Skip to content

Commit 81af2d3

Browse files
committed
バグなどを修正
1 parent 046ecd1 commit 81af2d3

11 files changed

Lines changed: 115 additions & 118 deletions

File tree

packages/frontend/src/pages/components/ExportDialog.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,11 @@ export default function ExportDialog({ isOpen, onClose }: ExportDialogProps) {
466466
<Divider sx={{ my: 2 }} />
467467
<Stack gap={2}>
468468
<Typography variant="subtitle1" component="div">
469-
レイアウト方式
469+
配置方式
470470
</Typography>
471471
<Stack direction="row" gap={1}>
472472
<FormControl>
473-
<InputLabel>レイアウト方式</InputLabel>
473+
<InputLabel>配置方式</InputLabel>
474474
<Select
475475
value={configurations.layoutMode}
476476
onChange={(e) =>
@@ -479,7 +479,7 @@ export default function ExportDialog({ isOpen, onClose }: ExportDialogProps) {
479479
layoutMode: e.target.value,
480480
})
481481
}
482-
label="レイアウト方式"
482+
label="配置方式"
483483
>
484484
<MenuItem value="linear">横並び表示</MenuItem>
485485
<MenuItem value="structured">構造化表示</MenuItem>

packages/frontend/src/pages/components/SentenceStructureDiagramAnnotator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export default function SentenceStructureDiagramAnnotator(
255255
</text>
256256
),
257257
)}
258-
{/* 矢印 */}
258+
{/* 修飾 */}
259259
{props.sentenceStructureDiagramData.relations.map((relation) => (
260260
<path
261261
key={relation.relationId}

packages/frontend/src/pages/components/SentenceStructureEditor.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ export default function SentenceStructureEditor() {
302302
}
303303
}}
304304
>
305-
矢印
305+
修飾
306306
</Button>
307307
<Divider orientation="vertical" flexItem />
308308
<Button
@@ -345,7 +345,7 @@ export default function SentenceStructureEditor() {
345345
}}
346346
onMouseUp={(e) => e.stopPropagation()}
347347
>
348-
{(activeRange.kind === "sentence-element"
348+
{(activeRange.kind === "core-sentence-element"
349349
? sentenceElementRangeTypeToAllowedSentenceElementNameOptionsMap[
350350
activeRange.type
351351
]
@@ -378,7 +378,7 @@ export default function SentenceStructureEditor() {
378378
}
379379
}}
380380
>
381-
矢印
381+
修飾
382382
</Button>
383383
<Divider orientation="vertical" flexItem />
384384
<Button
@@ -407,7 +407,7 @@ export default function SentenceStructureEditor() {
407407
);
408408
})()}
409409

410-
{/* 矢印の作成のキャンセル */}
410+
{/* 修飾の作成のキャンセル */}
411411
{(interactionState.type === "relation-idle" ||
412412
interactionState.type === "relation-selecting") &&
413413
(() => {
@@ -443,7 +443,7 @@ export default function SentenceStructureEditor() {
443443
);
444444
})()}
445445

