@hufe921/canvas-editor 0.9.94 → 0.9.96
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.
- package/CHANGELOG.md +57 -0
- package/README.md +53 -18
- package/dist/canvas-editor.es.js +314 -69
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +37 -37
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +2 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +4 -1
- package/dist/src/editor/core/cursor/Cursor.d.ts +1 -0
- package/dist/src/editor/core/draw/control/Control.d.ts +3 -1
- package/dist/src/editor/core/draw/particle/table/TableOperate.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/table/TableParticle.d.ts +1 -0
- package/dist/src/editor/core/draw/particle/table/TableTool.d.ts +2 -0
- package/dist/src/editor/core/range/RangeManager.d.ts +1 -0
- package/dist/src/editor/dataset/constant/ContextMenu.d.ts +2 -0
- package/dist/src/editor/dataset/enum/table/Table.d.ts +3 -1
- package/dist/src/editor/index.d.ts +5 -5
- package/dist/src/editor/interface/Control.d.ts +10 -0
- package/dist/src/editor/interface/Element.d.ts +6 -1
- package/dist/src/editor/interface/Search.d.ts +7 -0
- package/dist/src/editor/utils/element.d.ts +1 -1
- package/package.json +1 -1
|
@@ -108,6 +108,7 @@ export declare class Command {
|
|
|
108
108
|
getRangeRow: CommandAdapt['getRangeRow'];
|
|
109
109
|
getRangeParagraph: CommandAdapt['getRangeParagraph'];
|
|
110
110
|
getKeywordRangeList: CommandAdapt['getKeywordRangeList'];
|
|
111
|
+
getKeywordContext: CommandAdapt['getKeywordContext'];
|
|
111
112
|
getPaperMargin: CommandAdapt['getPaperMargin'];
|
|
112
113
|
getSearchNavigateInfo: CommandAdapt['getSearchNavigateInfo'];
|
|
113
114
|
getLocale: CommandAdapt['getLocale'];
|
|
@@ -117,5 +118,6 @@ export declare class Command {
|
|
|
117
118
|
getContainer: CommandAdapt['getContainer'];
|
|
118
119
|
getTitleValue: CommandAdapt['getTitleValue'];
|
|
119
120
|
getPositionContextByEvent: CommandAdapt['getPositionContextByEvent'];
|
|
121
|
+
getElementById: CommandAdapt['getElementById'];
|
|
120
122
|
constructor(adapt: CommandAdapt);
|
|
121
123
|
}
|
|
@@ -10,10 +10,11 @@ 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
12
|
import { IEditorData, IEditorHTML, IEditorOption, IEditorResult, IEditorText, IFocusOption, ISetValueOption, IUpdateOption } from '../../interface/Editor';
|
|
13
|
-
import { IElement, IElementPosition, IUpdateElementByIdOption } from '../../interface/Element';
|
|
13
|
+
import { IElement, IElementPosition, IGetElementByIdOption, IUpdateElementByIdOption } from '../../interface/Element';
|
|
14
14
|
import { IPasteOption, IPositionContextByEvent } from '../../interface/Event';
|
|
15
15
|
import { IMargin } from '../../interface/Margin';
|
|
16
16
|
import { IRange, RangeContext } from '../../interface/Range';
|
|
17
|
+
import { ISearchResultContext } from '../../interface/Search';
|
|
17
18
|
import { ITextDecoration } from '../../interface/Text';
|
|
18
19
|
import { IGetTitleValueOption, IGetTitleValueResult } from '../../interface/Title';
|
|
19
20
|
import { IWatermark } from '../../interface/Watermark';
|
|
@@ -113,6 +114,7 @@ export declare class CommandAdapt {
|
|
|
113
114
|
getRangeRow(): IElement[] | null;
|
|
114
115
|
getRangeParagraph(): IElement[] | null;
|
|
115
116
|
getKeywordRangeList(payload: string): IRange[];
|
|
117
|
+
getKeywordContext(payload: string): ISearchResultContext[] | null;
|
|
116
118
|
pageMode(payload: PageMode): void;
|
|
117
119
|
pageScaleRecovery(): void;
|
|
118
120
|
pageScaleMinus(): void;
|
|
@@ -124,6 +126,7 @@ export declare class CommandAdapt {
|
|
|
124
126
|
insertElementList(payload: IElement[]): void;
|
|
125
127
|
appendElementList(elementList: IElement[], options?: IAppendElementListOption): void;
|
|
126
128
|
updateElementById(payload: IUpdateElementByIdOption): void;
|
|
129
|
+
getElementById(payload: IGetElementByIdOption): IElement[];
|
|
127
130
|
setValue(payload: Partial<IEditorData>, options?: ISetValueOption): void;
|
|
128
131
|
removeControl(): void;
|
|
129
132
|
setLocale(payload: string): void;
|
|
@@ -32,6 +32,7 @@ export declare class Cursor {
|
|
|
32
32
|
private _blinkStop;
|
|
33
33
|
private _setBlinkTimeout;
|
|
34
34
|
private _clearBlinkTimeout;
|
|
35
|
+
focus(): void;
|
|
35
36
|
drawCursor(payload?: IDrawCursorOption): void;
|
|
36
37
|
recoveryCursor(): void;
|
|
37
38
|
moveCursorToVisible(payload: IMoveCursorToVisibleOption): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IControlContext, IControlHighlight, IControlInitOption, IControlInstance, IGetControlValueOption, IGetControlValueResult, IInitNextControlOption, INextControlContext, IRepaintControlOption, ISetControlExtensionOption, ISetControlProperties, ISetControlValueOption } from '../../../interface/Control';
|
|
1
|
+
import { IControlContext, IControlHighlight, IControlInitOption, IControlInstance, IGetControlValueOption, IGetControlValueResult, IInitNextControlOption, INextControlContext, IRepaintControlOption, ISetControlExtensionOption, ISetControlProperties, ISetControlRowFlexOption, ISetControlValueOption } from '../../../interface/Control';
|
|
2
2
|
import { IElement, IElementPosition } from '../../../interface/Element';
|
|
3
3
|
import { IRange } from '../../../interface/Range';
|
|
4
4
|
import { Draw } from '../Draw';
|
|
@@ -27,6 +27,7 @@ export declare class Control {
|
|
|
27
27
|
getIsRangeWithinControl(): boolean;
|
|
28
28
|
getIsElementListContainFullControl(elementList: IElement[]): boolean;
|
|
29
29
|
getIsDisabledControl(context?: IControlContext): boolean;
|
|
30
|
+
getIsDisabledPasteControl(context?: IControlContext): boolean;
|
|
30
31
|
getContainer(): HTMLDivElement;
|
|
31
32
|
getElementList(): IElement[];
|
|
32
33
|
getPosition(): IElementPosition | null;
|
|
@@ -55,5 +56,6 @@ export declare class Control {
|
|
|
55
56
|
getPreControlContext(): INextControlContext | null;
|
|
56
57
|
getNextControlContext(): INextControlContext | null;
|
|
57
58
|
initNextControl(option?: IInitNextControlOption): void;
|
|
59
|
+
setMinWidthControlInfo(option: ISetControlRowFlexOption): void;
|
|
58
60
|
}
|
|
59
61
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TableBorder, VerticalAlign } from '../../../..';
|
|
1
|
+
import { IElement, TableBorder, VerticalAlign } from '../../../..';
|
|
2
2
|
import { TdBorder, TdSlash } from '../../../../dataset/enum/table/Table';
|
|
3
3
|
import { Draw } from '../../Draw';
|
|
4
4
|
export declare class TableOperate {
|
|
@@ -12,6 +12,7 @@ export declare class TableOperate {
|
|
|
12
12
|
insertTable(row: number, col: number): void;
|
|
13
13
|
insertTableTopRow(): void;
|
|
14
14
|
insertTableBottomRow(): void;
|
|
15
|
+
adjustColWidth(element: IElement): void;
|
|
15
16
|
insertTableLeftCol(): void;
|
|
16
17
|
insertTableRightCol(): void;
|
|
17
18
|
deleteTableRow(): void;
|
|
@@ -17,6 +17,7 @@ export declare class TableParticle {
|
|
|
17
17
|
getTableHeight(element: IElement): number;
|
|
18
18
|
getRowCountByColIndex(trList: ITr[], colIndex: number): number;
|
|
19
19
|
getTdListByColIndex(trList: ITr[], colIndex: number): ITd[];
|
|
20
|
+
getTdListByRowIndex(trList: ITr[], rowIndex: number): ITd[];
|
|
20
21
|
computeRowColInfo(element: IElement): void;
|
|
21
22
|
drawRange(ctx: CanvasRenderingContext2D, element: IElement, startX: number, startY: number): void;
|
|
22
23
|
render(ctx: CanvasRenderingContext2D, element: IElement, startX: number, startY: number): void;
|
|
@@ -11,6 +11,7 @@ export declare class TableTool {
|
|
|
11
11
|
private canvas;
|
|
12
12
|
private options;
|
|
13
13
|
private position;
|
|
14
|
+
private range;
|
|
14
15
|
private container;
|
|
15
16
|
private toolRowContainer;
|
|
16
17
|
private toolRowAddBtn;
|
|
@@ -24,6 +25,7 @@ export declare class TableTool {
|
|
|
24
25
|
constructor(draw: Draw);
|
|
25
26
|
dispose(): void;
|
|
26
27
|
render(): void;
|
|
28
|
+
private _setAnchorActive;
|
|
27
29
|
private _mousedown;
|
|
28
30
|
private _mousemove;
|
|
29
31
|
}
|
|
@@ -14,6 +14,7 @@ export declare class RangeManager {
|
|
|
14
14
|
getRange(): IRange;
|
|
15
15
|
clearRange(): void;
|
|
16
16
|
getIsCollapsed(): boolean;
|
|
17
|
+
getIsSelection(): boolean;
|
|
17
18
|
getSelection(): IElement[] | null;
|
|
18
19
|
getSelectionElementList(): IElement[] | null;
|
|
19
20
|
getTextLikeSelection(): IElement[] | null;
|
|
@@ -31,7 +31,9 @@ export declare const INTERNAL_CONTEXT_MENU_KEY: {
|
|
|
31
31
|
BORDER: string;
|
|
32
32
|
BORDER_ALL: string;
|
|
33
33
|
BORDER_EMPTY: string;
|
|
34
|
+
BORDER_DASH: string;
|
|
34
35
|
BORDER_EXTERNAL: string;
|
|
36
|
+
BORDER_INTERNAL: string;
|
|
35
37
|
BORDER_TD: string;
|
|
36
38
|
BORDER_TD_TOP: string;
|
|
37
39
|
BORDER_TD_RIGHT: string;
|
|
@@ -9,7 +9,7 @@ import { ElementType } from './dataset/enum/Element';
|
|
|
9
9
|
import { Register } from './core/register/Register';
|
|
10
10
|
import { IContextMenuContext, IRegisterContextMenu } from './interface/contextmenu/ContextMenu';
|
|
11
11
|
import { EditorComponent, EditorZone, EditorMode, PageMode, PaperDirection, WordBreak, RenderMode } from './dataset/enum/Editor';
|
|
12
|
-
import { EDITOR_COMPONENT } from './dataset/constant/Editor';
|
|
12
|
+
import { EDITOR_CLIPBOARD, EDITOR_COMPONENT } from './dataset/constant/Editor';
|
|
13
13
|
import { IWatermark } from './interface/Watermark';
|
|
14
14
|
import { ControlIndentation, ControlType } from './dataset/enum/Control';
|
|
15
15
|
import { INavigateInfo } from './core/draw/interactive/Search';
|
|
@@ -32,7 +32,7 @@ import { LETTER_CLASS } from './dataset/constant/Common';
|
|
|
32
32
|
import { INTERNAL_CONTEXT_MENU_KEY } from './dataset/constant/ContextMenu';
|
|
33
33
|
import { IRange } from './interface/Range';
|
|
34
34
|
import { splitText } from './utils';
|
|
35
|
-
import { createDomFromElementList } from './utils/element';
|
|
35
|
+
import { createDomFromElementList, getElementListByHTML, getTextFromElementList, type IGetElementListByHTMLOption } from './utils/element';
|
|
36
36
|
import { BackgroundRepeat, BackgroundSize } from './dataset/enum/Background';
|
|
37
37
|
import { TextDecorationStyle } from './dataset/enum/Text';
|
|
38
38
|
import { LineNumberType } from './dataset/enum/LineNumber';
|
|
@@ -46,7 +46,7 @@ export default class Editor {
|
|
|
46
46
|
use: UsePlugin;
|
|
47
47
|
constructor(container: HTMLDivElement, data: IEditorData | IElement[], options?: IEditorOption);
|
|
48
48
|
}
|
|
49
|
-
export { splitText, createDomFromElementList };
|
|
50
|
-
export { EDITOR_COMPONENT, LETTER_CLASS, INTERNAL_CONTEXT_MENU_KEY };
|
|
51
|
-
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, LocationPosition };
|
|
49
|
+
export { splitText, createDomFromElementList, getElementListByHTML, getTextFromElementList };
|
|
50
|
+
export { EDITOR_COMPONENT, LETTER_CLASS, INTERNAL_CONTEXT_MENU_KEY, EDITOR_CLIPBOARD };
|
|
51
|
+
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, LocationPosition, IGetElementListByHTMLOption };
|
|
52
52
|
export type { IElement, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang, ICatalog, ICatalogItem, IRange, IRangeStyle };
|
|
@@ -2,10 +2,12 @@ import { LocationPosition } from '../dataset/enum/Common';
|
|
|
2
2
|
import { ControlType, ControlIndentation } from '../dataset/enum/Control';
|
|
3
3
|
import { EditorZone } from '../dataset/enum/Editor';
|
|
4
4
|
import { MoveDirection } from '../dataset/enum/Observer';
|
|
5
|
+
import { RowFlex } from '../dataset/enum/Row';
|
|
5
6
|
import { IDrawOption } from './Draw';
|
|
6
7
|
import { IElement } from './Element';
|
|
7
8
|
import { IPositionContext } from './Position';
|
|
8
9
|
import { IRange } from './Range';
|
|
10
|
+
import { IRow, IRowElement } from './Row';
|
|
9
11
|
export interface IValueSet {
|
|
10
12
|
value: string;
|
|
11
13
|
code: string;
|
|
@@ -40,6 +42,7 @@ export interface IControlHighlight {
|
|
|
40
42
|
export interface IControlRule {
|
|
41
43
|
deletable?: boolean;
|
|
42
44
|
disabled?: boolean;
|
|
45
|
+
pasteDisabled?: boolean;
|
|
43
46
|
}
|
|
44
47
|
export interface IControlBasic {
|
|
45
48
|
type: ControlType;
|
|
@@ -53,6 +56,7 @@ export interface IControlBasic {
|
|
|
53
56
|
border?: boolean;
|
|
54
57
|
extension?: unknown;
|
|
55
58
|
indentation?: ControlIndentation;
|
|
59
|
+
rowFlex?: RowFlex;
|
|
56
60
|
}
|
|
57
61
|
export interface IControlStyle {
|
|
58
62
|
font?: string;
|
|
@@ -135,3 +139,9 @@ export interface IInitNextControlOption {
|
|
|
135
139
|
export interface ILocationControlOption {
|
|
136
140
|
position: LocationPosition;
|
|
137
141
|
}
|
|
142
|
+
export interface ISetControlRowFlexOption {
|
|
143
|
+
row: IRow;
|
|
144
|
+
rowElement: IRowElement;
|
|
145
|
+
availableWidth: number;
|
|
146
|
+
controlRealWidth: number;
|
|
147
|
+
}
|
|
@@ -139,6 +139,11 @@ export interface IElementFillRect {
|
|
|
139
139
|
height: number;
|
|
140
140
|
}
|
|
141
141
|
export interface IUpdateElementByIdOption {
|
|
142
|
-
id
|
|
142
|
+
id?: string;
|
|
143
|
+
conceptId?: string;
|
|
143
144
|
properties: Omit<Partial<IElement>, 'id'>;
|
|
144
145
|
}
|
|
146
|
+
export interface IGetElementByIdOption {
|
|
147
|
+
id?: string;
|
|
148
|
+
conceptId?: string;
|
|
149
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { EditorContext } from '../dataset/enum/Editor';
|
|
2
|
+
import { IElementPosition } from './Element';
|
|
3
|
+
import { IRange } from './Range';
|
|
2
4
|
export interface ISearchResultBasic {
|
|
3
5
|
type: EditorContext;
|
|
4
6
|
index: number;
|
|
@@ -13,3 +15,8 @@ export interface ISearchResultRestArgs {
|
|
|
13
15
|
startIndex?: number;
|
|
14
16
|
}
|
|
15
17
|
export type ISearchResult = ISearchResultBasic & ISearchResultRestArgs;
|
|
18
|
+
export interface ISearchResultContext {
|
|
19
|
+
range: IRange;
|
|
20
|
+
startPosition: IElementPosition;
|
|
21
|
+
endPosition: IElementPosition;
|
|
22
|
+
}
|
|
@@ -35,7 +35,7 @@ export interface IElementListGroupRowFlex {
|
|
|
35
35
|
export declare function groupElementListByRowFlex(elementList: IElement[]): IElementListGroupRowFlex[];
|
|
36
36
|
export declare function createDomFromElementList(elementList: IElement[], options?: IEditorOption): HTMLDivElement;
|
|
37
37
|
export declare function convertTextNodeToElement(textNode: Element | Node): IElement | null;
|
|
38
|
-
interface IGetElementListByHTMLOption {
|
|
38
|
+
export interface IGetElementListByHTMLOption {
|
|
39
39
|
innerWidth: number;
|
|
40
40
|
}
|
|
41
41
|
export declare function getElementListByHTML(htmlText: string, options: IGetElementListByHTMLOption): IElement[];
|