Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#763 Upgrade save replacing all names from \\ to \n #899

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/page-header/rmp-to-rmg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export const ToRmgEndSelectModal = (props: {
whiteSpace="nowrap"
display="ruby"
>
{name1.replaceAll('\\', '⏎')}/{name2.replaceAll('\\', '⏎')}
{name1.replaceAll('\n', '⏎')}/{name2.replaceAll('\n', '⏎')}
</Button>
))}
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion src/components/panels/details/info-multiple-selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default function InfoMultipleSection() {
whiteSpace="nowrap"
display="ruby"
>
{getName(id)?.replaceAll('\\', '⏎')}
{getName(id)?.replaceAll('\n', '⏎')}
</Button>
<Button size="sm" onClick={() => dispatch(removeSelected(id))}>
<MdDeselect />
Expand Down
14 changes: 7 additions & 7 deletions src/components/svgs/nodes/jr-east-line-badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const JREastLineBadge = (props: NodeComponentProps<JREastLineBadgeAttributes>) =
</text>
<MultilineText
ref={textLineEl}
text={names[0].split('\\')}
text={names[0].split('\n')}
x={CIRCLE_X + CIRCLE_R + 1}
y="-1"
fill={color[3]}
Expand All @@ -130,7 +130,7 @@ const JREastLineBadge = (props: NodeComponentProps<JREastLineBadgeAttributes>) =
className="rmp-name__jreast_ja"
/>
<MultilineText
text={names[1].split('\\')}
text={names[1].split('\n')}
textAnchor="middle"
dominantBaseline="hanging"
x={(bBox.width + CIRCLE_R + 10) / 2}
Expand All @@ -149,7 +149,7 @@ const JREastLineBadge = (props: NodeComponentProps<JREastLineBadgeAttributes>) =
* JREastLineBadge specific props.
*/
export interface JREastLineBadgeAttributes extends AttributesWithColor {
names: [string, string];
names: [string, ...string[]];
num: number;
crosshatchPatternFill: boolean;
}
Expand Down Expand Up @@ -180,19 +180,19 @@ const jrEastLineBadgeAttrsComponent = (props: AttrsProps<JREastLineBadgeAttribut
{
type: 'textarea',
label: t('panel.details.nodes.common.nameJa'),
value: attrs.names[0].replaceAll('\\', '\n'),
value: attrs.names[0],
onChange: val => {
attrs.names[0] = val.replaceAll('\n', '\\');
attrs.names[0] = val;
handleAttrsUpdate(id, attrs);
},
minW: 'full',
},
{
type: 'textarea',
label: t('panel.details.nodes.common.nameEn'),
value: attrs.names[1].replaceAll('\\', '\n'),
value: attrs.names[1],
onChange: val => {
attrs.names[1] = val.replaceAll('\n', '\\');
attrs.names[1] = val;
handleAttrsUpdate(id, attrs);
},
minW: 'full',
Expand Down
28 changes: 13 additions & 15 deletions src/components/svgs/stations/bjsubway-basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ const BjsubwayBasicStation = (props: StationComponentProps) => {

const getTextOffset = (oX: NameOffsetX, oY: NameOffsetY) => {
if (oX === 'left' && oY === 'top') {
return [-4, -(names[1].split('\\').length + (!open ? 1 : 0)) * LINE_HEIGHT[oY] - 1];
return [-4, -(names[1].split('\n').length + (!open ? 1 : 0)) * LINE_HEIGHT[oY] - 1];
} else if (oX === 'middle' && oY === 'top') {
return [0, -(names[1].split('\\').length + (!open ? 1 : 0)) * LINE_HEIGHT[oY] - 4];
return [0, -(names[1].split('\n').length + (!open ? 1 : 0)) * LINE_HEIGHT[oY] - 4];
} else if (oX === 'right' && oY === 'top') {
return [4, -(names[1].split('\\').length + (!open ? 1 : 0)) * LINE_HEIGHT[oY] - 1];
return [4, -(names[1].split('\n').length + (!open ? 1 : 0)) * LINE_HEIGHT[oY] - 1];
} else if (oX === 'left' && oY === 'bottom') {
return [-4, names[0].split('\\').length * LINE_HEIGHT[oY] + 1];
return [-4, names[0].split('\n').length * LINE_HEIGHT[oY] + 1];
} else if (oX === 'middle' && oY === 'bottom') {
return [0, names[0].split('\\').length * LINE_HEIGHT[oY] + 4];
return [0, names[0].split('\n').length * LINE_HEIGHT[oY] + 4];
} else if (oX === 'right' && oY === 'bottom') {
return [4, names[0].split('\\').length * LINE_HEIGHT[oY] + 1];
return [4, names[0].split('\n').length * LINE_HEIGHT[oY] + 1];
} else if (oX === 'left' && oY === 'middle') {
return [-5, 0];
} else if (oX === 'right' && oY === 'middle') {
Expand All @@ -81,15 +81,15 @@ const BjsubwayBasicStation = (props: StationComponentProps) => {
/>
<g transform={`translate(${textX}, ${textY})`} textAnchor={textAnchor}>
<MultilineText
text={names[0].split('\\')}
text={names[0].split('\n')}
fontSize={LINE_HEIGHT.zh}
lineHeight={LINE_HEIGHT.zh}
grow="up"
className="rmp-name__zh"
baseOffset={1}
/>
<MultilineText
text={names[1].split('\\')}
text={names[1].split('\n')}
fontSize={LINE_HEIGHT.en}
lineHeight={LINE_HEIGHT.en}
grow="down"
Expand All @@ -98,7 +98,7 @@ const BjsubwayBasicStation = (props: StationComponentProps) => {
/>
{!open && (
<text
dy={names[1].split('\\').length * LINE_HEIGHT.en + 2}
dy={names[1].split('\n').length * LINE_HEIGHT.en + 2}
fontSize={LINE_HEIGHT.en}
dominantBaseline="hanging"
className="rmp-name__zh"
Expand Down Expand Up @@ -134,27 +134,25 @@ const bjsubwayBasicStationFields = [
{
type: 'textarea',
label: 'panel.details.stations.common.nameZh',
value: (attrs?: BjsubwayBasicStationAttributes) =>
(attrs ?? defaultBjsubwayBasicStationAttributes).names[0].replaceAll('\\', '\n'),
value: (attrs?: BjsubwayBasicStationAttributes) => (attrs ?? defaultBjsubwayBasicStationAttributes).names[0],
onChange: (val: string | number, attrs_: BjsubwayBasicStationAttributes | undefined) => {
// set default value if switched from another type
const attrs = attrs_ ?? defaultBjsubwayBasicStationAttributes;
// set value
attrs.names[0] = val.toString().replaceAll('\n', '\\');
attrs.names[0] = val.toString();
// return modified attrs
return attrs;
},
},
{
type: 'textarea',
label: 'panel.details.stations.common.nameEn',
value: (attrs?: BjsubwayBasicStationAttributes) =>
(attrs ?? defaultBjsubwayBasicStationAttributes).names[1].replaceAll('\\', '\n'),
value: (attrs?: BjsubwayBasicStationAttributes) => (attrs ?? defaultBjsubwayBasicStationAttributes).names[1],
onChange: (val: string | number, attrs_: BjsubwayBasicStationAttributes | undefined) => {
// set default value if switched from another type
const attrs = attrs_ ?? defaultBjsubwayBasicStationAttributes;
// set value
attrs.names[1] = val.toString().replaceAll('\n', '\\');
attrs.names[1] = val.toString();
// return modified attrs
return attrs;
},
Expand Down
26 changes: 12 additions & 14 deletions src/components/svgs/stations/bjsubway-int.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ const BjsubwayIntStation = (props: StationComponentProps) => {

const getTextOffset = (oX: NameOffsetX, oY: NameOffsetY) => {
if (oX === 'left' && oY === 'top') {
return [-5, -names[1].split('\\').length * LINE_HEIGHT[oY] - 4];
return [-5, -names[1].split('\n').length * LINE_HEIGHT[oY] - 4];
} else if (oX === 'middle' && oY === 'top') {
return [0, -names[1].split('\\').length * LINE_HEIGHT[oY] - 7];
return [0, -names[1].split('\n').length * LINE_HEIGHT[oY] - 7];
} else if (oX === 'right' && oY === 'top') {
return [5, -names[1].split('\\').length * LINE_HEIGHT[oY] - 4];
return [5, -names[1].split('\n').length * LINE_HEIGHT[oY] - 4];
} else if (oX === 'left' && oY === 'bottom') {
return [-5, names[0].split('\\').length * LINE_HEIGHT[oY] + 4];
return [-5, names[0].split('\n').length * LINE_HEIGHT[oY] + 4];
} else if (oX === 'middle' && oY === 'bottom') {
return [0, names[0].split('\\').length * LINE_HEIGHT[oY] + 7];
return [0, names[0].split('\n').length * LINE_HEIGHT[oY] + 7];
} else if (oX === 'right' && oY === 'bottom') {
return [5, names[0].split('\\').length * LINE_HEIGHT[oY] + 4];
return [5, names[0].split('\n').length * LINE_HEIGHT[oY] + 4];
} else if (oX === 'left' && oY === 'middle') {
return [-8, 0];
} else if (oX === 'right' && oY === 'middle') {
Expand Down Expand Up @@ -90,15 +90,15 @@ const BjsubwayIntStation = (props: StationComponentProps) => {
</g>
<g transform={`translate(${x + textX}, ${y + textY})`} textAnchor={textAnchor}>
<MultilineText
text={names[0].split('\\')}
text={names[0].split('\n')}
fontSize={LINE_HEIGHT.zh}
lineHeight={LINE_HEIGHT.zh}
grow="up"
className="rmp-name__zh"
baseOffset={1}
/>
<MultilineText
text={names[1].split('\\')}
text={names[1].split('\n')}
fontSize={LINE_HEIGHT.en}
lineHeight={LINE_HEIGHT.en}
grow="down"
Expand Down Expand Up @@ -130,27 +130,25 @@ const bjsubwayIntStationFields = [
{
type: 'textarea',
label: 'panel.details.stations.common.nameZh',
value: (attrs?: BjsubwayIntStationAttributes) =>
(attrs ?? defaultBjsubwayIntStationAttributes).names[0].replaceAll('\\', '\n'),
value: (attrs?: BjsubwayIntStationAttributes) => (attrs ?? defaultBjsubwayIntStationAttributes).names[0],
onChange: (val: string | number, attrs_: BjsubwayIntStationAttributes | undefined) => {
// set default value if switched from another type
const attrs = attrs_ ?? defaultBjsubwayIntStationAttributes;
// set value
attrs.names[0] = val.toString().replaceAll('\n', '\\');
attrs.names[0] = val.toString();
// return modified attrs
return attrs;
},
},
{
type: 'textarea',
label: 'panel.details.stations.common.nameEn',
value: (attrs?: BjsubwayIntStationAttributes) =>
(attrs ?? defaultBjsubwayIntStationAttributes).names[1].replaceAll('\\', '\n'),
value: (attrs?: BjsubwayIntStationAttributes) => (attrs ?? defaultBjsubwayIntStationAttributes).names[1],
onChange: (val: string | number, attrs_: BjsubwayIntStationAttributes | undefined) => {
// set default value if switched from another type
const attrs = attrs_ ?? defaultBjsubwayIntStationAttributes;
// set value
attrs.names[1] = val.toString().replaceAll('\n', '\\');
attrs.names[1] = val.toString();
// return modified attrs
return attrs;
},
Expand Down
12 changes: 6 additions & 6 deletions src/components/svgs/stations/foshan-metro-basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ const FoshanMetroBasicStation = (props: StationComponentProps) => {
</g>
<g ref={textRef} transform={`translate(${textX}, ${textY})`} textAnchor={textAnchor}>
<MultilineText
text={names[0].split('\\')}
text={names[0].split('\n')}
fontSize={FONT_SIZE.zh}
lineHeight={FONT_SIZE.zh}
grow="up"
className="rmp-name__zh"
/>
<MultilineText
text={names[1].split('\\')}
text={names[1].split('\n')}
fontSize={FONT_SIZE.en}
lineHeight={FONT_SIZE.en}
grow="down"
Expand Down Expand Up @@ -221,19 +221,19 @@ const foshanMetroBasicStationAttrsComponents = (props: AttrsProps<FoshanMetroBas
{
type: 'textarea',
label: t('panel.details.stations.common.nameZh'),
value: attrs.names[0].replaceAll('\\', '\n'),
value: attrs.names[0],
onChange: val => {
attrs.names[0] = val.replaceAll('\n', '\\');
attrs.names[0] = val;
handleAttrsUpdate(id, attrs);
},
minW: 'full',
},
{
type: 'textarea',
label: t('panel.details.stations.common.nameEn'),
value: attrs.names[1].replaceAll('\\', '\n'),
value: attrs.names[1],
onChange: val => {
attrs.names[1] = val.replaceAll('\n', '\\');
attrs.names[1] = val;
handleAttrsUpdate(id, attrs);
},
minW: 'full',
Expand Down
6 changes: 3 additions & 3 deletions src/components/svgs/stations/guangdong-intercity-railway.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const GuangdongIntercityRailwayStation = (props: StationComponentProps) => {

const textX = nameOffsetX === 'left' ? -13.33 : nameOffsetX === 'right' ? 13.33 : 0;
const textY =
(names[NAME_DY[nameOffsetY].namesPos].split('\\').length * NAME_DY_SH_BASIC[nameOffsetY].lineHeight +
(names[NAME_DY[nameOffsetY].namesPos].split('\n').length * NAME_DY_SH_BASIC[nameOffsetY].lineHeight +
NAME_DY_SH_BASIC[nameOffsetY].offset) *
NAME_DY[nameOffsetY].polarity;
const textAnchor = nameOffsetX === 'left' ? 'end' : nameOffsetX === 'right' ? 'start' : 'middle';
Expand Down Expand Up @@ -66,15 +66,15 @@ const GuangdongIntercityRailwayStation = (props: StationComponentProps) => {
strokeWidth="1"
>
<MultilineText
text={names[0].split('\\')}
text={names[0].split('\n')}
fontSize={13.13}
lineHeight={13.13}
grow="up"
baseOffset={1}
className="rmp-name__zh"
/>
<MultilineText
text={names[1].split('\\')}
text={names[1].split('\n')}
dx={nameOffsetX === 'right' ? 1.67 : 0}
fontSize={5.83}
lineHeight={5.83}
Expand Down
12 changes: 6 additions & 6 deletions src/components/svgs/stations/gzmtr-basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ const GzmtrBasicStation = (props: StationComponentProps) => {
</g>
<g ref={textRef} transform={`translate(${textX}, ${textY})`} textAnchor={textAnchor}>
<MultilineText
text={names[0].split('\\')}
text={names[0].split('\n')}
fontSize={FONT_SIZE.zh}
lineHeight={FONT_SIZE.zh}
grow="up"
className="rmp-name__zh"
/>
<MultilineText
text={names[1].split('\\')}
text={names[1].split('\n')}
fontSize={FONT_SIZE.en}
lineHeight={FONT_SIZE.en}
grow="down"
Expand Down Expand Up @@ -224,19 +224,19 @@ const gzmtrBasicStationAttrsComponents = (props: AttrsProps<GzmtrBasicStationAtt
{
type: 'textarea',
label: t('panel.details.stations.common.nameZh'),
value: attrs.names[0].replaceAll('\\', '\n'),
value: attrs.names[0],
onChange: val => {
attrs.names[0] = val.replaceAll('\n', '\\');
attrs.names[0] = val;
handleAttrsUpdate(id, attrs);
},
minW: 'full',
},
{
type: 'textarea',
label: t('panel.details.stations.common.nameEn'),
value: attrs.names[1].replaceAll('\\', '\n'),
value: attrs.names[1],
onChange: val => {
attrs.names[1] = val.replaceAll('\n', '\\');
attrs.names[1] = val;
handleAttrsUpdate(id, attrs);
},
minW: 'full',
Expand Down
12 changes: 6 additions & 6 deletions src/components/svgs/stations/gzmtr-int.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,14 @@ const GzmtrIntStation = (props: StationComponentProps) => {

<g ref={textRef} transform={`translate(${textX}, ${textY})`} textAnchor={textAnchor}>
<MultilineText
text={names[0].split('\\')}
text={names[0].split('\n')}
fontSize={FONT_SIZE.zh}
lineHeight={FONT_SIZE.zh}
grow="up"
className="rmp-name__zh"
/>
<MultilineText
text={names[1].split('\\')}
text={names[1].split('\n')}
fontSize={FONT_SIZE.en}
lineHeight={FONT_SIZE.en}
grow="down"
Expand Down Expand Up @@ -404,19 +404,19 @@ const gzmtrIntStationAttrsComponents = (props: AttrsProps<GzmtrIntStationAttribu
{
type: 'textarea',
label: t('panel.details.stations.common.nameZh'),
value: attrs.names[0].replaceAll('\\', '\n'),
value: attrs.names[0],
onChange: val => {
attrs.names[0] = val.replaceAll('\n', '\\');
attrs.names[0] = val;
handleAttrsUpdate(id, attrs);
},
minW: 'full',
},
{
type: 'textarea',
label: t('panel.details.stations.common.nameEn'),
value: attrs.names[1].replaceAll('\\', '\n'),
value: attrs.names[1],
onChange: val => {
attrs.names[1] = val.replaceAll('\n', '\\');
attrs.names[1] = val;
handleAttrsUpdate(id, attrs);
},
minW: 'full',
Expand Down
Loading
Loading