446-
{/* 矢印の削除 */}
446+
{/* 修飾の削除 */}
447447
{interactionState.type === "relation-selected" &&
448448
(() => {
449449
const activeRelation = findRelationById(
@@ -484,7 +484,7 @@ export default function SentenceStructureEditor() {
484484
}}
485485
color="error"
486486
>
487-
矢印を削除
487+
修飾を削除
488488
</Button>
489489
</Paper>
490490
);

packages/sentence-structure-data/format.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const simplifiedSentenceStructureDataToSentenceStructureData = z.codec(
9191
)!,
9292
)
9393
? {
94-
kind: "sentence-element",
94+
kind: "core-sentence-element",
9595
type: simplifiedSentenceElementRangeTypeToSentenceElementRangeTypeMap.get(
9696
range.type as any,
9797
)!,
@@ -178,7 +178,7 @@ export const simplifiedSentenceStructureDataToSentenceStructureData = z.codec(
178178
}
179179
: {
180180
type:
181-
range.kind === "sentence-element"
181+
range.kind === "core-sentence-element"
182182
? sentenceElementRangeTypeToSimplifiedSentenceElementRangeTypeMap.get(
183183
range.type,
184184
)!

packages/sentence-structure-data/operations.ts

Lines changed: 83 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export function createSentenceElementRange(
167167
ranges: [
168168
...sentenceStructureData.ranges,
169169
{
170-
kind: "sentence-element",
170+
kind: "core-sentence-element",
171171
type: input.type,
172172
id: rangeId,
173173
startWordIndex: input.startWordIndex,
@@ -248,53 +248,6 @@ export function createSentenceStructureRange(
248248
throw newSentenceStructureData.error;
249249
}
250250

251-
export function _createRelationRange(
252-
sentenceStructureData: SentenceStructureData,
253-
input: {
254-
startWordIndex: number;
255-
endWordIndex: number;
256-
},
257-
): Result<{
258-
newSentenceStructureData: SentenceStructureData;
259-
rangeId: string;
260-
}> {
261-
const rangeId = crypto.randomUUID();
262-
const newSentenceStructureData = SentenceStructureDataSchema.safeParse({
263-
...sentenceStructureData,
264-
ranges: [
265-
...sentenceStructureData.ranges,
266-
{
267-
kind: "relation",
268-
type: "relation",
269-
id: rangeId,
270-
startWordIndex: input.startWordIndex,
271-
endWordIndex: input.endWordIndex,
272-
},
273-
],
274-
} satisfies SentenceStructureData);
275-
276-
if (newSentenceStructureData.success) {
277-
return {
278-
success: true,
279-
data: {
280-
newSentenceStructureData: newSentenceStructureData.data,
281-
rangeId,
282-
},
283-
};
284-
}
285-
const errorMessage =
286-
newSentenceStructureData.error.issues.find(
287-
(issue) => issue.code === "custom",
288-
)?.message ?? null;
289-
if (errorMessage) {
290-
return {
291-
success: false,
292-
message: errorMessage,
293-
};
294-
}
295-
throw newSentenceStructureData.error;
296-
}
297-
298251
export function findRangeById(
299252
sentenceStructureData: SentenceStructureData,
300253
input: { rangeId: string },
@@ -366,10 +319,10 @@ export function createRelation(
366319
toRange: { startWordIndex: number; endWordIndex: number };
367320
},
368321
): Result<{ newSentenceStructureData: SentenceStructureData }> {
369-
const fromRangeResult: Result<{
322+
const fromRangeResult: {
370323
newSentenceStructureData: SentenceStructureData;
371324
rangeId: string;
372-
}> = (() => {
325+
} = (() => {
373326
const existingFromRange = findRangeByStartAndEndWordIndex(
374327
sentenceStructureData,
375328
{
@@ -379,74 +332,99 @@ export function createRelation(
379332
);
380333
if (existingFromRange) {
381334
return {
382-
success: true,
383-
data: {
384-
newSentenceStructureData: sentenceStructureData,
385-
rangeId: existingFromRange.id,
386-
},
335+
newSentenceStructureData: sentenceStructureData,
336+
rangeId: existingFromRange.id,
387337
};
388338
}
389-
return _createRelationRange(sentenceStructureData, {
390-
startWordIndex: input.fromRange.startWordIndex,
391-
endWordIndex: input.fromRange.endWordIndex,
392-
});
393-
})();
394-
if (!fromRangeResult.success) {
339+
340+
const rangeId = crypto.randomUUID();
341+
const newSentenceStructureData: SentenceStructureData = {
342+
...sentenceStructureData,
343+
ranges: [
344+
...sentenceStructureData.ranges,
345+
{
346+
kind: "relation",
347+
type: "relation",
348+
id: rangeId,
349+
startWordIndex: input.fromRange.startWordIndex,
350+
endWordIndex: input.fromRange.endWordIndex,
351+
},
352+
],
353+
};
395354
return {
396-
success: false,
397-
message: fromRangeResult.message,
355+
newSentenceStructureData,
356+
rangeId,
398357
};
399-
}
358+
})();
400359

401-
const toRangeResult: Result<{
360+
const toRangeResult: {
402361
newSentenceStructureData: SentenceStructureData;
403362
rangeId: string;
404-
}> = (() => {
363+
} = (() => {
405364
const existingToRange = findRangeByStartAndEndWordIndex(
406-
fromRangeResult.data.newSentenceStructureData,
365+
fromRangeResult.newSentenceStructureData,
407366
{
408367
startWordIndex: input.toRange.startWordIndex,
409368
endWordIndex: input.toRange.endWordIndex,
410369
},
411370
);
412371
if (existingToRange) {
413372
return {
414-
success: true,
415-
data: {
416-
newSentenceStructureData:
417-
fromRangeResult.data.newSentenceStructureData,
418-
rangeId: existingToRange.id,
419-
},
373+
newSentenceStructureData: fromRangeResult.newSentenceStructureData,
374+
rangeId: existingToRange.id,
420375
};
421376
}
422-
return _createRelationRange(fromRangeResult.data.newSentenceStructureData, {
423-
startWordIndex: input.toRange.startWordIndex,
424-
endWordIndex: input.toRange.endWordIndex,
425-
});
377+
378+
const rangeId = crypto.randomUUID();
379+
const newSentenceStructureData: SentenceStructureData = {
380+
...fromRangeResult.newSentenceStructureData,
381+
ranges: [
382+
...fromRangeResult.newSentenceStructureData.ranges,
383+
{
384+
kind: "relation",
385+
type: "relation",
386+
id: rangeId,
387+
startWordIndex: input.toRange.startWordIndex,
388+
endWordIndex: input.toRange.endWordIndex,
389+
},
390+
],
391+
};
392+
return {
393+
newSentenceStructureData,
394+
rangeId,
395+
};
426396
})();
427-
if (!toRangeResult.success) {
397+
398+
const newSentenceStructureData = SentenceStructureDataSchema.safeParse({
399+
...toRangeResult.newSentenceStructureData,
400+
relations: [
401+
...toRangeResult.newSentenceStructureData.relations,
402+
{
403+
id: crypto.randomUUID(),
404+
fromRangeId: fromRangeResult.rangeId,
405+
toRangeId: toRangeResult.rangeId,
406+
},
407+
],
408+
} satisfies SentenceStructureData);
409+
if (newSentenceStructureData.success) {
410+
return {
411+
success: true,
412+
data: {
413+
newSentenceStructureData: newSentenceStructureData.data,
414+
},
415+
};
416+
}
417+
const errorMessage =
418+
newSentenceStructureData.error.issues.find(
419+
(issue) => issue.code === "custom",
420+
)?.message ?? null;
421+
if (errorMessage) {
428422
return {
429423
success: false,
430-
message: toRangeResult.message,
424+
message: errorMessage,
431425
};
432426
}
433-
434-
return {
435-
success: true,
436-
data: {
437-
newSentenceStructureData: SentenceStructureDataSchema.parse({
438-
...toRangeResult.data.newSentenceStructureData,
439-
relations: [
440-
...toRangeResult.data.newSentenceStructureData.relations,
441-
{
442-
id: crypto.randomUUID(),
443-
fromRangeId: fromRangeResult.data.rangeId,
444-
toRangeId: toRangeResult.data.rangeId,
445-
},
446-
],
447-
} satisfies SentenceStructureData),
448-
},
449-
};
427+
throw newSentenceStructureData.error;
450428
}
451429

452430
export function findRelationById(
@@ -466,6 +444,15 @@ export function deleteRelation(
466444
): SentenceStructureData {
467445
return SentenceStructureDataSchema.parse({
468446
...sentenceStructureData,
447+
ranges: sentenceStructureData.ranges.filter(
448+
(range) =>
449+
range.kind !== "relation" ||
450+
sentenceStructureData.relations.some(
451+
(relation) =>
452+
relation.fromRangeId !== range.id &&
453+
relation.toRangeId !== range.id,
454+
),
455+
),
469456
relations: sentenceStructureData.relations.filter(
470457
(relation) => relation.id !== input.relationId,
471458
),

packages/sentence-structure-data/schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const RangeSchema = z.union([
4545
(sentenceElementRangeTypeOption) =>
4646
({
4747
"core-sentence-element": z.object({
48-
kind: z.literal("sentence-element"),
48+
kind: z.literal("core-sentence-element"),
4949
type: z.literal("core-sentence-element"),
5050
id: z.uuid(),
5151
startWordIndex: z.int().nonnegative(),
@@ -108,7 +108,7 @@ const RangeSchema = z.union([
108108
})[sentenceStructureRangeTypeOption],
109109
),
110110
z.object({
111-
kind: z.literal(relationRangeTypeOption),
111+
kind: z.literal("relation"),
112112
type: z.literal("relation"),
113113
id: z.uuid(),
114114
startWordIndex: z.int().nonnegative(),

packages/sentence-structure-diagram-data/generate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export function convertSentenceStructureDataToSentenceStructureDiagramData(
104104
]
105105
: null,
106106
position:
107-
range.kind === "sentence-element"
107+
range.kind === "core-sentence-element"
108108
? resolvedConfigurations.sentenceElementPosition.determineSentenceElementRangeSentenceElementPosition(
109109
rangePosition,
110110
)

packages/sentence-structure-diagram-data/resolve-configurations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function determineSentenceElementPosition(
8181
};
8282
case "bottom-left":
8383
return {
84-
x: rangePosition[0]!.start - 4,
84+
x: rangePosition[0]!.start + 6,
8585
y: rangePosition[0]!.bottom + 8,
8686
};
8787
}

packages/sentence-structure-diagram-svg/SentenceStructureDiagram.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export default function SentenceStructureDiagram(
117117
</text>
118118
),
119119
)}
120-
{/* 矢印 */}
120+
{/* 修飾 */}
121121
{sentenceStructureDiagramData.relations.map((relation) => (
122122
<path
123123
key={relation.relationId}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const lineHeight = 16;
22
export const lineSpacing = 48;
33
export const wordSpacing = 32;
4+
export const indentSpacing = 32;
45
export const padding = 48;

0 commit comments

Comments
 (0)