feat:data persistent format

pr675
黄云飞 4 years ago
parent 8a4688cfd1
commit c13404738b

@ -1,9 +1,11 @@
import { version } from "../../../../package.json"
import { ElementType } from "../.." import { ElementType } from "../.."
import { ZERO } from "../../dataset/constant/Common" import { ZERO } from "../../dataset/constant/Common"
import { EDITOR_ELEMENT_COPY_ATTR } from "../../dataset/constant/Element" import { EDITOR_ELEMENT_COPY_ATTR } from "../../dataset/constant/Element"
import { ElementStyleKey } from "../../dataset/enum/ElementStyle" import { ElementStyleKey } from "../../dataset/enum/ElementStyle"
import { MouseEventButton } from "../../dataset/enum/Event" import { MouseEventButton } from "../../dataset/enum/Event"
import { KeyMap } from "../../dataset/enum/Keymap" import { KeyMap } from "../../dataset/enum/Keymap"
import { IEditorResult } from "../../interface/Editor"
import { IElement } from "../../interface/Element" import { IElement } from "../../interface/Element"
import { ICurrentPosition } from "../../interface/Position" import { ICurrentPosition } from "../../interface/Position"
import { writeTextByElementList } from "../../utils/clipboard" import { writeTextByElementList } from "../../utils/clipboard"
@ -455,10 +457,19 @@ export class CanvasEvent {
this.isCompositing = false this.isCompositing = false
} }
public save(): IElement[] { public save(): IEditorResult {
// 配置
const { width, height, margins } = this.draw.getOptions()
// 数据
const elementList = this.draw.getOriginalElementList() const elementList = this.draw.getOriginalElementList()
const data = zipElementList(elementList) const data = zipElementList(elementList)
return data return {
version,
width,
height,
margins,
data
}
} }
} }

@ -1,3 +1,5 @@
import { IElement } from ".."
export interface IEditorOption { export interface IEditorOption {
defaultType?: string; defaultType?: string;
defaultFont?: string; defaultFont?: string;
@ -28,3 +30,11 @@ export interface IEditorOption {
defaultTdHeight?: number; defaultTdHeight?: number;
defaultHyperlinkColor?: string; defaultHyperlinkColor?: string;
} }
export interface IEditorResult {
version: string;
width: number;
height: number;
margins: [top: number, right: number, bootom: number, left: number];
data: IElement[];
}

@ -1,5 +1,5 @@
import { IElement } from ".."
import { RowFlex } from "../dataset/enum/Row" import { RowFlex } from "../dataset/enum/Row"
import { IEditorResult } from "./Editor"
export interface IRangeStype { export interface IRangeStype {
undo: boolean; undo: boolean;
@ -13,7 +13,7 @@ export interface IRangeStype {
color: string | null; color: string | null;
highlight: string | null; highlight: string | null;
rowFlex: RowFlex | null; rowFlex: RowFlex | null;
rowMargin: number rowMargin: number;
} }
export type IRangeStyleChange = (payload: IRangeStype) => void export type IRangeStyleChange = (payload: IRangeStype) => void
@ -26,4 +26,4 @@ export type IPageSizeChange = (payload: number) => void
export type IPageScaleChange = (payload: number) => void export type IPageScaleChange = (payload: number) => void
export type ISaved = (payload: IElement[]) => void export type ISaved = (payload: IEditorResult) => void

Loading…
Cancel
Save