vkedit 3.2.7 → 4.0.1
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 +51 -0
- package/LICENSE +21 -21
- package/README.en.md +38 -36
- package/README.md +41 -28
- package/THIRD_PARTY_LICENSES.md +64 -0
- package/dist/commands/add-element-command.d.ts +0 -2
- package/dist/commands/change-layer-order-command.d.ts +2 -0
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/reorder-elements-command.d.ts +20 -0
- package/dist/commands/update-canvas-property-command.d.ts +23 -0
- package/dist/components/BaseElementPropertyPanel.vue.d.ts +28 -1
- package/dist/components/TextProperty.vue.d.ts +2 -0
- package/dist/components/ui/VkButton.vue.d.ts +2 -2
- package/dist/components/ui/VkColorPicker.vue.d.ts +26 -0
- package/dist/components/ui/VkTextarea.vue.d.ts +20 -0
- package/dist/components/ui/index.d.ts +2 -1
- package/dist/core/ContentLayer.vue.d.ts +0 -2
- package/dist/core/Editor.vue.d.ts +1 -0
- package/dist/{plugins/rect/Tool.vue.d.ts → core/GraphicToolRenderer.vue.d.ts} +6 -1
- package/dist/core/HelpGuide.vue.d.ts +3 -1
- package/dist/{plugins/table/CellsBorder.vue.d.ts → core/TransformOverlay.vue.d.ts} +2 -2
- package/dist/core/editor-host.d.ts +4 -11
- package/dist/favicon.svg +21 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/use-canvas-property-command.d.ts +5 -0
- package/dist/hooks/use-content-layer.d.ts +6 -6
- package/dist/hooks/use-host-state.d.ts +1 -0
- package/dist/hooks/use-ruler-layer.d.ts +24 -0
- package/dist/hooks/use-selection-layer.d.ts +2 -3
- package/dist/hooks/use-stage-event.d.ts +1 -0
- package/dist/hooks/use-transform-overlay.d.ts +108 -0
- package/dist/index-Dpse_csX.js +25656 -0
- package/dist/{index.es-B1gCGYT7.js → index.es-LscL1n3Y.js} +1 -1
- package/dist/plugins/barcode/Shape.vue.d.ts +1 -1
- package/dist/plugins/barcode/index.d.ts +0 -1
- package/dist/plugins/export/export.d.ts +1 -2
- package/dist/plugins/graphic-registry/graphic-registry.d.ts +43 -0
- package/dist/plugins/graphic-registry/index.d.ts +1 -0
- package/dist/plugins/import/import.d.ts +1 -2
- package/dist/plugins/index.d.ts +2 -6
- package/dist/plugins/{table/ContextMenu.vue.d.ts → layer-manager/LayerPanel.vue.d.ts} +5 -4
- package/dist/plugins/layer-manager/index.d.ts +2 -0
- package/dist/plugins/layer-manager/layer-manager.d.ts +16 -0
- package/dist/plugins/line/Shape.vue.d.ts +3 -1
- package/dist/plugins/line/index.d.ts +0 -1
- package/dist/plugins/qrcode/Shape.vue.d.ts +1 -1
- package/dist/plugins/qrcode/index.d.ts +0 -1
- package/dist/plugins/rect/Shape.vue.d.ts +1 -1
- package/dist/plugins/rect/index.d.ts +0 -1
- package/dist/plugins/selection.d.ts +0 -1
- package/dist/plugins/text/Shape.vue.d.ts +1 -1
- package/dist/plugins/text/index.d.ts +0 -1
- package/dist/types/base-graphic-element.d.ts +10 -3
- package/dist/types/base.d.ts +6 -18
- package/dist/types/event-data.d.ts +38 -0
- package/dist/types/event-map.d.ts +14 -7
- package/dist/types/graphic-plugin.d.ts +53 -0
- package/dist/types/index.d.ts +1 -3
- package/dist/utils/color.d.ts +40 -0
- package/dist/utils/css-var.d.ts +14 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/readability.d.ts +22 -0
- package/dist/utils/theme.d.ts +2 -0
- package/dist/utils/transform-geometry.d.ts +62 -0
- package/dist/utils/transform-overlay.d.ts +62 -0
- package/dist/vkedit.css +1 -1
- package/dist/vkedit.es.js +84 -97
- package/package.json +21 -21
- package/dist/components/ui/VkIcon.vue.d.ts +0 -8
- package/dist/favicon.ico +0 -0
- package/dist/index-Aa1HXlw6.js +0 -72887
- package/dist/plugins/barcode/Tool.vue.d.ts +0 -6
- package/dist/plugins/barcode/barcode.d.ts +0 -76
- package/dist/plugins/chart/PropertyPanel.vue.d.ts +0 -9
- package/dist/plugins/chart/Shape.vue.d.ts +0 -23
- package/dist/plugins/chart/Tool.vue.d.ts +0 -6
- package/dist/plugins/chart/chart.d.ts +0 -38
- package/dist/plugins/chart/index.d.ts +0 -4
- package/dist/plugins/element-manager.d.ts +0 -24
- package/dist/plugins/graphic-manager/graphic-manager.d.ts +0 -31
- package/dist/plugins/graphic-manager/index.d.ts +0 -1
- package/dist/plugins/graphic-tool-manager.d.ts +0 -16
- package/dist/plugins/line/Tool.vue.d.ts +0 -7
- package/dist/plugins/line/line.d.ts +0 -61
- package/dist/plugins/property-panel-manager/index.d.ts +0 -1
- package/dist/plugins/property-panel-manager/property-panel-manager.d.ts +0 -32
- package/dist/plugins/qrcode/Tool.vue.d.ts +0 -6
- package/dist/plugins/qrcode/qrcode.d.ts +0 -75
- package/dist/plugins/rect/rect.d.ts +0 -69
- package/dist/plugins/table/PropertyPanel.vue.d.ts +0 -9
- package/dist/plugins/table/Shape.vue.d.ts +0 -26
- package/dist/plugins/table/Tool.vue.d.ts +0 -7
- package/dist/plugins/table/cell.d.ts +0 -61
- package/dist/plugins/table/index.d.ts +0 -6
- package/dist/plugins/table/table.d.ts +0 -92
- package/dist/plugins/text/Tool.vue.d.ts +0 -6
- package/dist/plugins/text/text.d.ts +0 -76
- package/dist/types/base-graphic-type.d.ts +0 -9
- package/dist/types/element-type-map.d.ts +0 -12
- package/dist/types/plugin-map.d.ts +0 -12
|
@@ -7,7 +7,6 @@ export declare class ExportPlugin extends BasePlugin {
|
|
|
7
7
|
pixelRatio: number;
|
|
8
8
|
constructor(host: EditorHost, pixelRatio?: number);
|
|
9
9
|
protected onInstall(): void;
|
|
10
|
-
handleExportExcel(): void;
|
|
11
10
|
handleExportImage(): void;
|
|
12
11
|
handleExportJSON(): void;
|
|
13
12
|
handleExportPdf(): void;
|
|
@@ -30,7 +29,7 @@ declare module '../../types' {
|
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
export interface ExportEventData extends BaseEventData {
|
|
33
|
-
format: 'png' | 'jpeg' | 'pdf' | 'json' |
|
|
32
|
+
format: 'png' | 'jpeg' | 'pdf' | 'json' | string;
|
|
34
33
|
error?: any;
|
|
35
34
|
prevent?: () => void;
|
|
36
35
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BasePlugin } from '../../types/base-plugin';
|
|
2
|
+
import { Component } from 'vue';
|
|
3
|
+
import { IGraphicElement } from '../../types';
|
|
4
|
+
export interface ToolDescriptor {
|
|
5
|
+
type: string;
|
|
6
|
+
iconComponent: Component;
|
|
7
|
+
typeDisplayName: string;
|
|
8
|
+
createElement: () => IGraphicElement;
|
|
9
|
+
}
|
|
10
|
+
export declare class GraphicRegistryPlugin extends BasePlugin {
|
|
11
|
+
name: string;
|
|
12
|
+
version: string;
|
|
13
|
+
elements: Map<string, IGraphicElement>;
|
|
14
|
+
private graphics;
|
|
15
|
+
private tools;
|
|
16
|
+
private propertyPanels;
|
|
17
|
+
protected onInstall(): void;
|
|
18
|
+
protected onUninstall(): void;
|
|
19
|
+
getElementComponent(type: string): Component;
|
|
20
|
+
getTypeMeta(type: string): {
|
|
21
|
+
iconComponent?: Component;
|
|
22
|
+
typeDisplayName?: string;
|
|
23
|
+
} | undefined;
|
|
24
|
+
getToolList(): ToolDescriptor[];
|
|
25
|
+
getToolComponent(type: string): Component;
|
|
26
|
+
getPanelsBySelection(selection: IGraphicElement[]): Component[];
|
|
27
|
+
private getPanelsByType;
|
|
28
|
+
private getPanelsByMultipleSelect;
|
|
29
|
+
private findCommonElements;
|
|
30
|
+
getCanvasPanels(): Component[];
|
|
31
|
+
addElement(element: IGraphicElement): void;
|
|
32
|
+
removeElement(elementId: string): void;
|
|
33
|
+
getElement<T extends IGraphicElement = IGraphicElement>(elementId: string): T;
|
|
34
|
+
getAllElements<T extends IGraphicElement = IGraphicElement>(): T[];
|
|
35
|
+
createElement(type: string): IGraphicElement;
|
|
36
|
+
getOrderedElements(order?: 'ascending' | 'descending'): IGraphicElement[];
|
|
37
|
+
normalizeZIndices(): void;
|
|
38
|
+
}
|
|
39
|
+
declare module '../../types' {
|
|
40
|
+
interface PluginMap {
|
|
41
|
+
'graphic-registry-plugin': GraphicRegistryPlugin;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './graphic-registry';
|
|
@@ -12,7 +12,6 @@ export declare class ImportPlugin extends BasePlugin {
|
|
|
12
12
|
};
|
|
13
13
|
handleImportJSON(): void;
|
|
14
14
|
importJSON(data: string): void;
|
|
15
|
-
importExcel(): void;
|
|
16
15
|
}
|
|
17
16
|
declare module '../../types' {
|
|
18
17
|
interface PluginMap {
|
|
@@ -20,7 +19,7 @@ declare module '../../types' {
|
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
export interface ImportEventData extends BaseEventData {
|
|
23
|
-
format: 'json' |
|
|
22
|
+
format: 'json' | string;
|
|
24
23
|
error?: any;
|
|
25
24
|
}
|
|
26
25
|
declare module '../../types' {
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
export * from './align';
|
|
2
2
|
export * from './barcode';
|
|
3
3
|
export * from './clipboard';
|
|
4
|
-
export * from './chart';
|
|
5
4
|
export * from './context-menu-manager';
|
|
6
|
-
export * from './element-manager';
|
|
7
5
|
export * from './export';
|
|
8
|
-
export * from './graphic-
|
|
9
|
-
export * from './graphic-tool-manager';
|
|
6
|
+
export * from './graphic-registry';
|
|
10
7
|
export * from './import';
|
|
11
8
|
export * from './keydown';
|
|
9
|
+
export * from './layer-manager';
|
|
12
10
|
export * from './line';
|
|
13
11
|
export * from './preview';
|
|
14
|
-
export * from './property-panel-manager';
|
|
15
12
|
export * from './qrcode';
|
|
16
13
|
export * from './rect';
|
|
17
14
|
export * from './selection';
|
|
18
15
|
export * from './snap';
|
|
19
|
-
export * from './table';
|
|
20
16
|
export * from './text';
|
|
21
17
|
export * from './toolbar-manager';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { EditorHost } from '../../core';
|
|
2
|
-
import { TableElement } from './table';
|
|
3
2
|
type __VLS_Props = {
|
|
4
3
|
host: EditorHost;
|
|
5
|
-
element: TableElement;
|
|
6
|
-
selection: TableElement[];
|
|
7
4
|
};
|
|
8
|
-
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
5
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
6
|
+
panelRef: HTMLDivElement;
|
|
7
|
+
listRef: HTMLDivElement;
|
|
8
|
+
renameInputEl: HTMLInputElement;
|
|
9
|
+
}, HTMLDivElement>;
|
|
9
10
|
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BasePlugin } from '../../types/base-plugin';
|
|
2
|
+
import { IGraphicElement } from '../../types';
|
|
3
|
+
export declare class LayerManagerPlugin extends BasePlugin {
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
protected onInstall(): void;
|
|
7
|
+
protected onUninstall(): void;
|
|
8
|
+
getElementDisplayName(element: IGraphicElement): string;
|
|
9
|
+
moveLayer(elementId: string, direction: 'up' | 'down' | 'top' | 'bottom'): void;
|
|
10
|
+
reorder(newOrder: string[]): void;
|
|
11
|
+
}
|
|
12
|
+
declare module '../../types' {
|
|
13
|
+
interface PluginMap {
|
|
14
|
+
'layer-manager-plugin': LayerManagerPlugin;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { EditorHost } from '../../core';
|
|
1
2
|
import { LineElement } from './line';
|
|
2
|
-
interface Props {
|
|
3
|
+
export interface Props {
|
|
4
|
+
host: EditorHost;
|
|
3
5
|
element: LineElement;
|
|
4
6
|
}
|
|
5
7
|
declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RectElement } from './rect';
|
|
2
|
-
interface Props {
|
|
2
|
+
export interface Props {
|
|
3
3
|
element: RectElement;
|
|
4
4
|
}
|
|
5
5
|
declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextElement } from './text';
|
|
2
|
-
interface Props {
|
|
2
|
+
export interface Props {
|
|
3
3
|
element: TextElement;
|
|
4
4
|
}
|
|
5
5
|
declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
@@ -13,7 +13,9 @@ export interface BaseGraphicElementOptions {
|
|
|
13
13
|
visible?: boolean;
|
|
14
14
|
locked?: boolean;
|
|
15
15
|
draggable?: boolean;
|
|
16
|
-
|
|
16
|
+
resizable?: boolean;
|
|
17
|
+
zIndex?: number;
|
|
18
|
+
displayName?: string | null;
|
|
17
19
|
}
|
|
18
20
|
export declare abstract class BaseGraphicElement implements IGraphicElement {
|
|
19
21
|
get x(): number;
|
|
@@ -37,8 +39,11 @@ export declare abstract class BaseGraphicElement implements IGraphicElement {
|
|
|
37
39
|
visible: boolean;
|
|
38
40
|
locked: boolean;
|
|
39
41
|
draggable: boolean;
|
|
40
|
-
|
|
42
|
+
resizable: boolean;
|
|
43
|
+
zIndex: number;
|
|
41
44
|
resizeAnchors: string[] | null;
|
|
45
|
+
/** 元素自定义显示名称。空字符串/null 时回退到 layer-manager.getElementDisplayName 的自动命名逻辑。 */
|
|
46
|
+
displayName: string | null;
|
|
42
47
|
constructor(host: EditorHost, options?: Partial<BaseGraphicElementOptions>);
|
|
43
48
|
updateProperty(host: EditorHost, property: string, oldValue: any, newValue: any): void;
|
|
44
49
|
clone(): IGraphicElement;
|
|
@@ -62,7 +67,9 @@ export declare abstract class BaseGraphicElement implements IGraphicElement {
|
|
|
62
67
|
visible: boolean;
|
|
63
68
|
locked: boolean;
|
|
64
69
|
draggable: boolean;
|
|
65
|
-
|
|
70
|
+
resizable: boolean;
|
|
71
|
+
zIndex: number;
|
|
72
|
+
displayName: string | null;
|
|
66
73
|
[key: string]: any;
|
|
67
74
|
};
|
|
68
75
|
getTransformAttr(event: any): {
|
package/dist/types/base.d.ts
CHANGED
|
@@ -14,11 +14,6 @@ export interface BoundingBox {
|
|
|
14
14
|
width: number;
|
|
15
15
|
height: number;
|
|
16
16
|
}
|
|
17
|
-
export interface IGraphicComponent {
|
|
18
|
-
component: any;
|
|
19
|
-
props?: any;
|
|
20
|
-
events?: any;
|
|
21
|
-
}
|
|
22
17
|
export interface IGraphicElement {
|
|
23
18
|
id: string;
|
|
24
19
|
type: string;
|
|
@@ -32,7 +27,10 @@ export interface IGraphicElement {
|
|
|
32
27
|
visible: boolean;
|
|
33
28
|
locked: boolean;
|
|
34
29
|
draggable: boolean;
|
|
35
|
-
|
|
30
|
+
resizable: boolean;
|
|
31
|
+
zIndex: number;
|
|
32
|
+
/** 元素自定义显示名称。空字符串/null 时回退到 layer-manager.getElementDisplayName 的自动命名逻辑。 */
|
|
33
|
+
displayName?: string | null;
|
|
36
34
|
resizeAnchors?: string[] | null;
|
|
37
35
|
getBoundingBox(): BoundingBox;
|
|
38
36
|
clone(): IGraphicElement;
|
|
@@ -51,24 +49,13 @@ export interface IEditorPlugin {
|
|
|
51
49
|
uninstall(): void;
|
|
52
50
|
activate?(): void;
|
|
53
51
|
deactivate?(): void;
|
|
54
|
-
registerGraphicTypes?(): IGraphicType[];
|
|
55
|
-
getTools?(): IPluginTool[];
|
|
56
|
-
[key: string]: any;
|
|
57
|
-
}
|
|
58
|
-
export interface IPluginTool {
|
|
59
52
|
[key: string]: any;
|
|
60
53
|
}
|
|
61
|
-
export interface IGraphicType {
|
|
62
|
-
type: string;
|
|
63
|
-
render(): Component;
|
|
64
|
-
renderTool(): Component;
|
|
65
|
-
renderPropertyPanel(): Component;
|
|
66
|
-
createElement(x: number, y: number): IGraphicElement;
|
|
67
|
-
}
|
|
68
54
|
export interface IEditorState {
|
|
69
55
|
zoom: number;
|
|
70
56
|
currentTool: string;
|
|
71
57
|
snapToGrid: boolean;
|
|
58
|
+
snapRotation: boolean;
|
|
72
59
|
showGrid: boolean;
|
|
73
60
|
width: number;
|
|
74
61
|
height: number;
|
|
@@ -87,6 +74,7 @@ export interface IStageState {
|
|
|
87
74
|
isPanning: boolean;
|
|
88
75
|
offsetX: number;
|
|
89
76
|
offsetY: number;
|
|
77
|
+
autoFitPending: boolean;
|
|
90
78
|
}
|
|
91
79
|
export interface IToolbar {
|
|
92
80
|
name: string;
|
|
@@ -7,6 +7,10 @@ export interface BaseEventData {
|
|
|
7
7
|
timestamp?: number;
|
|
8
8
|
source?: string;
|
|
9
9
|
}
|
|
10
|
+
export interface EditorLifecyclePayload {
|
|
11
|
+
timestamp: number;
|
|
12
|
+
source: string;
|
|
13
|
+
}
|
|
10
14
|
export interface ElementEventData extends BaseEventData {
|
|
11
15
|
element: any;
|
|
12
16
|
elementId: string;
|
|
@@ -18,6 +22,9 @@ export interface ElementRegisteredEventData extends BaseEventData {
|
|
|
18
22
|
export interface SelectionEventData extends BaseEventData {
|
|
19
23
|
selection: Array<IGraphicElement>;
|
|
20
24
|
}
|
|
25
|
+
export interface SelectionChangedPayload {
|
|
26
|
+
elements: unknown[];
|
|
27
|
+
}
|
|
21
28
|
export interface TransformEventData extends ElementEventData {
|
|
22
29
|
oldState: any;
|
|
23
30
|
newState: any;
|
|
@@ -35,6 +42,10 @@ export interface ToolEventData extends BaseEventData {
|
|
|
35
42
|
export interface PluginEventData extends BaseEventData {
|
|
36
43
|
plugin: any;
|
|
37
44
|
}
|
|
45
|
+
export interface PluginLoadedPayload extends BaseEventData {
|
|
46
|
+
name: string;
|
|
47
|
+
plugin: unknown;
|
|
48
|
+
}
|
|
38
49
|
export interface CommandEventData extends BaseEventData {
|
|
39
50
|
command: any;
|
|
40
51
|
}
|
|
@@ -79,6 +90,17 @@ export interface DistributeEventData extends BaseEventData {
|
|
|
79
90
|
export interface LayerOrderEventData extends BaseEventData {
|
|
80
91
|
elementId: string;
|
|
81
92
|
direction: 'up' | 'down' | 'top' | 'bottom';
|
|
93
|
+
newOrder?: string[];
|
|
94
|
+
}
|
|
95
|
+
export interface LayerOrderChangedPayload extends BaseEventData {
|
|
96
|
+
elementIds: string[];
|
|
97
|
+
elementId?: string;
|
|
98
|
+
direction?: 'up' | 'down' | 'top' | 'bottom';
|
|
99
|
+
newOrder?: string[];
|
|
100
|
+
}
|
|
101
|
+
export interface LayerVisibilityChangedPayload extends BaseEventData {
|
|
102
|
+
elementId: string;
|
|
103
|
+
visible: boolean;
|
|
82
104
|
}
|
|
83
105
|
export interface BaseStageEventData extends BaseEventData {
|
|
84
106
|
point: Point2D;
|
|
@@ -106,6 +128,22 @@ export interface ElementDragEventData extends BaseEventData {
|
|
|
106
128
|
target: any;
|
|
107
129
|
evt: MouseEvent | undefined;
|
|
108
130
|
}
|
|
131
|
+
export interface GraphicEventData extends BaseEventData {
|
|
132
|
+
type: string;
|
|
133
|
+
render: () => Component;
|
|
134
|
+
iconComponent?: Component;
|
|
135
|
+
typeDisplayName?: string;
|
|
136
|
+
}
|
|
137
|
+
export interface GraphicToolEventData extends BaseEventData {
|
|
138
|
+
type: string;
|
|
139
|
+
render: () => Component;
|
|
140
|
+
}
|
|
141
|
+
export interface PropertyPanelEventData extends BaseEventData {
|
|
142
|
+
graphicTypes: string[];
|
|
143
|
+
render: () => Component;
|
|
144
|
+
isCanvas: boolean;
|
|
145
|
+
isPublic: boolean;
|
|
146
|
+
}
|
|
109
147
|
/**
|
|
110
148
|
* 事件工具函数
|
|
111
149
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseEventData, ElementDragEventData, ElementEventData, SelectionEventData, TransformEventData, ToolEventData, PluginEventData, CommandEventData, HistoryEventData, ViewEventData, CreationEventData, ErrorEventData, PerformanceEventData, AlignEventData, DistributeEventData, LayerOrderEventData, ElementUpdateEventData, StageDblClickEventData, StageMouseEventData, StageKeyboardEventData, ElementRegisteredEventData, StatusEventData } from './event-data';
|
|
1
|
+
import { BaseEventData, EditorLifecyclePayload, ElementDragEventData, ElementEventData, SelectionEventData, TransformEventData, ToolEventData, PluginEventData, PluginLoadedPayload, CommandEventData, HistoryEventData, ViewEventData, CreationEventData, ErrorEventData, PerformanceEventData, AlignEventData, DistributeEventData, LayerOrderEventData, LayerOrderChangedPayload, LayerVisibilityChangedPayload, ElementUpdateEventData, StageDblClickEventData, StageMouseEventData, StageKeyboardEventData, ElementRegisteredEventData, StatusEventData, GraphicEventData, GraphicToolEventData, PropertyPanelEventData } from './event-data';
|
|
2
2
|
/**
|
|
3
3
|
* 编辑器事件映射接口
|
|
4
4
|
* @description 定义编辑器中所有可能的事件及其对应的负载类型。
|
|
@@ -16,9 +16,9 @@ import { BaseEventData, ElementDragEventData, ElementEventData, SelectionEventDa
|
|
|
16
16
|
* ```
|
|
17
17
|
* */
|
|
18
18
|
export interface EventMap {
|
|
19
|
-
'editor:ready': (payload:
|
|
20
|
-
'editor:destroy': (payload:
|
|
21
|
-
'editor:reset': (payload:
|
|
19
|
+
'editor:ready': (payload: EditorLifecyclePayload) => void;
|
|
20
|
+
'editor:destroy': (payload: EditorLifecyclePayload) => void;
|
|
21
|
+
'editor:reset': (payload: EditorLifecyclePayload) => void;
|
|
22
22
|
'file:new': (payload: BaseEventData) => void;
|
|
23
23
|
'file:open': (payload: BaseEventData) => void;
|
|
24
24
|
'file:save': (payload: BaseEventData) => void;
|
|
@@ -83,8 +83,8 @@ export interface EventMap {
|
|
|
83
83
|
'view:ruler-visibility-change': (payload: ViewEventData) => void;
|
|
84
84
|
'layer:added': (payload: BaseEventData) => void;
|
|
85
85
|
'layer:removed': (payload: BaseEventData) => void;
|
|
86
|
-
'layer:order-changed': (payload:
|
|
87
|
-
'layer:visibility-change': (payload:
|
|
86
|
+
'layer:order-changed': (payload: LayerOrderChangedPayload) => void;
|
|
87
|
+
'layer:visibility-change': (payload: LayerVisibilityChangedPayload) => void;
|
|
88
88
|
'layer:locked-change': (payload: BaseEventData) => void;
|
|
89
89
|
'layer:active-change': (payload: BaseEventData) => void;
|
|
90
90
|
'command:executed': (payload: CommandEventData) => void;
|
|
@@ -96,11 +96,17 @@ export interface EventMap {
|
|
|
96
96
|
'plugin:unregistered': (payload: PluginEventData) => void;
|
|
97
97
|
'plugin:activated': (payload: PluginEventData) => void;
|
|
98
98
|
'plugin:deactivated': (payload: PluginEventData) => void;
|
|
99
|
-
'plugin:loaded': (payload:
|
|
99
|
+
'plugin:loaded': (payload: PluginLoadedPayload) => void;
|
|
100
100
|
'plugin:error': (payload: ErrorEventData) => void;
|
|
101
|
+
'graphic:registered': (payload: GraphicEventData) => void;
|
|
102
|
+
'graphic:unregistered': (payload: GraphicEventData) => void;
|
|
103
|
+
'graphic-tool:registered': (payload: GraphicToolEventData) => void;
|
|
104
|
+
'graphic-tool:unregistered': (payload: GraphicToolEventData) => void;
|
|
101
105
|
'create-strategy:registered': (payload: BaseEventData) => void;
|
|
102
106
|
'create-strategy:unregistered': (payload: BaseEventData) => void;
|
|
103
107
|
'create-strategy:needs-register': (payload: BaseEventData) => void;
|
|
108
|
+
'property-panel:registered': (payload: PropertyPanelEventData) => void;
|
|
109
|
+
'property-panel:unregistered': (payload: PropertyPanelEventData) => void;
|
|
104
110
|
'property:value-change': (payload: BaseEventData) => void;
|
|
105
111
|
'property:batch-update-start': (payload: BaseEventData) => void;
|
|
106
112
|
'property:batch-update-end': (payload: BaseEventData) => void;
|
|
@@ -109,6 +115,7 @@ export interface EventMap {
|
|
|
109
115
|
'elements:group': (payload: BaseEventData) => void;
|
|
110
116
|
'elements:ungroup': (payload: BaseEventData) => void;
|
|
111
117
|
'elements:layer': (payload: LayerOrderEventData) => void;
|
|
118
|
+
'elements:reorder': (payload: LayerOrderEventData) => void;
|
|
112
119
|
'shortcut:triggered': (payload: BaseEventData) => void;
|
|
113
120
|
'shortcut:registered': (payload: BaseEventData) => void;
|
|
114
121
|
'shortcut:conflict': (payload: BaseEventData) => void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { EditorHost } from '../core';
|
|
3
|
+
import { BasePlugin } from './base-plugin';
|
|
4
|
+
import { IGraphicElement } from './base';
|
|
5
|
+
export interface GraphicTypeRegistration {
|
|
6
|
+
type: string;
|
|
7
|
+
render: () => Component;
|
|
8
|
+
createElement: () => IGraphicElement;
|
|
9
|
+
iconComponent?: Component;
|
|
10
|
+
typeDisplayName?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PropertyPanelRegistration {
|
|
13
|
+
graphicTypes: string[];
|
|
14
|
+
render: () => Component;
|
|
15
|
+
isCanvas?: boolean;
|
|
16
|
+
isPublic?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare abstract class GraphicPlugin<T extends IGraphicElement> extends BasePlugin {
|
|
19
|
+
abstract graphicType: string;
|
|
20
|
+
abstract graphicElement: new (host: EditorHost) => T;
|
|
21
|
+
abstract shapeComponent: Component;
|
|
22
|
+
/**
|
|
23
|
+
* 当前图形自身的属性面板 Vue 组件。
|
|
24
|
+
*
|
|
25
|
+
* 与 {@link shapeComponent} / {@link iconComponent} 风格一致:
|
|
26
|
+
* 直接以组件引用声明,而非工厂函数。
|
|
27
|
+
*
|
|
28
|
+
* 基类会在 `onActivate` 时自动 emit 等价的 `property-panel:registered` 事件:
|
|
29
|
+
* - `graphicTypes = [this.graphicType]`
|
|
30
|
+
* - `render = () => this.propertyPanel`
|
|
31
|
+
* - `isCanvas = false`
|
|
32
|
+
* - `isPublic = false`
|
|
33
|
+
*
|
|
34
|
+
* 如需注册自身以外的图形类型、注册多个面板、或 `isCanvas = true` / `isPublic = true`,
|
|
35
|
+
* 请改用旧 {@link propertyPanels} 字段或在独立插件的 `onInstall` 手动 emit。
|
|
36
|
+
*/
|
|
37
|
+
propertyPanel?: Component;
|
|
38
|
+
/**
|
|
39
|
+
* 属性面板注册列表(旧 API,多面板与逃生通道)。
|
|
40
|
+
*
|
|
41
|
+
* @deprecated 请优先使用单数 {@link propertyPanel} 字段。本字段仅作为
|
|
42
|
+
* 「多面板 / 为其他 graphicType 注册 / `isCanvas = true` / `isPublic = true`」
|
|
43
|
+
* 场景下的逃生通道保留。新插件禁止使用本字段。
|
|
44
|
+
*
|
|
45
|
+
* 基类 `onActivate` 仍按现有逻辑遍历本数组 emit `property-panel:registered`,
|
|
46
|
+
* 因此同一插件同时声明 `propertyPanel` 与 `propertyPanels` 时两者都会被注册。
|
|
47
|
+
*/
|
|
48
|
+
propertyPanels?: PropertyPanelRegistration[];
|
|
49
|
+
iconComponent?: Component;
|
|
50
|
+
typeDisplayName?: string;
|
|
51
|
+
protected onActivate(): void;
|
|
52
|
+
protected onDeactivate(): void;
|
|
53
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export * from './base-graphic-element';
|
|
2
|
-
export * from './base-graphic-type';
|
|
3
2
|
export * from './base-plugin';
|
|
4
3
|
export * from './base';
|
|
5
4
|
export * from './event-data';
|
|
6
5
|
export * from './event-map';
|
|
7
6
|
export * from './konva-text';
|
|
8
|
-
export * from './plugin
|
|
9
|
-
export * from './element-type-map';
|
|
7
|
+
export * from './graphic-plugin';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断输入是否是完整的 #RRGGBB 形式的 HEX 颜色
|
|
3
|
+
*/
|
|
4
|
+
export declare function isFullHexColor(value: unknown): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* 将任意输入规范化为小写 #rrggbb 形式的 HEX 字符串
|
|
7
|
+
* @returns 规范化结果;输入不是合法完整 HEX 时返回 null
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeHex(value: unknown): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* 将 #rrggbb 形式的字符串拆分成 r/g/b 三个 0-255 的整数分量
|
|
12
|
+
*/
|
|
13
|
+
export declare function hexToRgb(hex: unknown): {
|
|
14
|
+
r: number;
|
|
15
|
+
g: number;
|
|
16
|
+
b: number;
|
|
17
|
+
} | null;
|
|
18
|
+
/**
|
|
19
|
+
* WCAG 2.x sRGB 相对亮度
|
|
20
|
+
* https://www.w3.org/TR/WCAG21/#dfn-relative-luminance
|
|
21
|
+
*/
|
|
22
|
+
export declare function relativeLuminance(rgb: {
|
|
23
|
+
r: number;
|
|
24
|
+
g: number;
|
|
25
|
+
b: number;
|
|
26
|
+
}): number;
|
|
27
|
+
/**
|
|
28
|
+
* WCAG 2.x 对比度 = (较亮 + 0.05) / (较暗 + 0.05)
|
|
29
|
+
*/
|
|
30
|
+
export declare function contrastRatio(a: {
|
|
31
|
+
r: number;
|
|
32
|
+
g: number;
|
|
33
|
+
b: number;
|
|
34
|
+
}, b: {
|
|
35
|
+
r: number;
|
|
36
|
+
g: number;
|
|
37
|
+
b: number;
|
|
38
|
+
}): number;
|
|
39
|
+
export declare const DEFAULT_SWATCHES: string[];
|
|
40
|
+
export declare const PRESET_SWATCHES: string[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a CSS custom property from the editor theme scope.
|
|
3
|
+
* Prefer passing a node inside the editor (e.g. host.stageState.wrapperEl).
|
|
4
|
+
*/
|
|
5
|
+
export declare function cssVar(name: string, el?: Element | null): string;
|
|
6
|
+
/**
|
|
7
|
+
* Resolve a color token to a computed color (rgb/rgba) that canvas/Konva can use.
|
|
8
|
+
* getPropertyValue alone may return nested `var(...)` which Konva cannot paint.
|
|
9
|
+
*/
|
|
10
|
+
export declare function cssColorVar(name: string, el?: Element | null): string;
|
|
11
|
+
/**
|
|
12
|
+
* Resolve color-mix against a token (e.g. primary @ 16% transparent) for Konva fills.
|
|
13
|
+
*/
|
|
14
|
+
export declare function cssColorMix(name: string, percent: number, el?: Element | null, space?: string): string;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComputedRef } from 'vue';
|
|
2
|
+
export declare const READABILITY_WARNING_TEXT = "\u5F53\u524D\u524D\u666F\u8272\u4E0E\u80CC\u666F\u8272\u7684\u660E\u6697\u5173\u7CFB\u6216\u5BF9\u6BD4\u5EA6\u53EF\u80FD\u5BFC\u81F4\u7801\u65E0\u6CD5\u8BC6\u522B\uFF0C\u8BF7\u4F7F\u7528\u5B9E\u9645\u8BBE\u5907\u626B\u7801\u786E\u8BA4\u3002";
|
|
3
|
+
export declare const READABILITY_CONTRAST_THRESHOLD = 4.5;
|
|
4
|
+
/**
|
|
5
|
+
* 判定给定前景色与背景色组合是否会触发可读性风险提示。
|
|
6
|
+
* - 前景亮度 >= 背景亮度 ⇒ 必然触发
|
|
7
|
+
* - 前景更暗但对比度 < 4.5 ⇒ 触发
|
|
8
|
+
* - 前景更暗且对比度 >= 4.5 ⇒ 不触发
|
|
9
|
+
*/
|
|
10
|
+
export declare function shouldWarnReadability(fg: string, bg: string): boolean;
|
|
11
|
+
export interface UseReadabilityWarningInput {
|
|
12
|
+
foreground: ComputedRef<string> | {
|
|
13
|
+
value: string;
|
|
14
|
+
};
|
|
15
|
+
background: ComputedRef<string> | {
|
|
16
|
+
value: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 在属性面板中使用的可读性风险提示组合式:返回文案(无风险时为空字符串)
|
|
21
|
+
*/
|
|
22
|
+
export declare function useReadabilityWarning(input: UseReadabilityWarningInput): ComputedRef<string>;
|