refactor: define type instead of IndexAccessType (#549)

main
skanehira 2022-10-26 16:37:43 +09:00 committed by GitHub
parent 0ab6c08ea1
commit 3609b7e639
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 39 deletions

View File

@ -1,8 +1,8 @@
import { RunJSON, RunPropertyJSON } from "./run"; import { RunJSON, RunPropertyJSON } from "./run";
import { IndentJSON } from "./indent"; import { IndentJSON } from "./indent";
import { import {
CommentRangeStartJSON,
CommentRangeEndJSON, CommentRangeEndJSON,
CommentRangeStartJSON,
SectionPropertyJSON, SectionPropertyJSON,
} from ".."; } from "..";
import { LineSpacingJSON } from "./line_spacing"; import { LineSpacingJSON } from "./line_spacing";
@ -61,43 +61,47 @@ export type ParagraphJSON = {
}; };
}; };
export type InsertJSONData = {
children: (
| DeleteJSON
| RunJSON
| CommentRangeStartJSON
| CommentRangeEndJSON
)[];
author: string;
date: string;
};
export type InsertJSON = { export type InsertJSON = {
type: "insert"; type: "insert";
data: { data: InsertJSONData;
children: ( };
| DeleteJSON
| RunJSON export type DeleteJSONData = {
| CommentRangeStartJSON children: DeleteChildJSON[];
| CommentRangeEndJSON author: string;
)[]; date: string;
author: string;
date: string;
};
}; };
export type DeleteJSON = { export type DeleteJSON = {
type: "delete"; type: "delete";
data: { data: DeleteJSONData;
children: DeleteChildJSON[];
author: string;
date: string;
};
}; };
export type HyperlinkJSON = { export type HyperlinkJSON = {
type: "hyperlink"; type: "hyperlink";
data: data:
| { | {
type: "external"; type: "external";
rid: string; rid: string;
children: HyperlinkChildJSON[]; children: HyperlinkChildJSON[];
history: number | null; history: number | null;
} }
| { | {
type: "anchor"; type: "anchor";
anchor: string; anchor: string;
children: HyperlinkChildJSON[]; children: HyperlinkChildJSON[];
}; };
}; };
export type DeleteChildJSON = export type DeleteChildJSON =

View File

@ -1,8 +1,7 @@
import { DrawingJSON } from "./drawing"; import { DrawingJSON } from "./drawing";
import { ShapeJSON } from "./shape"; import { ShapeJSON } from "./shape";
import { CommentRangeStartJSON, CommentRangeEndJSON } from ".."; import { CommentRangeStartJSON, CommentRangeEndJSON, InsertJSONData, DeleteJSONData } from "..";
import { BorderType } from "../border"; import { BorderType } from "../border";
import { InsertJSON, DeleteJSON } from "./paragraph";
import { VertAlignType } from "../run"; import { VertAlignType } from "../run";
import { FieldChar } from "./bindings/FieldChar"; import { FieldChar } from "./bindings/FieldChar";
import { InstrHyperlink } from "./bindings/InstrHyperlink"; import { InstrHyperlink } from "./bindings/InstrHyperlink";
@ -43,8 +42,8 @@ export type RunPropertyJSON = {
vanish?: boolean | null; vanish?: boolean | null;
spacing?: number | null; spacing?: number | null;
textBorder?: TextBorderJSON | null; textBorder?: TextBorderJSON | null;
ins?: InsertJSON["data"] | null; ins?: InsertJSONData | null;
del?: DeleteJSON["data"] | null; del?: DeleteJSONData | null;
strike?: boolean; strike?: boolean;
}; };
@ -103,14 +102,14 @@ export type FieldCharJSON = {
export type InstrTextJSON = { export type InstrTextJSON = {
type: "instrText"; type: "instrText";
data: data:
| { | {
type: "hyperlink"; type: "hyperlink";
data: InstrHyperlink; data: InstrHyperlink;
} }
| { | {
type: "toc"; type: "toc";
data: InstrToC; data: InstrToC;
}; };
}; };
export type InstrTextStringJSON = { export type InstrTextStringJSON = {