@hufe921/canvas-editor 0.9.90 → 0.9.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/canvas-editor.es.js +312 -123
  3. package/dist/canvas-editor.es.js.map +1 -1
  4. package/dist/canvas-editor.umd.js +31 -30
  5. package/dist/canvas-editor.umd.js.map +1 -1
  6. package/dist/src/editor/core/actuator/Actuator.d.ts +7 -0
  7. package/dist/src/editor/core/actuator/handlers/positionContextChange.d.ts +3 -0
  8. package/dist/src/editor/core/command/Command.d.ts +1 -0
  9. package/dist/src/editor/core/command/CommandAdapt.d.ts +2 -1
  10. package/dist/src/editor/core/draw/Draw.d.ts +4 -0
  11. package/dist/src/editor/core/draw/control/date/DateControl.d.ts +1 -0
  12. package/dist/src/editor/core/draw/control/select/SelectControl.d.ts +1 -0
  13. package/dist/src/editor/core/draw/control/text/TextControl.d.ts +1 -0
  14. package/dist/src/editor/core/draw/frame/PageBorder.d.ts +9 -0
  15. package/dist/src/editor/core/draw/particle/date/DateParticle.d.ts +1 -0
  16. package/dist/src/editor/core/event/handlers/mousedown.d.ts +4 -0
  17. package/dist/src/editor/core/position/Position.d.ts +1 -0
  18. package/dist/src/editor/dataset/constant/PageBorder.d.ts +2 -0
  19. package/dist/src/editor/dataset/enum/Editor.d.ts +2 -1
  20. package/dist/src/editor/interface/Control.d.ts +2 -1
  21. package/dist/src/editor/interface/Editor.d.ts +6 -1
  22. package/dist/src/editor/interface/EventBus.d.ts +2 -1
  23. package/dist/src/editor/interface/Listener.d.ts +6 -0
  24. package/dist/src/editor/interface/PageBorder.d.ts +7 -0
  25. package/dist/src/editor/interface/table/Td.d.ts +4 -0
  26. package/dist/src/editor/interface/table/Tr.d.ts +2 -0
  27. package/dist/src/editor/utils/element.d.ts +3 -1
  28. package/package.json +1 -1
