@hufe921/canvas-editor 0.9.88 → 0.9.89

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.
@@ -11,6 +11,7 @@ import { Position } from '../position/Position';
11
11
  import { RangeManager } from '../range/RangeManager';
12
12
  import { Search } from './interactive/Search';
13
13
  import { ImageParticle } from './particle/ImageParticle';
14
+ import { TextParticle } from './particle/TextParticle';
14
15
  import { TableParticle } from './particle/table/TableParticle';
15
16
  import { TableTool } from './particle/table/TableTool';
16
17
  import { HyperlinkParticle } from './particle/HyperlinkParticle';
@@ -69,6 +70,7 @@ export declare class Draw {
69
70
  private tableParticle;
70
71
  private tableTool;
71
72
  private pageNumber;
73
+ private lineNumber;
72
74
  private waterMark;
73
75
  private placeholder;
74
76
  private header;
@@ -147,6 +149,7 @@ export declare class Draw {
147
149
  getZone(): Zone;
148
150
  getRange(): RangeManager;
149
151
  getLineBreakParticle(): LineBreakParticle;
152
+ getTextParticle(): TextParticle;
150
153
  getHeaderElementList(): IElement[];
151
154
  getTableElementList(sourceElementList: IElement[]): IElement[];
152
155
  getElementList(): IElement[];
@@ -26,7 +26,7 @@ export declare class Control {
26
26
  getIsRangeInPostfix(): boolean;
27
27
  getIsRangeWithinControl(): boolean;
28
28
  getIsElementListContainFullControl(elementList: IElement[]): boolean;
29
- getIsDisabledControl(): boolean;
29
+ getIsDisabledControl(context?: IControlContext): boolean;
30
30
  getContainer(): HTMLDivElement;
31
31
  getElementList(): IElement[];
32
32
  getPosition(): IElementPosition | null;
@@ -45,10 +45,10 @@ export declare class Control {
45
45
  setValue(data: IElement[]): number;
46
46
  keydown(evt: KeyboardEvent): number | null;
47
47
  cut(): number;
48
- getValueByConceptId(payload: IGetControlValueOption): IGetControlValueResult;
49
- setValueByConceptId(payload: ISetControlValueOption): void;
50
- setExtensionByConceptId(payload: ISetControlExtensionOption): void;
51
- setPropertiesByConceptId(payload: ISetControlProperties): void;
48
+ getValueById(payload: IGetControlValueOption): IGetControlValueResult;
49
+ setValueById(payload: ISetControlValueOption): void;
50
+ setExtensionById(payload: ISetControlExtensionOption): void;
51
+ setPropertiesById(payload: ISetControlProperties): void;
52
52
  getList(): IElement[];
53
53
  recordBorderInfo(x: number, y: number, width: number, height: number): void;
54
54
  drawBorder(ctx: CanvasRenderingContext2D): void;
@@ -0,0 +1,7 @@
1
+ import { Draw } from '../Draw';
2
+ export declare class LineNumber {
3
+ private draw;
4
+ private options;
5
+ constructor(draw: Draw);
6
+ render(ctx: CanvasRenderingContext2D, pageNo: number): void;
7
+ }
@@ -0,0 +1,2 @@
1
+ import { ILineNumberOption } from '../../interface/LineNumber';
2
+ export declare const defaultLineNumberOption: Readonly<Required<ILineNumberOption>>;
@@ -0,0 +1,4 @@
1
+ export declare enum LineNumberType {
2
+ PAGE = "page",
3
+ CONTINUITY = "continuity"
4
+ }
@@ -34,6 +34,7 @@ import { IRange } from './interface/Range';
34
34
  import { splitText } from './utils';
35
35
  import { BackgroundRepeat, BackgroundSize } from './dataset/enum/Background';
36
36
  import { TextDecorationStyle } from './dataset/enum/Text';
37
+ import { LineNumberType } from './dataset/enum/LineNumber';
37
38
  export default class Editor {
38
39
  command: Command;
39
40
  listener: Listener;
@@ -46,5 +47,5 @@ export default class Editor {
46
47
  }
47
48
  export { splitText };
48
49
  export { EDITOR_COMPONENT, LETTER_CLASS, INTERNAL_CONTEXT_MENU_KEY };
49
- export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, PageMode, RenderMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection, TableBorder, TdBorder, TdSlash, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle, WordBreak, ControlIndentation, BackgroundRepeat, BackgroundSize, TextDecorationStyle };
50
+ export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, PageMode, RenderMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection, TableBorder, TdBorder, TdSlash, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle, WordBreak, ControlIndentation, BackgroundRepeat, BackgroundSize, TextDecorationStyle, LineNumberType };
50
51
  export type { IElement, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang, ICatalog, ICatalogItem, IRange, IRangeStyle };
@@ -33,7 +33,8 @@ export interface IControlHighlightRule {
33
33
  }
34
34
  export interface IControlHighlight {
35
35
  ruleList: IControlHighlightRule[];
36
- conceptId: string;
36
+ id?: string;
37
+ conceptId?: string;
37
38
  }
38
39
  export interface IControlRule {
39
40
  deletable?: boolean;
@@ -96,7 +97,8 @@ export interface IControlRuleOption {
96
97
  isAddPlaceholder?: boolean;
97
98
  }
98
99
  export interface IGetControlValueOption {
99
- conceptId: string;
100
+ id?: string;
101
+ conceptId?: string;
100
102
  }
101
103
  export type IGetControlValueResult = (Omit<IControl, 'value'> & {
102
104
  value: string | null;
@@ -104,16 +106,19 @@ export type IGetControlValueResult = (Omit<IControl, 'value'> & {
104
106
  zone: EditorZone;
105
107
  })[];
106
108
  export interface ISetControlValueOption {
107
- conceptId: string;
109
+ id?: string;
110
+ conceptId?: string;
108
111
  value: string;
109
112
  }
110
113
  export interface ISetControlExtensionOption {
111
- conceptId: string;
114
+ id?: string;
115
+ conceptId?: string;
112
116
  extension: unknown;
113
117
  }
114
118
  export type ISetControlHighlightOption = IControlHighlight[];
115
119
  export type ISetControlProperties = {
116
- conceptId: string;
120
+ id?: string;
121
+ conceptId?: string;
117
122
  properties: Partial<Omit<IControl, 'value'>>;
118
123
  };
119
124
  export type IRepaintControlOption = Pick<IDrawOption, 'curIndex' | 'isCompute' | 'isSubmitHistory'>;
@@ -18,6 +18,7 @@ import { IWatermark } from './Watermark';
18
18
  import { IZoneOption } from './Zone';
19
19
  import { ISeparatorOption } from './Separator';
20
20
  import { ITableOption } from './table/Table';
21
+ import { ILineNumberOption } from './LineNumber';
21
22
  export interface IEditorData {
22
23
  header?: IElement[];
23
24
  main: IElement[];
@@ -81,6 +82,7 @@ export interface IEditorOption {
81
82
  background?: IBackgroundOption;
82
83
  lineBreak?: ILineBreakOption;
83
84
  separator?: ISeparatorOption;
85
+ lineNumber?: ILineNumberOption;
84
86
  }
85
87
  export interface IEditorResult {
86
88
  version: string;
@@ -139,5 +139,5 @@ export interface IElementFillRect {
139
139
  }
140
140
  export interface IUpdateElementByIdOption {
141
141
  id: string;
142
- properties: Omit<IElement, 'id'>;
142
+ properties: Omit<Partial<IElement>, 'id'>;
143
143
  }
@@ -0,0 +1,9 @@
1
+ import { LineNumberType } from '../dataset/enum/LineNumber';
2
+ export interface ILineNumberOption {
3
+ size?: number;
4
+ font?: string;
5
+ color?: string;
6
+ disabled?: boolean;
7
+ right?: number;
8
+ type?: LineNumberType;
9
+ }
@@ -17,4 +17,5 @@ export interface IRow {
17
17
  offsetX?: number;
18
18
  elementList: IRowElement[];
19
19
  isWidthNotEnough?: boolean;
20
+ rowIndex: number;
20
21
  }
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.88",
5
+ "version": "0.9.89",
6
6
  "description": "rich text editor by canvas/svg",
7
7
  "publishConfig": {
8
8
  "registry": "https://registry.npmjs.org/",