@hufe921/canvas-editor 1.0.5 → 1.1.0
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 +61 -0
- package/README.md +9 -8
- package/dist/assets/catalog-ezAM0r6o.js.map +1 -0
- package/dist/assets/group-BZtj1M7o.js.map +1 -1
- package/dist/assets/value-DKLIEqC1.js.map +1 -0
- package/dist/assets/wordCount-xSvDqE7d.js.map +1 -0
- package/dist/canvas-editor.js +4786 -2873
- package/dist/canvas-editor.js.map +1 -1
- package/dist/canvas-editor.umd.cjs +42 -42
- package/dist/canvas-editor.umd.cjs.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +9 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +11 -2
- package/dist/src/editor/core/contextmenu/ContextMenu.d.ts +7 -0
- package/dist/src/editor/core/draw/Draw.d.ts +21 -10
- package/dist/src/editor/core/draw/column/ColumnManager.d.ts +2 -1
- package/dist/src/editor/core/draw/control/Control.d.ts +3 -2
- package/dist/src/editor/core/draw/control/interactive/ControlSearch.d.ts +2 -1
- package/dist/src/editor/core/draw/control/richtext/Border.d.ts +2 -1
- package/dist/src/editor/core/draw/frame/Background.d.ts +2 -1
- package/dist/src/editor/core/draw/frame/Badge.d.ts +3 -1
- package/dist/src/editor/core/draw/frame/Footer.d.ts +2 -1
- package/dist/src/editor/core/draw/frame/Header.d.ts +2 -1
- package/dist/src/editor/core/draw/frame/LineNumber.d.ts +2 -1
- package/dist/src/editor/core/draw/frame/Margin.d.ts +2 -1
- package/dist/src/editor/core/draw/frame/PageBorder.d.ts +2 -1
- package/dist/src/editor/core/draw/frame/PageNumber.d.ts +2 -1
- package/dist/src/editor/core/draw/frame/Placeholder.d.ts +2 -1
- package/dist/src/editor/core/draw/frame/Watermark.d.ts +4 -3
- package/dist/src/editor/core/draw/graffiti/Graffiti.d.ts +2 -1
- package/dist/src/editor/core/draw/interactive/Area.d.ts +14 -1
- package/dist/src/editor/core/draw/interactive/AreaTool.d.ts +18 -0
- package/dist/src/editor/core/draw/interactive/Group.d.ts +2 -1
- package/dist/src/editor/core/draw/interactive/Search.d.ts +2 -1
- package/dist/src/editor/core/draw/interactive/Spellcheck.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/CheckboxParticle.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/HyperlinkParticle.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/ImageParticle.d.ts +3 -1
- package/dist/src/editor/core/draw/particle/LabelParticle.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/LineBreakParticle.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/ListParticle.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/PageBreakParticle.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/RadioParticle.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/SeparatorParticle.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/SubscriptParticle.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/SuperscriptParticle.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/TextParticle.d.ts +8 -2
- package/dist/src/editor/core/draw/particle/TraceParticle.d.ts +3 -2
- package/dist/src/editor/core/draw/particle/WhiteSpaceParticle.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/block/BlockParticle.d.ts +3 -1
- package/dist/src/editor/core/draw/particle/block/modules/BaseBlock.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/block/modules/VideoBlock.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/date/DatePicker.d.ts +1 -0
- package/dist/src/editor/core/draw/particle/latex/LaTexParticle.d.ts +6 -1
- package/dist/src/editor/core/draw/particle/table/TableOperate.d.ts +2 -0
- package/dist/src/editor/core/draw/particle/table/TableParticle.d.ts +3 -2
- package/dist/src/editor/core/draw/richtext/AbstractRichText.d.ts +3 -2
- package/dist/src/editor/core/draw/richtext/Highlight.d.ts +2 -1
- package/dist/src/editor/core/draw/richtext/Strikeout.d.ts +2 -1
- package/dist/src/editor/core/draw/richtext/Underline.d.ts +2 -1
- package/dist/src/editor/core/draw/ruler/Ruler.d.ts +31 -2
- package/dist/src/editor/core/event/GlobalEvent.d.ts +1 -0
- package/dist/src/editor/core/event/pagePointer.d.ts +8 -0
- package/dist/src/editor/core/layout/LayoutEngine.d.ts +31 -0
- package/dist/src/editor/core/layout/TextMeasurer.d.ts +10 -0
- package/dist/src/editor/core/range/RangeManager.d.ts +2 -1
- package/dist/src/editor/core/render/BackendFactory.d.ts +3 -0
- package/dist/src/editor/core/render/RenderBackend.d.ts +24 -0
- package/dist/src/editor/core/render/canvas/CanvasBackend.d.ts +19 -0
- package/dist/src/editor/core/render/canvas/CanvasRenderer.d.ts +5 -0
- package/dist/src/editor/core/render/canvas/CanvasSurface.d.ts +17 -0
- package/dist/src/editor/core/render/model/DisplayList.d.ts +62 -0
- package/dist/src/editor/core/render/model/RenderContext.d.ts +48 -0
- package/dist/src/editor/core/render/svg/SvgBackend.d.ts +22 -0
- package/dist/src/editor/core/render/svg/SvgRenderer.d.ts +9 -0
- package/dist/src/editor/core/render/svg/SvgSurface.d.ts +13 -0
- package/dist/src/editor/core/render/svg/scene/PathCompiler.d.ts +16 -0
- package/dist/src/editor/core/render/svg/scene/ResourceKey.d.ts +7 -0
- package/dist/src/editor/core/render/svg/scene/SceneCompiler.d.ts +9 -0
- package/dist/src/editor/core/render/svg/scene/SceneKey.d.ts +28 -0
- package/dist/src/editor/core/render/svg/scene/SceneNode.d.ts +20 -0
- package/dist/src/editor/core/render/svg/scene/SceneReconciler.d.ts +12 -0
- package/dist/src/editor/core/render/svg/scene/SvgNodeFactory.d.ts +14 -0
- package/dist/src/editor/dataset/constant/Common.d.ts +1 -0
- package/dist/src/editor/dataset/enum/Common.d.ts +4 -0
- package/dist/src/editor/dataset/enum/Editor.d.ts +4 -0
- package/dist/src/editor/dataset/enum/TabStop.d.ts +11 -0
- package/dist/src/editor/index.d.ts +6 -5
- package/dist/src/editor/interface/Area.d.ts +8 -0
- package/dist/src/editor/interface/Checkbox.d.ts +3 -0
- package/dist/src/editor/interface/Control.d.ts +2 -1
- package/dist/src/editor/interface/Draw.d.ts +4 -0
- package/dist/src/editor/interface/Editor.d.ts +6 -0
- package/dist/src/editor/interface/Element.d.ts +12 -0
- package/dist/src/editor/interface/Listener.d.ts +7 -1
- package/dist/src/editor/interface/Row.d.ts +12 -0
- package/dist/src/editor/interface/table/Td.d.ts +2 -0
- package/dist/src/editor/utils/element.d.ts +1 -0
- package/dist/src/editor/utils/print.d.ts +1 -0
- package/package.json +14 -13
- package/dist/assets/catalog-B-cbxN0s.js.map +0 -1
- package/dist/assets/value-CLcLo2uw.js.map +0 -1
- package/dist/assets/wordCount-BWZRHbSB.js.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DisplayList } from '../model/DisplayList';
|
|
2
|
+
import type { IPageResizeOption, IRenderBackend } from '../RenderBackend';
|
|
3
|
+
export declare class SvgBackend implements IRenderBackend {
|
|
4
|
+
readonly canvas: null;
|
|
5
|
+
private surface;
|
|
6
|
+
private renderer;
|
|
7
|
+
private pageList;
|
|
8
|
+
private renderedPages;
|
|
9
|
+
private pendingPages;
|
|
10
|
+
private frameId;
|
|
11
|
+
constructor(pageContainer: HTMLElement);
|
|
12
|
+
create(pageNo: number, width: number, height: number, gap: number, dpr: number): void;
|
|
13
|
+
resize(pageNo: number, width: number, height: number, dpr: number, options?: IPageResizeOption): void;
|
|
14
|
+
resizeHeight(pageNo: number, height: number, dpr: number): void;
|
|
15
|
+
renderPage(pageNo: number, displayList: DisplayList): void;
|
|
16
|
+
flush(): void;
|
|
17
|
+
observeVisibility(callback: (pageNo: number) => void): void;
|
|
18
|
+
disconnectVisibility(): void;
|
|
19
|
+
getPage(pageNo: number): SVGSVGElement;
|
|
20
|
+
getPageList(): SVGSVGElement[];
|
|
21
|
+
destroy(): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DisplayList } from '../model/DisplayList';
|
|
2
|
+
export declare class SvgRenderer {
|
|
3
|
+
private compiler;
|
|
4
|
+
private reconciler;
|
|
5
|
+
private resourceScopes;
|
|
6
|
+
constructor();
|
|
7
|
+
render(host: SVGSVGElement, displayList: DisplayList): void;
|
|
8
|
+
private _getResourceScope;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IPageResizeOption } from '../RenderBackend';
|
|
2
|
+
export declare class SvgSurface {
|
|
3
|
+
private pageContainer;
|
|
4
|
+
private visibilityObserver;
|
|
5
|
+
constructor(pageContainer: HTMLElement);
|
|
6
|
+
create(pageNo: number, width: number, height: number, gap: number): {
|
|
7
|
+
page: SVGSVGElement;
|
|
8
|
+
};
|
|
9
|
+
resize(page: SVGSVGElement, width: number, height: number, options?: IPageResizeOption): void;
|
|
10
|
+
resizeHeight(page: SVGSVGElement, height: number): void;
|
|
11
|
+
observeVisibility(pageList: Element[], callback: (pageNo: number) => void): void;
|
|
12
|
+
disconnectVisibility(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class PathCompiler {
|
|
2
|
+
private commands;
|
|
3
|
+
private currentPoint;
|
|
4
|
+
private subpathStart;
|
|
5
|
+
moveTo(x: number, y: number): void;
|
|
6
|
+
lineTo(x: number, y: number): void;
|
|
7
|
+
rect(x: number, y: number, width: number, height: number): void;
|
|
8
|
+
closePath(): void;
|
|
9
|
+
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
|
|
10
|
+
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
|
|
11
|
+
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
|
|
12
|
+
getPathData(): string;
|
|
13
|
+
private _connectTo;
|
|
14
|
+
private _arcTo;
|
|
15
|
+
private _number;
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IRenderPattern } from '../../model/RenderContext';
|
|
2
|
+
export declare function buildPatternResourceKey(pattern: IRenderPattern): string;
|
|
3
|
+
export declare function createResourceId(kind: string, resourceKey: string, scope?: string): string;
|
|
4
|
+
export declare function getImageSize(image: CanvasImageSource): {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DisplayList } from '../../model/DisplayList';
|
|
2
|
+
import type { SceneNode } from './SceneNode';
|
|
3
|
+
export declare class SceneCompiler {
|
|
4
|
+
compile(displayList: DisplayList, resourceScope?: string): SceneNode;
|
|
5
|
+
private _createInitialState;
|
|
6
|
+
private _isRenderPattern;
|
|
7
|
+
private _multiplyMatrix;
|
|
8
|
+
private _serializeMatrix;
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { EditorZone } from '../../../../dataset/enum/Editor';
|
|
2
|
+
export interface IRowKeyPayload {
|
|
3
|
+
zoneKey: string;
|
|
4
|
+
containerKey: string;
|
|
5
|
+
occurrence: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ITableFragmentKeyPayload {
|
|
8
|
+
containerKey: string;
|
|
9
|
+
tableId?: string;
|
|
10
|
+
tablePath: string[];
|
|
11
|
+
startTrIndex: number;
|
|
12
|
+
endTrIndex: number;
|
|
13
|
+
startSplitTrOffset?: number;
|
|
14
|
+
endSplitTrHeight?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface IRepeatHeaderKeyPayload {
|
|
17
|
+
fragmentKey: string;
|
|
18
|
+
trIndex: number;
|
|
19
|
+
tdIndex: number;
|
|
20
|
+
tdId?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function buildSourceTextKey(sourceKeyId: number): string;
|
|
23
|
+
export declare function buildPageKey(pageNo: number): string;
|
|
24
|
+
export declare function buildLayerKey(pageNo: number, layer: string): string;
|
|
25
|
+
export declare function buildZoneKey(zone: EditorZone, pageNo: number): string;
|
|
26
|
+
export declare function buildRowKey(payload: IRowKeyPayload): string;
|
|
27
|
+
export declare function buildTableFragmentKey(payload: ITableFragmentKeyPayload): string;
|
|
28
|
+
export declare function buildRepeatHeaderKey(payload: IRepeatHeaderKeyPayload): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type SceneGroupKind = 'page' | 'layer' | 'group' | 'row' | 'table-fragment' | 'repeat-header';
|
|
2
|
+
export type SceneNodeKind = SceneGroupKind | 'text' | 'path' | 'rect' | 'image';
|
|
3
|
+
export interface ISceneResourceIdentity {
|
|
4
|
+
key: string;
|
|
5
|
+
revision?: string | number;
|
|
6
|
+
}
|
|
7
|
+
export interface SceneDefinition {
|
|
8
|
+
key: string;
|
|
9
|
+
kind: 'clipPath' | 'pattern';
|
|
10
|
+
attributes: Record<string, unknown>;
|
|
11
|
+
children: SceneNode[];
|
|
12
|
+
cacheKey?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SceneNode {
|
|
15
|
+
key: string;
|
|
16
|
+
kind: SceneNodeKind;
|
|
17
|
+
attributes: Record<string, unknown>;
|
|
18
|
+
children: SceneNode[];
|
|
19
|
+
defs?: SceneDefinition[];
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SceneNode } from './SceneNode';
|
|
2
|
+
export declare class SceneReconciler {
|
|
3
|
+
private readonly factory;
|
|
4
|
+
private readonly elements;
|
|
5
|
+
private readonly rootScenes;
|
|
6
|
+
private readonly definitionElements;
|
|
7
|
+
reconcile(host: SVGElement, scene: SceneNode, previous?: SceneNode | undefined): SVGElement;
|
|
8
|
+
private _mount;
|
|
9
|
+
private _patch;
|
|
10
|
+
private _reconcileDefinitions;
|
|
11
|
+
private _reconcileChildren;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SceneDefinition, SceneNode } from './SceneNode';
|
|
2
|
+
export declare const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
3
|
+
type SceneElement = SceneNode | SceneDefinition;
|
|
4
|
+
export declare class SvgNodeFactory {
|
|
5
|
+
private readonly patternHrefs;
|
|
6
|
+
create(node: SceneElement): SVGElement;
|
|
7
|
+
patch(element: SVGElement, previous: SceneElement | null, next: SceneElement): void;
|
|
8
|
+
getChildren(node: SceneElement): SceneNode[];
|
|
9
|
+
private _patchPatternImage;
|
|
10
|
+
private _getAttributes;
|
|
11
|
+
private _getPatternImageHref;
|
|
12
|
+
private _getImageHref;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -5,6 +5,7 @@ export declare const HORIZON_TAB = "\t";
|
|
|
5
5
|
export declare const NBSP = " ";
|
|
6
6
|
export declare const NON_BREAKING_SPACE = " ";
|
|
7
7
|
export declare const PUNCTUATION_LIST: string[];
|
|
8
|
+
export declare const HANG_PUNCTUATION_LIST: string[];
|
|
8
9
|
export declare const maxHeightRadioMapping: Record<MaxHeightRatio, number>;
|
|
9
10
|
export declare const LETTER_CLASS: {
|
|
10
11
|
ENGLISH: string;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import './assets/css/index.css';
|
|
2
2
|
import { IEditorData, IEditorOption, IEditorResult } from './interface/Editor';
|
|
3
|
-
import { IElement } from './interface/Element';
|
|
3
|
+
import { IElement, ITabStop } from './interface/Element';
|
|
4
4
|
import { Command } from './core/command/Command';
|
|
5
5
|
import { Listener } from './core/listener/Listener';
|
|
6
6
|
import { RowFlex } from './dataset/enum/Row';
|
|
7
|
-
import { FlexDirection, ImageDisplay, LocationPosition, SurroundPosition } from './dataset/enum/Common';
|
|
7
|
+
import { FlexDirection, CheckboxMarkType, ImageDisplay, LocationPosition, SurroundPosition } from './dataset/enum/Common';
|
|
8
8
|
import { ElementType } from './dataset/enum/Element';
|
|
9
9
|
import { Register } from './core/register/Register';
|
|
10
10
|
import { IContextMenuContext, IRegisterContextMenu } from './interface/contextmenu/ContextMenu';
|
|
11
|
-
import { EditorComponent, EditorZone, EditorMode, PageMode, PaperDirection, WordBreak, RenderMode } from './dataset/enum/Editor';
|
|
11
|
+
import { BackendType, EditorComponent, EditorZone, EditorMode, PageMode, PaperDirection, WordBreak, RenderMode } from './dataset/enum/Editor';
|
|
12
12
|
import { EDITOR_CLIPBOARD, EDITOR_COMPONENT } from './dataset/constant/Editor';
|
|
13
13
|
import { IWatermark } from './interface/Watermark';
|
|
14
14
|
import { ControlComponent, ControlIndentation, ControlState, ControlType } from './dataset/enum/Control';
|
|
@@ -23,6 +23,7 @@ import { TableBorder, TdBorder, TdSlash } from './dataset/enum/table/Table';
|
|
|
23
23
|
import { MaxHeightRatio, NumberType } from './dataset/enum/Common';
|
|
24
24
|
import { TitleLevel } from './dataset/enum/Title';
|
|
25
25
|
import { ListStyle, ListType } from './dataset/enum/List';
|
|
26
|
+
import { TabStopLeader, TabStopType } from './dataset/enum/TabStop';
|
|
26
27
|
import { ICatalog, ICatalogItem } from './interface/Catalog';
|
|
27
28
|
import { UsePlugin } from './interface/Plugin';
|
|
28
29
|
import { MacroManager } from './core/macro/MacroManager';
|
|
@@ -56,5 +57,5 @@ export default class Editor {
|
|
|
56
57
|
}
|
|
57
58
|
export { splitText, createDomFromElementList, getElementListByHTML, getTextFromElementList };
|
|
58
59
|
export { EDITOR_COMPONENT, LETTER_CLASS, INTERNAL_CONTEXT_MENU_KEY, INTERNAL_SHORTCUT_KEY, EDITOR_CLIPBOARD };
|
|
59
|
-
export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, PageMode, RenderMode, ImageDisplay, Command, KeyMap, BlockType, MacroType, PaperDirection, TableBorder, TdBorder, TdSlash, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle, WordBreak, ControlIndentation, ControlComponent, BackgroundRepeat, BackgroundSize, TextDecorationStyle, LineNumberType, LocationPosition, SurroundPosition, AreaMode, ControlState, FlexDirection, WatermarkType, WatermarkLayer };
|
|
60
|
-
export type { IElement, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang, ICatalog, ICatalogItem, IRange, IRangeStyle, RangeRect, IBadge, IGetElementListByHTMLOption };
|
|
60
|
+
export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, PageMode, RenderMode, BackendType, ImageDisplay, Command, KeyMap, BlockType, MacroType, PaperDirection, TableBorder, TdBorder, TdSlash, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle, TabStopType, TabStopLeader, WordBreak, ControlIndentation, ControlComponent, BackgroundRepeat, BackgroundSize, TextDecorationStyle, LineNumberType, LocationPosition, SurroundPosition, AreaMode, ControlState, FlexDirection, CheckboxMarkType, WatermarkType, WatermarkLayer };
|
|
61
|
+
export type { IElement, ITabStop, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang, ICatalog, ICatalogItem, IRange, IRangeStyle, RangeRect, IBadge, IGetElementListByHTMLOption };
|
|
@@ -10,6 +10,7 @@ export interface IAreaBasic {
|
|
|
10
10
|
}
|
|
11
11
|
export interface IAreaStyle {
|
|
12
12
|
top?: number;
|
|
13
|
+
minHeight?: number;
|
|
13
14
|
borderColor?: string;
|
|
14
15
|
backgroundColor?: string;
|
|
15
16
|
}
|
|
@@ -17,6 +18,7 @@ export interface IAreaRule {
|
|
|
17
18
|
mode?: AreaMode;
|
|
18
19
|
hide?: boolean;
|
|
19
20
|
deletable?: boolean;
|
|
21
|
+
resizable?: boolean;
|
|
20
22
|
}
|
|
21
23
|
export type IArea = IAreaBasic & IAreaStyle & IAreaRule;
|
|
22
24
|
export interface IInsertAreaOption {
|
|
@@ -44,6 +46,11 @@ export interface IGetAreaValueResult {
|
|
|
44
46
|
endPageNo: number;
|
|
45
47
|
value: IElement[];
|
|
46
48
|
}
|
|
49
|
+
export interface IAreaPaddingSegment {
|
|
50
|
+
pageNo: number;
|
|
51
|
+
y: number;
|
|
52
|
+
height: number;
|
|
53
|
+
}
|
|
47
54
|
export interface IAreaInfo {
|
|
48
55
|
id: string;
|
|
49
56
|
area: IArea;
|
|
@@ -54,6 +61,7 @@ export interface IAreaInfo {
|
|
|
54
61
|
td: ITd;
|
|
55
62
|
tablePosition: IElementPosition;
|
|
56
63
|
};
|
|
64
|
+
paddingSegmentList?: IAreaPaddingSegment[];
|
|
57
65
|
}
|
|
58
66
|
export interface ILocationAreaOption {
|
|
59
67
|
position: LocationPosition;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { CheckboxMarkType } from '../dataset/enum/Common';
|
|
1
2
|
import { VerticalAlign } from '../dataset/enum/VerticalAlign';
|
|
2
3
|
export interface ICheckbox {
|
|
3
4
|
value: boolean | null;
|
|
4
5
|
code?: string;
|
|
5
6
|
disabled?: boolean;
|
|
7
|
+
markType?: CheckboxMarkType;
|
|
6
8
|
}
|
|
7
9
|
export interface ICheckboxOption {
|
|
8
10
|
width?: number;
|
|
@@ -14,5 +16,6 @@ export interface ICheckboxOption {
|
|
|
14
16
|
checkFillStyle?: string;
|
|
15
17
|
checkStrokeStyle?: string;
|
|
16
18
|
checkMarkColor?: string;
|
|
19
|
+
markType?: CheckboxMarkType;
|
|
17
20
|
verticalAlign?: VerticalAlign;
|
|
18
21
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FlexDirection, LocationPosition } from '../dataset/enum/Common';
|
|
1
|
+
import { CheckboxMarkType, FlexDirection, LocationPosition } from '../dataset/enum/Common';
|
|
2
2
|
import { ControlType, ControlIndentation, ControlState } from '../dataset/enum/Control';
|
|
3
3
|
import { EditorZone } from '../dataset/enum/Editor';
|
|
4
4
|
import { MoveDirection } from '../dataset/enum/Observer';
|
|
@@ -27,6 +27,7 @@ export interface IControlCheckbox {
|
|
|
27
27
|
max?: number;
|
|
28
28
|
flexDirection: FlexDirection;
|
|
29
29
|
valueSets: IValueSet[];
|
|
30
|
+
markType?: CheckboxMarkType;
|
|
30
31
|
}
|
|
31
32
|
export interface IControlRadio {
|
|
32
33
|
code: string | null;
|
|
@@ -36,6 +36,10 @@ export interface IDrawRowPayload {
|
|
|
36
36
|
startIndex: number;
|
|
37
37
|
innerWidth: number;
|
|
38
38
|
zone?: EditorZone;
|
|
39
|
+
keyContext?: {
|
|
40
|
+
containerKey?: string;
|
|
41
|
+
tablePath?: string[];
|
|
42
|
+
};
|
|
39
43
|
isDrawLineBreak?: boolean;
|
|
40
44
|
isDrawWhiteSpace?: boolean;
|
|
41
45
|
isDrawRange?: boolean;
|
|
@@ -34,11 +34,14 @@ import { ITraceOption } from './Trace';
|
|
|
34
34
|
import { IRulerOption } from './Ruler';
|
|
35
35
|
import { IHintOption } from './Hint';
|
|
36
36
|
import type { ISpellcheckOption } from './Spellcheck';
|
|
37
|
+
import { BackendType } from '../dataset/enum/Editor';
|
|
37
38
|
export interface ILabOption {
|
|
38
39
|
/**
|
|
39
40
|
* 行级增量行计算:编辑时仅从受影响行断点续算,区间外行复用。
|
|
40
41
|
* 复杂结构(表格/控件/浮动图/分栏/minWidth 控件占位等)自动退化全量。
|
|
41
42
|
* 默认:false
|
|
43
|
+
* @deprecated 自 1.1.0 起不再生效,请使用
|
|
44
|
+
* IEditorOption.incrementalCompute,后续版本移除。
|
|
42
45
|
*/
|
|
43
46
|
incrementalCompute?: boolean;
|
|
44
47
|
}
|
|
@@ -82,6 +85,7 @@ export interface IEditorOption {
|
|
|
82
85
|
margins?: IMargin;
|
|
83
86
|
pageMode?: PageMode;
|
|
84
87
|
renderMode?: RenderMode;
|
|
88
|
+
backend?: BackendType;
|
|
85
89
|
defaultHyperlinkColor?: string;
|
|
86
90
|
paperDirection?: PaperDirection;
|
|
87
91
|
inactiveAlpha?: number;
|
|
@@ -94,6 +98,8 @@ export interface IEditorOption {
|
|
|
94
98
|
scrollContainerSelector?: string;
|
|
95
99
|
pageOuterSelectionDisable?: boolean;
|
|
96
100
|
wordBreak?: WordBreak;
|
|
101
|
+
hangPunctuation?: boolean;
|
|
102
|
+
incrementalCompute?: boolean;
|
|
97
103
|
lab?: ILabOption;
|
|
98
104
|
table?: ITableOption;
|
|
99
105
|
header?: IHeader;
|
|
@@ -5,6 +5,7 @@ import { ElementType } from '../dataset/enum/Element';
|
|
|
5
5
|
import { TraceType } from '../dataset/enum/Trace';
|
|
6
6
|
import { ListStyle, ListType } from '../dataset/enum/List';
|
|
7
7
|
import { RowFlex } from '../dataset/enum/Row';
|
|
8
|
+
import { TabStopLeader, TabStopType } from '../dataset/enum/TabStop';
|
|
8
9
|
import { TitleLevel } from '../dataset/enum/Title';
|
|
9
10
|
import { TableBorder } from '../dataset/enum/table/Table';
|
|
10
11
|
import { IArea } from './Area';
|
|
@@ -39,11 +40,22 @@ export interface IElementStyle {
|
|
|
39
40
|
strikeout?: boolean;
|
|
40
41
|
rowFlex?: RowFlex;
|
|
41
42
|
rowMargin?: number;
|
|
43
|
+
spacingBefore?: number;
|
|
44
|
+
spacingAfter?: number;
|
|
45
|
+
indentLeft?: number;
|
|
46
|
+
indentRight?: number;
|
|
47
|
+
indentFirstLine?: number;
|
|
48
|
+
tabStops?: ITabStop[];
|
|
42
49
|
level?: TitleLevel;
|
|
43
50
|
title?: ITitle;
|
|
44
51
|
letterSpacing?: number;
|
|
45
52
|
textDecoration?: ITextDecoration;
|
|
46
53
|
}
|
|
54
|
+
export interface ITabStop {
|
|
55
|
+
position: number;
|
|
56
|
+
type: TabStopType;
|
|
57
|
+
leader?: TabStopLeader;
|
|
58
|
+
}
|
|
47
59
|
export interface IElementRule {
|
|
48
60
|
hide?: boolean;
|
|
49
61
|
}
|
|
@@ -5,7 +5,7 @@ import { RowFlex } from '../dataset/enum/Row';
|
|
|
5
5
|
import { TitleLevel } from '../dataset/enum/Title';
|
|
6
6
|
import { IControlChangeResult, IControlContentChangeResult } from './Control';
|
|
7
7
|
import { IEditorResult } from './Editor';
|
|
8
|
-
import { IElement } from './Element';
|
|
8
|
+
import { IElement, ITabStop } from './Element';
|
|
9
9
|
import { IPositionContext } from './Position';
|
|
10
10
|
import { IRange } from './Range';
|
|
11
11
|
import { ITextDecoration } from './Text';
|
|
@@ -24,6 +24,12 @@ export interface IRangeStyle {
|
|
|
24
24
|
highlight: string | null;
|
|
25
25
|
rowFlex: RowFlex | null;
|
|
26
26
|
rowMargin: number;
|
|
27
|
+
spacingBefore: number;
|
|
28
|
+
spacingAfter: number;
|
|
29
|
+
indentLeft: number;
|
|
30
|
+
indentRight: number;
|
|
31
|
+
indentFirstLine: number;
|
|
32
|
+
tabStops: ITabStop[] | null;
|
|
27
33
|
dashArray: number[];
|
|
28
34
|
level: TitleLevel | null;
|
|
29
35
|
listType: ListType | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PaperDirection } from '../dataset/enum/Editor';
|
|
2
2
|
import { RowFlex } from '../dataset/enum/Row';
|
|
3
|
+
import { TabStopLeader } from '../dataset/enum/TabStop';
|
|
3
4
|
import { IElement, IElementMetrics, IElementPosition, ITableRowFragment } from './Element';
|
|
4
5
|
import { IMargin } from './Margin';
|
|
5
6
|
import { ITd } from './table/Td';
|
|
@@ -7,6 +8,8 @@ export type IRowElement = IElement & {
|
|
|
7
8
|
metrics: IElementMetrics;
|
|
8
9
|
style: string;
|
|
9
10
|
left?: number;
|
|
11
|
+
tabLeader?: TabStopLeader;
|
|
12
|
+
hang?: boolean;
|
|
10
13
|
};
|
|
11
14
|
export interface IRow {
|
|
12
15
|
width: number;
|
|
@@ -20,6 +23,15 @@ export interface IRow {
|
|
|
20
23
|
listIndex?: number;
|
|
21
24
|
offsetX?: number;
|
|
22
25
|
offsetY?: number;
|
|
26
|
+
spacingAfter?: number;
|
|
27
|
+
areaPadding?: {
|
|
28
|
+
areaId: string;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
31
|
+
areaPaddingCarry?: {
|
|
32
|
+
areaId: string;
|
|
33
|
+
height: number;
|
|
34
|
+
};
|
|
23
35
|
elementList: IRowElement[];
|
|
24
36
|
isWidthNotEnough?: boolean;
|
|
25
37
|
rowIndex: number;
|
|
@@ -73,4 +73,5 @@ export declare function scanToOwner(elementList: IElement[], index: number, dire
|
|
|
73
73
|
*/
|
|
74
74
|
export declare function getOutermostOwner(elementList: IElement[], index: number): string | null;
|
|
75
75
|
export declare function visitElementTree(elementList: IElement[], visitor: (element: IElement) => void): void;
|
|
76
|
+
export declare function getFirstLineIndentElement(elementList: IElement[], zeroIndex: number): IElement | undefined;
|
|
76
77
|
export {};
|
|
@@ -8,4 +8,5 @@ interface IPrintOption {
|
|
|
8
8
|
iframeInfoList?: IIframeInfo[][];
|
|
9
9
|
}
|
|
10
10
|
export declare function print(base64List: string[], options: IPrintOption): Promise<void>;
|
|
11
|
+
export declare function printSvg(pageList: SVGSVGElement[], options: IPrintOption): Promise<void>;
|
|
11
12
|
export {};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@hufe921/canvas-editor",
|
|
3
3
|
"author": "Hufe",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.0
|
|
5
|
+
"version": "1.1.0",
|
|
6
6
|
"description": "A Canvas/SVG-based rich text editor",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -45,32 +45,33 @@
|
|
|
45
45
|
"docs:dev": "vitepress dev docs",
|
|
46
46
|
"docs:build": "vitepress build docs",
|
|
47
47
|
"docs:preview": "vitepress preview docs",
|
|
48
|
-
"pre-release": "node scripts/pre-release.js"
|
|
48
|
+
"pre-release": "node scripts/pre-release.js",
|
|
49
|
+
"prepublishOnly": "npm run lib && npm run pre-release"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@eslint/js": "^10.0.1",
|
|
52
|
-
"@rollup/plugin-typescript": "^12.3.
|
|
53
|
+
"@rollup/plugin-typescript": "^12.3.1",
|
|
53
54
|
"@types/jsdom": "^28.0.3",
|
|
54
|
-
"@types/node": "^24.19.
|
|
55
|
+
"@types/node": "^24.19.2",
|
|
55
56
|
"@types/prismjs": "^1.26.6",
|
|
56
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
57
|
-
"@typescript-eslint/parser": "^8.
|
|
58
|
-
"@vitest/coverage-v8": "^4.1.
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^8.72.1",
|
|
58
|
+
"@typescript-eslint/parser": "^8.72.1",
|
|
59
|
+
"@vitest/coverage-v8": "^4.1.12",
|
|
59
60
|
"cypress": "^15.21.1",
|
|
60
61
|
"cypress-file-upload": "^5.0.8",
|
|
61
|
-
"eslint": "^10.
|
|
62
|
+
"eslint": "^10.13.0",
|
|
62
63
|
"globals": "^17.13.0",
|
|
63
64
|
"jsdom": "^29.1.1",
|
|
64
65
|
"simple-git-hooks": "^2.14.0",
|
|
65
66
|
"tslib": "^2.8.1",
|
|
66
67
|
"typescript": "^6.0.3",
|
|
67
|
-
"typescript-eslint": "^8.
|
|
68
|
-
"vite": "^8.3.
|
|
69
|
-
"vite-plugin-css-injected-by-js": "^5.0.
|
|
68
|
+
"typescript-eslint": "^8.72.1",
|
|
69
|
+
"vite": "^8.3.5",
|
|
70
|
+
"vite-plugin-css-injected-by-js": "^5.0.3",
|
|
70
71
|
"vitepress": "^1.6.4",
|
|
71
|
-
"vitest": "^4.1.
|
|
72
|
+
"vitest": "^4.1.12",
|
|
72
73
|
"vitest-canvas-mock": "^1.2.0",
|
|
73
|
-
"vue": "^3.5.
|
|
74
|
+
"vue": "^3.5.44"
|
|
74
75
|
},
|
|
75
76
|
"simple-git-hooks": {
|
|
76
77
|
"pre-commit": "npm run lint && npm run type:check",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"catalog-B-cbxN0s.js","names":[],"sources":["../../src/editor/core/worker/works/catalog.ts"],"sourcesContent":["import { ICatalog, ICatalogItem } from '../../../interface/Catalog'\nimport { IElement, IElementPosition } from '../../../interface/Element'\n\ninterface IGetCatalogPayload {\n elementList: IElement[]\n positionList: IElementPosition[]\n}\n\ntype ICatalogElement = IElement & {\n pageNo: number\n}\n\nenum ElementType {\n TEXT = 'text',\n IMAGE = 'image',\n TABLE = 'table',\n HYPERLINK = 'hyperlink',\n SUPERSCRIPT = 'superscript',\n SUBSCRIPT = 'subscript',\n SEPARATOR = 'separator',\n PAGE_BREAK = 'pageBreak',\n CONTROL = 'control',\n CHECKBOX = 'checkbox',\n RADIO = 'radio',\n LATEX = 'latex',\n TAB = 'tab',\n DATE = 'date',\n BLOCK = 'block',\n TITLE = 'title',\n AREA = 'area',\n LIST = 'list',\n LABEL = 'label'\n}\n\nenum TitleLevel {\n FIRST = 'first',\n SECOND = 'second',\n THIRD = 'third',\n FOURTH = 'fourth',\n FIFTH = 'fifth',\n SIXTH = 'sixth'\n}\n\nconst titleOrderNumberMapping: Record<TitleLevel, number> = {\n [TitleLevel.FIRST]: 1,\n [TitleLevel.SECOND]: 2,\n [TitleLevel.THIRD]: 3,\n [TitleLevel.FOURTH]: 4,\n [TitleLevel.FIFTH]: 5,\n [TitleLevel.SIXTH]: 6\n}\n\nconst TEXTLIKE_ELEMENT_TYPE: ElementType[] = [\n ElementType.TEXT,\n ElementType.HYPERLINK,\n ElementType.SUBSCRIPT,\n ElementType.SUPERSCRIPT,\n ElementType.CONTROL,\n ElementType.DATE,\n ElementType.LABEL\n]\n\nconst ZERO = '\\u200B'\n\nfunction isTextLikeElement(element: IElement): boolean {\n return !element.type || TEXTLIKE_ELEMENT_TYPE.includes(element.type)\n}\n\nfunction getCatalog(payload: IGetCatalogPayload): ICatalog | null {\n const { elementList, positionList } = payload\n // 筛选标题\n const titleElementList: ICatalogElement[] = []\n let t = 0\n while (t < elementList.length) {\n const element = elementList[t]\n const getElementInfo = (\n element: IElement,\n elementList: IElement[],\n position: number\n ) => {\n const titleId = element.titleId\n const level = element.level\n const titleElement: ICatalogElement = {\n type: ElementType.TITLE,\n value: '',\n level,\n titleId,\n pageNo: positionList[t].pageNo\n }\n const valueList: IElement[] = []\n while (position < elementList.length) {\n const titleE = elementList[position]\n if (titleId !== titleE.titleId) {\n position--\n break\n }\n valueList.push(titleE)\n position++\n }\n titleElement.value = valueList\n .filter(el => isTextLikeElement(el))\n .map(el => el.value)\n .join('')\n .replace(new RegExp(ZERO, 'g'), '')\n return { position, titleElement }\n }\n if (element.titleId) {\n const { position, titleElement } = getElementInfo(element, elementList, t)\n t = position\n titleElementList.push(titleElement)\n }\n if (element.type === ElementType.TABLE) {\n const trList = element.trList!\n for (let r = 0; r < trList.length; r++) {\n const tr = trList[r]\n for (let d = 0; d < tr.tdList.length; d++) {\n const td = tr.tdList[d]\n const value = td.value\n if (value.length > 1) {\n let index = 1\n while (index < value.length) {\n if (value[index]?.titleId) {\n const { titleElement, position } = getElementInfo(\n value[index],\n value,\n index\n )\n titleElementList.push(titleElement)\n index = position\n }\n index++\n }\n }\n }\n }\n }\n t++\n }\n if (!titleElementList.length) return null\n // 查找到比最新元素大的标题时终止\n const recursiveInsert = (\n title: ICatalogElement,\n catalogItem: ICatalogItem\n ) => {\n const subCatalogItem =\n catalogItem.subCatalog[catalogItem.subCatalog.length - 1]\n const catalogItemLevel = titleOrderNumberMapping[subCatalogItem?.level]\n const titleLevel = titleOrderNumberMapping[title.level!]\n if (subCatalogItem && titleLevel > catalogItemLevel) {\n recursiveInsert(title, subCatalogItem)\n } else {\n catalogItem.subCatalog.push({\n id: title.titleId!,\n name: title.value,\n level: title.level!,\n pageNo: title.pageNo,\n subCatalog: []\n })\n }\n }\n // 循环标题组\n // 如果当前列表级别小于标题组最新标题级别:则递归查找最小级别并追加\n // 如果大于:则直接追加至当前标题组\n const catalog: ICatalog = []\n for (let e = 0; e < titleElementList.length; e++) {\n const title = titleElementList[e]\n const catalogItem = catalog[catalog.length - 1]\n const catalogItemLevel = titleOrderNumberMapping[catalogItem?.level]\n const titleLevel = titleOrderNumberMapping[title.level!]\n if (catalogItem && titleLevel > catalogItemLevel) {\n recursiveInsert(title, catalogItem)\n } else {\n catalog.push({\n id: title.titleId!,\n name: title.value,\n level: title.level!,\n pageNo: title.pageNo,\n subCatalog: []\n })\n }\n }\n return catalog\n}\n\nonmessage = evt => {\n const payload = <IGetCatalogPayload>evt.data\n const catalog = getCatalog(payload)\n postMessage(catalog)\n}\n"],"mappings":"YA2CA,IAAM,EAAsD,CACtC,MAAA,EACC,OAAA,EACD,MAAA,EACC,OAAA,EACD,MAAA,EACA,MAAA,CACtB,EAEM,EAAuC,sEAQ7C,EAIA,SAAS,EAAkB,EAA4B,CACrD,MAAO,CAAC,EAAQ,MAAQ,EAAsB,SAAS,EAAQ,IAAI,CACrE,CAEA,SAAS,EAAW,EAA8C,CAChE,GAAM,CAAE,cAAa,gBAAiB,EAEhC,EAAsC,CAAC,EACzC,EAAI,EACR,KAAO,EAAI,EAAY,QAAQ,CAC7B,IAAM,EAAU,EAAY,GACtB,GACJ,EACA,EACA,IACG,CACH,IAAM,EAAU,EAAQ,QAElB,EAAgC,CACpC,KAAA,QACA,MAAO,GACP,MAJY,EAAQ,MAKpB,UACA,OAAQ,EAAa,EAAE,CAAC,MAC1B,EACM,EAAwB,CAAC,EAC/B,KAAO,EAAW,EAAY,QAAQ,CACpC,IAAM,EAAS,EAAY,GAC3B,GAAI,IAAY,EAAO,QAAS,CAC9B,IACA,KACF,CACA,EAAU,KAAK,CAAM,EACrB,GACF,CAMA,MALA,GAAa,MAAQ,EAClB,OAAO,GAAM,EAAkB,CAAE,CAAC,CAAC,CACnC,IAAI,GAAM,EAAG,KAAK,CAAC,CACnB,KAAK,EAAE,CAAC,CACR,QAAY,OAAO,IAAM,GAAG,EAAG,EAAE,EAC7B,CAAE,WAAU,cAAa,CAClC,EACA,GAAI,EAAQ,QAAS,CACnB,GAAM,CAAE,WAAU,gBAAiB,EAAe,EAAS,EAAa,CAAC,EACzE,EAAI,EACJ,EAAiB,KAAK,CAAY,CACpC,CACA,GAAI,EAAQ,OAAA,QAA4B,CACtC,IAAM,EAAS,EAAQ,OACvB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,OAAQ,IAAK,CACtC,IAAM,EAAK,EAAO,GAClB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAG,OAAO,OAAQ,IAAK,CAEzC,IAAM,EADK,EAAG,OAAO,EACP,CAAG,MACjB,GAAI,EAAM,OAAS,EAAG,CACpB,IAAI,EAAQ,EACZ,KAAO,EAAQ,EAAM,QAAQ,CAC3B,GAAI,EAAM,EAAM,EAAE,QAAS,CACzB,GAAM,CAAE,eAAc,YAAa,EACjC,EAAM,GACN,EACA,CACF,EACA,EAAiB,KAAK,CAAY,EAClC,EAAQ,CACV,CACA,GACF,CACF,CACF,CACF,CACF,CACA,GACF,CACA,GAAI,CAAC,EAAiB,OAAQ,OAAO,KAErC,IAAM,GACJ,EACA,IACG,CACH,IAAM,EACJ,EAAY,WAAW,EAAY,WAAW,OAAS,GACnD,EAAmB,EAAwB,GAAgB,OAC3D,EAAa,EAAwB,EAAM,OAC7C,GAAkB,EAAa,EACjC,EAAgB,EAAO,CAAc,EAErC,EAAY,WAAW,KAAK,CAC1B,GAAI,EAAM,QACV,KAAM,EAAM,MACZ,MAAO,EAAM,MACb,OAAQ,EAAM,OACd,WAAY,CAAC,CACf,CAAC,CAEL,EAIM,EAAoB,CAAC,EAC3B,IAAK,IAAI,EAAI,EAAG,EAAI,EAAiB,OAAQ,IAAK,CAChD,IAAM,EAAQ,EAAiB,GACzB,EAAc,EAAQ,EAAQ,OAAS,GACvC,EAAmB,EAAwB,GAAa,OACxD,EAAa,EAAwB,EAAM,OAC7C,GAAe,EAAa,EAC9B,EAAgB,EAAO,CAAW,EAElC,EAAQ,KAAK,CACX,GAAI,EAAM,QACV,KAAM,EAAM,MACZ,MAAO,EAAM,MACb,OAAQ,EAAM,OACd,WAAY,CAAC,CACf,CAAC,CAEL,CACA,OAAO,CACT,CAEA,UAAY,GAAO,CACjB,IAAM,EAA8B,EAAI,KAClC,EAAU,EAAW,CAAO,EAClC,YAAY,CAAO,CACrB"}
|