@@ -0,0 +1,7 @@
1
+ import { Draw } from '../draw/Draw';
2
+ export declare class Actuator {
3
+ private draw;
4
+ private eventBus;
5
+ constructor(draw: Draw);
6
+ private execute;
7
+ }
@@ -0,0 +1,3 @@
1
+ import { IPositionContextChangePayload } from '../../../interface/Listener';
2
+ import { Draw } from '../../draw/Draw';
3
+ export declare function positionContextChange(draw: Draw, payload: IPositionContextChangePayload): void;
@@ -93,6 +93,7 @@ export declare class Command {
93
93
  executeInsertControl: CommandAdapt['insertControl'];
94
94
  executeUpdateOptions: CommandAdapt['updateOptions'];
95
95
  executeInsertTitle: CommandAdapt['insertTitle'];
96
+ executeFocus: CommandAdapt['focus'];
96
97
  getCatalog: CommandAdapt['getCatalog'];
97
98
  getImage: CommandAdapt['getImage'];
98
99
  getOptions: CommandAdapt['getOptions'];
@@ -9,7 +9,7 @@ import { ICatalog } from '../../interface/Catalog';
9
9
  import { DeepRequired } from '../../interface/Common';
10
10
  import { IGetControlValueOption, IGetControlValueResult, ILocationControlOption, ISetControlExtensionOption, ISetControlHighlightOption, ISetControlProperties, ISetControlValueOption } from '../../interface/Control';
11
11
  import { IAppendElementListOption, IDrawImagePayload, IForceUpdateOption, IGetImageOption, IGetValueOption, IPainterOption } from '../../interface/Draw';
12
- import { IEditorData, IEditorHTML, IEditorOption, IEditorResult, IEditorText, ISetValueOption, IUpdateOption } from '../../interface/Editor';
12
+ import { IEditorData, IEditorHTML, IEditorOption, IEditorResult, IEditorText, IFocusOption, ISetValueOption, IUpdateOption } from '../../interface/Editor';
13
13
  import { IElement, IUpdateElementByIdOption } from '../../interface/Element';
14
14
  import { IPasteOption, IPositionContextByEvent } from '../../interface/Event';
15
15
  import { IMargin } from '../../interface/Margin';
@@ -149,4 +149,5 @@ export declare class CommandAdapt {
149
149
  getTitleValue(payload: IGetTitleValueOption): IGetTitleValueResult | null;
150
150
  getPositionContextByEvent(evt: MouseEvent): IPositionContextByEvent | null;
151
151
  insertTitle(payload: IElement): void;
152
+ focus(payload?: IFocusOption): void;
152
153
  }
@@ -35,6 +35,7 @@ import { EventBusMap } from '../../interface/EventBus';
35
35
  import { Group } from './interactive/Group';
36
36
  import { Override } from '../override/Override';
37
37
  import { LineBreakParticle } from './particle/LineBreakParticle';
38
+ import { ITd } from '../../interface/table/Td';
38
39
  export declare class Draw {
39
40
  private container;
40
41
  private pageContainer;
@@ -87,6 +88,7 @@ export declare class Draw {
87
88
  private listParticle;
88
89
  private lineBreakParticle;
89
90
  private control;
91
+ private pageBorder;
90
92
  private workerManager;
91
93
  private scrollObserver;
92
94
  private selectionObserver;
@@ -107,6 +109,7 @@ export declare class Draw {
107
109
  setMode(payload: EditorMode): void;
108
110
  isReadonly(): boolean;
109
111
  isDisabled(): boolean;
112
+ isDesignMode(): boolean;
110
113
  getOriginalWidth(): number;
111
114
  getOriginalHeight(): number;
112
115
  getWidth(): number;
@@ -158,6 +161,7 @@ export declare class Draw {
158
161
  getOriginalElementList(): IElement[];
159
162
  getOriginalMainElementList(): IElement[];
160
163
  getFooterElementList(): IElement[];
164
+ getTd(): ITd | null;
161
165
  insertElementList(payload: IElement[]): void;
162
166
  appendElementList(elementList: IElement[], options?: IAppendElementListOption): void;
163
167
  spliceElementList(elementList: IElement[], start: number, deleteCount: number, ...items: IElement[]): void;
@@ -7,6 +7,7 @@ export declare class DateControl implements IControlInstance {
7
7
  private control;
8
8
  private isPopup;
9
9
  private datePicker;
10
+ private options;
10
11
  constructor(element: IElement, control: Control);
11
12
  setElement(element: IElement): void;
12
13
  getElement(): IElement;
@@ -6,6 +6,7 @@ export declare class SelectControl implements IControlInstance {
6
6
  private control;
7
7
  private isPopup;
8
8
  private selectDom;
9
+ private options;
9
10
  constructor(element: IElement, control: Control);
10
11
  setElement(element: IElement): void;
11
12
  getElement(): IElement;
@@ -4,6 +4,7 @@ import { Control } from '../Control';
4
4
  export declare class TextControl implements IControlInstance {
5
5
  private element;
6
6
  private control;
7
+ private options;
7
8
  constructor(element: IElement, control: Control);
8
9
  setElement(element: IElement): void;
9
10
  getElement(): IElement;
@@ -0,0 +1,9 @@
1
+ import { Draw } from '../Draw';
2
+ export declare class PageBorder {
3
+ private draw;
4
+ private header;
5
+ private footer;
6
+ private options;
7
+ constructor(draw: Draw);
8
+ render(ctx: CanvasRenderingContext2D): void;
9
+ }
@@ -4,6 +4,7 @@ export declare class DateParticle {
4
4
  private draw;
5
5
  private range;
6
6
  private datePicker;
7
+ private options;
7
8
  constructor(draw: Draw);
8
9
  private _setValue;
9
10
  getDateElementRange(): [number, number] | null;
@@ -1,3 +1,7 @@
1
1
  import { CanvasEvent } from '../CanvasEvent';
2
+ import { IElement } from '../../../interface/Element';
3
+ import { Draw } from '../../draw/Draw';
2
4
  export declare function setRangeCache(host: CanvasEvent): void;
5
+ export declare function hitCheckbox(element: IElement, draw: Draw): void;
6
+ export declare function hitRadio(element: IElement, draw: Draw): void;
3
7
  export declare function mousedown(evt: MouseEvent, host: CanvasEvent): void;
@@ -8,6 +8,7 @@ export declare class Position {
8
8
  private positionList;
9
9
  private floatPositionList;
10
10
  private draw;
11
+ private eventBus;
11
12
  private options;
12
13
  constructor(draw: Draw);
13
14
  getFloatPositionList(): IFloatPosition[];
@@ -0,0 +1,2 @@
1
+ import { IPageBorderOption } from '../../interface/PageBorder';
2
+ export declare const defaultPageBorderOption: Readonly<Required<IPageBorderOption>>;
@@ -17,7 +17,8 @@ export declare enum EditorMode {
17
17
  CLEAN = "clean",
18
18
  READONLY = "readonly",
19
19
  FORM = "form",
20
- PRINT = "print"
20
+ PRINT = "print",
21
+ DESIGN = "design"
21
22
  }
22
23
  export declare enum EditorZone {
23
24
  HEADER = "header",
@@ -70,6 +70,7 @@ export interface IControlOption {
70
70
  postfix?: string;
71
71
  borderWidth?: number;
72
72
  borderColor?: string;
73
+ activeBackgroundColor?: string;
73
74
  }
74
75
  export interface IControlInitOption {
75
76
  index: number;
@@ -122,7 +123,7 @@ export type ISetControlProperties = {
122
123
  conceptId?: string;
123
124
  properties: Partial<Omit<IControl, 'value'>>;
124
125
  };
125
- export type IRepaintControlOption = Pick<IDrawOption, 'curIndex' | 'isCompute' | 'isSubmitHistory'>;
126
+ export type IRepaintControlOption = Pick<IDrawOption, 'curIndex' | 'isCompute' | 'isSubmitHistory' | 'isSetCursor'>;
126
127
  export interface INextControlContext {
127
128
  positionContext: IPositionContext;
128
129
  nextIndex: number;
@@ -1,4 +1,4 @@
1
- import { IElement } from '..';
1
+ import { IElement, LocationPosition } from '..';
2
2
  import { EditorMode, PageMode, PaperDirection, RenderMode, WordBreak } from '../dataset/enum/Editor';
3
3
  import { IBackgroundOption } from './Background';
4
4
  import { ICheckboxOption } from './Checkbox';
@@ -19,6 +19,7 @@ import { IZoneOption } from './Zone';
19
19
  import { ISeparatorOption } from './Separator';
20
20
  import { ITableOption } from './table/Table';
21
21
  import { ILineNumberOption } from './LineNumber';
22
+ import { IPageBorderOption } from './PageBorder';
22
23
  export interface IEditorData {
23
24
  header?: IElement[];
24
25
  main: IElement[];
@@ -83,6 +84,7 @@ export interface IEditorOption {
83
84
  lineBreak?: ILineBreakOption;
84
85
  separator?: ISeparatorOption;
85
86
  lineNumber?: ILineNumberOption;
87
+ pageBorder?: IPageBorderOption;
86
88
  }
87
89
  export interface IEditorResult {
88
90
  version: string;
@@ -99,3 +101,6 @@ export type IUpdateOption = Omit<IEditorOption, 'mode' | 'width' | 'height' | 's
99
101
  export interface ISetValueOption {
100
102
  isSetCursor?: boolean;
101
103
  }
104
+ export interface IFocusOption {
105
+ position?: LocationPosition;
106
+ }
@@ -1,4 +1,4 @@
1
- import { IContentChange, IControlChange, IIntersectionPageNoChange, IMouseEventChange, IPageModeChange, IPageScaleChange, IPageSizeChange, IRangeStyleChange, ISaved, IVisiblePageNoListChange, IZoneChange } from './Listener';
1
+ import { IContentChange, IControlChange, IIntersectionPageNoChange, IMouseEventChange, IPageModeChange, IPageScaleChange, IPageSizeChange, IPositionContextChange, IRangeStyleChange, ISaved, IVisiblePageNoListChange, IZoneChange } from './Listener';
2
2
  export interface EventBusMap {
3
3
  rangeStyleChange: IRangeStyleChange;
4
4
  visiblePageNoListChange: IVisiblePageNoListChange;
@@ -13,4 +13,5 @@ export interface EventBusMap {
13
13
  mousemove: IMouseEventChange;
14
14
  mouseleave: IMouseEventChange;
15
15
  mouseenter: IMouseEventChange;
16
+ positionContextChange: IPositionContextChange;
16
17
  }
@@ -2,6 +2,7 @@ import { EditorZone, ElementType, ListStyle, ListType, PageMode, TitleLevel } fr
2
2
  import { RowFlex } from '../dataset/enum/Row';
3
3
  import { IControl } from './Control';
4
4
  import { IEditorResult } from './Editor';
5
+ import { IPositionContext } from './Position';
5
6
  import { ITextDecoration } from './Text';
6
7
  export interface IRangeStyle {
7
8
  type: ElementType | null;
@@ -37,3 +38,8 @@ export type IControlChange = (payload: IControl | null) => void;
37
38
  export type IPageModeChange = (payload: PageMode) => void;
38
39
  export type IZoneChange = (payload: EditorZone) => void;
39
40
  export type IMouseEventChange = (evt: MouseEvent) => void;
41
+ export interface IPositionContextChangePayload {
42
+ value: IPositionContext;
43
+ oldValue: IPositionContext;
44
+ }
45
+ export type IPositionContextChange = (payload: IPositionContextChangePayload) => void;
@@ -0,0 +1,7 @@
1
+ import { IPadding } from './Common';
2
+ export interface IPageBorderOption {
3
+ color?: string;
4
+ lineWidth?: number;
5
+ padding?: IPadding;
6
+ disabled?: boolean;
7
+ }
@@ -5,6 +5,8 @@ import { IRow } from '../Row';
5
5
  export interface ITd {
6
6
  conceptId?: string;
7
7
  id?: string;
8
+ extension?: unknown;
9
+ externalId?: string;
8
10
  x?: number;
9
11
  y?: number;
10
12
  width?: number;
@@ -28,4 +30,6 @@ export interface ITd {
28
30
  mainHeight?: number;
29
31
  realHeight?: number;
30
32
  realMinHeight?: number;
33
+ disabled?: boolean;
34
+ deletable?: boolean;
31
35
  }
@@ -1,6 +1,8 @@
1
1
  import { ITd } from './Td';
2
2
  export interface ITr {
3
3
  id?: string;
4
+ extension?: unknown;
5
+ externalId?: string;
4
6
  height: number;
5
7
  tdList: ITd[];
6
8
  minHeight?: number;
@@ -3,6 +3,7 @@ import { DeepRequired } from '../interface/Common';
3
3
  export declare function unzipElementList(elementList: IElement[]): IElement[];
4
4
  interface IFormatElementListOption {
5
5
  isHandleFirstElement?: boolean;
6
+ isForceCompensation?: boolean;
6
7
  editorOptions: DeepRequired<IEditorOption>;
7
8
  }
8
9
  export declare function formatElementList(elementList: IElement[], options: IFormatElementListOption): void;
@@ -21,7 +22,8 @@ export declare function convertRowFlexToJustifyContent(rowFlex: RowFlex): "cente
21
22
  export declare function isTextLikeElement(element: IElement): boolean;
22
23
  export declare function getAnchorElement(elementList: IElement[], anchorIndex: number): IElement | null;
23
24
  export interface IFormatElementContextOption {
24
- isBreakWhenWrap: boolean;
25
+ isBreakWhenWrap?: boolean;
26
+ editorOptions?: DeepRequired<IEditorOption>;
25
27
  }
26
28
  export declare function formatElementContext(sourceElementList: IElement[], formatElementList: IElement[], anchorIndex: number, options?: IFormatElementContextOption): void;
27
29
  export declare function convertElementToDom(element: IElement, options: DeepRequired<IEditorOption>): HTMLElement;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@hufe921/canvas-editor",
3
3
  "author": "Hufe",
4
4
  "license": "MIT",
5
- "version": "0.9.90",
5
+ "version": "0.9.92",
6
6
  "description": "rich text editor by canvas/svg",
7
7
  "publishConfig": {
8
8
  "registry": "https://registry.npmjs.org/",