mce 0.16.7 → 0.17.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.
Files changed (58) hide show
  1. package/dist/components/EditorLayout.vue.d.ts +2 -9
  2. package/dist/components/Frame.vue.d.ts +6 -2
  3. package/dist/components/Rulers.vue.d.ts +17 -4
  4. package/dist/components/Selection.vue.d.ts +97 -79
  5. package/dist/components/shared/{TransformControls.vue.d.ts → Transform.vue.d.ts} +21 -25
  6. package/dist/composables/strategy.d.ts +1 -2
  7. package/dist/editor.d.ts +10 -8
  8. package/dist/index.css +131 -91
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +6474 -6196
  11. package/dist/locale/en.d.ts +12 -14
  12. package/dist/locale/zh-Hans.d.ts +12 -14
  13. package/dist/mixins/0.config/base.d.ts +41 -26
  14. package/dist/mixins/0.config.d.ts +3 -3
  15. package/dist/mixins/0.context.d.ts +2 -2
  16. package/dist/mixins/0.font.d.ts +0 -3
  17. package/dist/mixins/1.screen.d.ts +11 -2
  18. package/dist/mixins/snap.d.ts +27 -0
  19. package/dist/mixins/snapshot.d.ts +0 -3
  20. package/dist/mixins/tool.d.ts +25 -0
  21. package/dist/nodes/Doc.d.ts +2 -2
  22. package/dist/plugin.d.ts +3 -3
  23. package/dist/plugins/frame.d.ts +13 -1
  24. package/dist/plugins/image.d.ts +1 -1
  25. package/dist/plugins/layers.d.ts +2 -2
  26. package/dist/plugins/madeWith.d.ts +5 -2
  27. package/dist/plugins/menu.d.ts +3 -0
  28. package/dist/plugins/node.d.ts +6 -3
  29. package/dist/plugins/pen.d.ts +1 -1
  30. package/dist/plugins/ruler.d.ts +6 -9
  31. package/dist/plugins/scroll.d.ts +6 -3
  32. package/dist/plugins/selection.d.ts +4 -10
  33. package/dist/plugins/shape.d.ts +1 -1
  34. package/dist/plugins/smartGuides.d.ts +0 -7
  35. package/dist/plugins/state.d.ts +1 -1
  36. package/dist/plugins/statusbar.d.ts +4 -4
  37. package/dist/plugins/timeline.d.ts +4 -4
  38. package/dist/plugins/{drawingTool.d.ts → tool.d.ts} +1 -1
  39. package/dist/plugins/toolbelt.d.ts +5 -2
  40. package/dist/plugins/transform.d.ts +36 -4
  41. package/dist/plugins/typography.d.ts +41 -0
  42. package/dist/plugins/view.d.ts +16 -10
  43. package/dist/plugins/zoom.d.ts +10 -7
  44. package/dist/typed-global.d.ts +4 -1
  45. package/dist/typed-plugins.d.ts +4 -8
  46. package/dist/types/helper.d.ts +3 -0
  47. package/dist/types/index.d.ts +1 -0
  48. package/dist/utils/dnd.d.ts +28 -7
  49. package/dist/utils/helper.d.ts +2 -0
  50. package/package.json +6 -6
  51. package/dist/mixins/4.1.text.d.ts +0 -21
  52. package/dist/mixins/drawingTool.d.ts +0 -25
  53. package/dist/plugins/move.d.ts +0 -20
  54. package/dist/plugins/panels.d.ts +0 -13
  55. package/dist/plugins/rotate.d.ts +0 -10
  56. package/dist/plugins/text.d.ts +0 -17
  57. package/dist/plugins/ui.d.ts +0 -20
  58. /package/dist/components/{NodeCreator.vue.d.ts → Creator.vue.d.ts} +0 -0
@@ -0,0 +1,41 @@
1
+ import type { Element2D } from 'modern-canvas';
2
+ import type { FontSource } from 'modern-font';
3
+ import type { NormalizedFill, NormalizedFragment } from 'modern-idoc';
4
+ import type { Ref } from 'vue';
5
+ declare global {
6
+ namespace Mce {
7
+ interface Config {
8
+ typography: TypographyConfig;
9
+ }
10
+ interface TypographyConfig {
11
+ strategy: TypographyStrategy;
12
+ defaultFont?: FontSource;
13
+ }
14
+ type TypographyStrategy = 'autoHeight' | 'autoWidth' | 'fixedWidthHeight' | 'autoFontSize';
15
+ interface Editor {
16
+ hasTextSelectionRange: Ref<boolean>;
17
+ isTextAllSelected: Ref<boolean>;
18
+ }
19
+ interface addTextElementOptions extends AddElementOptions {
20
+ content?: string;
21
+ style?: Record<string, any>;
22
+ }
23
+ interface Commands {
24
+ startTyping: (event?: MouseEvent) => Promise<boolean>;
25
+ addTextElement: (options?: addTextElementOptions) => Element2D;
26
+ handleTextSelection: (textSelection: IndexCharacter[], cb: (arg: Record<string, any>) => boolean) => void;
27
+ textFontSizeToFit: (element: Element2D, scale?: number) => void;
28
+ textToFit: (element: Element2D, typography?: TypographyStrategy) => void;
29
+ getTextStyle: (key: string) => any;
30
+ setTextStyle: (key: string, value: any) => void;
31
+ getTextFill: () => NormalizedFill | undefined;
32
+ setTextFill: (value: NormalizedFill | undefined) => void;
33
+ setTextContentByEachFragment: (handler: (fragment: NormalizedFragment) => void) => void;
34
+ }
35
+ interface Tools {
36
+ text: [options?: addTextElementOptions];
37
+ }
38
+ }
39
+ }
40
+ declare const _default: import("..").Plugin;
41
+ export default _default;
@@ -1,17 +1,23 @@
1
+ import type { PointerInputEvent } from 'modern-canvas';
1
2
  declare global {
2
3
  namespace Mce {
3
- interface Views {
4
- msaa: [];
5
- checkerboard: [];
6
- pixelGrid: [];
7
- ruler: [];
8
- scrollbar: [];
9
- timeline: [];
10
- statusbar: [];
11
- frameOutline: [];
4
+ type Ui = keyof UIConfig;
5
+ interface PointerDownOptions {
6
+ allowTopFrame?: boolean;
12
7
  }
13
8
  interface Commands {
14
- view: <T extends keyof Views>(view: T, ...args: Views[T]) => Promise<boolean>;
9
+ getUiConfig: <T extends Ui>(name: T) => UIConfig[T];
10
+ setUiVisible: (name: Ui, visible: boolean | 'toggle') => void;
11
+ isUiVisible: (name: Ui) => boolean;
12
+ hideUi: (name: Ui) => void;
13
+ showUi: (name: Ui) => void;
14
+ toggleUi: (name: Ui) => void;
15
+ isPanelVisible: (name: string) => boolean;
16
+ setPanelVisible: (name: string, visible: boolean | 'toggle') => void;
17
+ hidePanel: (name: string, visible: boolean | 'toggle') => void;
18
+ showPanel: (name: string, visible: boolean | 'toggle') => void;
19
+ togglePanel: (name: string, visible: boolean | 'toggle') => void;
20
+ pointerDown: (e: PointerInputEvent, options?: PointerDownOptions) => void;
15
21
  }
16
22
  }
17
23
  }
@@ -1,21 +1,24 @@
1
1
  import type { Element2D } from 'modern-canvas';
2
2
  declare global {
3
3
  namespace Mce {
4
- type ZoomTarget = 'root' | 'selection' | Element2D | Element2D[] | number;
5
- type ZoomToMode = 'contain' | 'cover' | 'width' | 'height';
4
+ interface ViewportConfig {
5
+ zoom: ZoomConfig;
6
+ }
7
+ interface ZoomConfig {
8
+ strategy: ZoomToStrategy;
9
+ }
10
+ type ZoomToTarget = 'root' | 'selection' | Element2D | Element2D[] | number;
11
+ type ZoomToStrategy = 'cover' | 'contain' | 'containWidth' | 'containHeight';
6
12
  interface ZoomToOptions {
7
13
  intoView?: boolean;
8
- mode?: ZoomToMode;
14
+ strategy?: ZoomToStrategy;
9
15
  duration?: number;
10
16
  behavior?: 'smooth' | 'instant';
11
17
  }
12
- interface Config {
13
- zoomToFit: ZoomToMode;
14
- }
15
18
  interface Commands {
16
19
  zoomIn: () => void;
17
20
  zoomOut: () => void;
18
- zoomTo: (target: ZoomTarget, options?: ZoomToOptions) => Promise<void>;
21
+ zoomTo: (target: ZoomToTarget, options?: ZoomToOptions) => Promise<void>;
19
22
  zoomTo100: () => void;
20
23
  zoomToFit: () => void;
21
24
  zoomToSelection: (options?: ZoomToOptions) => void;
@@ -1,4 +1,5 @@
1
1
  import type { Vector2Like } from 'modern-canvas'
2
+ import type { DeepMaybe } from './types'
2
3
  import 'modern-canvas'
3
4
 
4
5
  declare module 'modern-canvas' {
@@ -18,7 +19,6 @@ declare module 'modern-canvas' {
18
19
  declare global {
19
20
  namespace Mce {
20
21
  interface Editor {}
21
- interface Options {}
22
22
  interface Slots {}
23
23
  interface Events {
24
24
  ready: []
@@ -27,6 +27,9 @@ declare global {
27
27
  interface Commands {}
28
28
  interface Exporters {}
29
29
  interface Config {}
30
+ interface Options extends DeepMaybe<Config> {
31
+ //
32
+ }
30
33
 
31
34
  type State
32
35
  = | 'loading'
@@ -18,17 +18,16 @@ import './mixins/2.export'
18
18
  import './mixins/2.load'
19
19
  import './mixins/3.view'
20
20
  import './mixins/4.0.node'
21
- import './mixins/4.1.text'
22
21
  import './mixins/4.2.frame'
23
22
  import './mixins/4.3.element'
24
- import './mixins/drawingTool'
25
23
  import './mixins/http'
24
+ import './mixins/snap'
26
25
  import './mixins/snapshot'
26
+ import './mixins/tool'
27
27
  import './plugins/arrange'
28
28
  import './plugins/autoNest'
29
29
  import './plugins/copyAs'
30
30
  import './plugins/doc'
31
- import './plugins/drawingTool'
32
31
  import './plugins/edit'
33
32
  import './plugins/formatPaint'
34
33
  import './plugins/frame'
@@ -43,13 +42,10 @@ import './plugins/layers'
43
42
  import './plugins/madeWith'
44
43
  import './plugins/memory'
45
44
  import './plugins/menu'
46
- import './plugins/move'
47
45
  import './plugins/new'
48
46
  import './plugins/node'
49
47
  import './plugins/open'
50
- import './plugins/panels'
51
48
  import './plugins/pen'
52
- import './plugins/rotate'
53
49
  import './plugins/ruler'
54
50
  import './plugins/saveAs'
55
51
  import './plugins/scroll'
@@ -61,11 +57,11 @@ import './plugins/smartSelection'
61
57
  import './plugins/state'
62
58
  import './plugins/statusbar'
63
59
  import './plugins/test'
64
- import './plugins/text'
65
60
  import './plugins/timeline'
61
+ import './plugins/tool'
66
62
  import './plugins/toolbelt'
67
63
  import './plugins/transform'
68
- import './plugins/ui'
64
+ import './plugins/typography'
69
65
  import './plugins/url'
70
66
  import './plugins/view'
71
67
  import './plugins/zoom'
@@ -0,0 +1,3 @@
1
+ export type DeepMaybe<T> = T extends Function ? T : T extends Array<infer U> ? Array<DeepMaybe<U>> | undefined : T extends object ? {
2
+ [K in keyof T]?: DeepMaybe<T[K]>;
3
+ } : T | undefined;
@@ -1 +1,2 @@
1
1
  export * from './box';
2
+ export * from './helper';
@@ -1,10 +1,31 @@
1
- export interface HandleDragOptions {
2
- threshold?: number;
3
- start?: (event: MouseEvent) => void;
4
- move?: (offset: {
1
+ export interface DragContext {
2
+ [key: string]: any;
3
+ event: MouseEvent;
4
+ dragging: boolean;
5
+ startEvent: MouseEvent;
6
+ startPoint: {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ moveEvent: MouseEvent;
11
+ movePoint: {
12
+ x: number;
13
+ y: number;
14
+ };
15
+ lastPoint: {
5
16
  x: number;
6
17
  y: number;
7
- }, event: MouseEvent) => void;
8
- end?: (event: MouseEvent) => void;
18
+ };
19
+ endEvent: MouseEvent;
20
+ endPoint: {
21
+ x: number;
22
+ y: number;
23
+ };
24
+ }
25
+ export interface DragListenerOptions<T extends DragContext> {
26
+ threshold?: number;
27
+ start?: (ctx: T) => void;
28
+ move?: (ctx: T) => void;
29
+ end?: (ctx: T) => void;
9
30
  }
10
- export declare function handleDrag(downEvent: MouseEvent, options?: HandleDragOptions): void;
31
+ export declare function addDragListener<T extends DragContext>(downEvent: MouseEvent | undefined, options?: DragListenerOptions<T>): () => void;
@@ -1,4 +1,5 @@
1
1
  import type { ComponentInternalInstance, ComponentPublicInstance, InjectionKey, VNodeChild } from 'vue';
2
+ import type { DeepMaybe } from '../types';
2
3
  export declare function noop(..._args: any): void;
3
4
  export declare function isClickInsideElement(event: MouseEvent, targetDiv: HTMLElement): boolean;
4
5
  export interface TemplateRef {
@@ -17,3 +18,4 @@ export declare function toKebabCase(str?: string): string;
17
18
  export declare namespace toKebabCase {
18
19
  var cache: Map<string, string>;
19
20
  }
21
+ export declare function deepMerge<T>(target: T, ...sources: DeepMaybe<T>[]): T;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mce",
3
3
  "type": "module",
4
- "version": "0.16.7",
4
+ "version": "0.17.0",
5
5
  "description": "A headless infinite canvas editor framework built on WebGL rendering, supports exporting to image, video, and PPT. Only the ESM.",
6
6
  "author": "wxm",
7
7
  "license": "MIT",
@@ -56,12 +56,12 @@
56
56
  ],
57
57
  "dependencies": {
58
58
  "@floating-ui/vue": "^1.1.10",
59
- "@vueuse/components": "^14.2.0",
60
- "@vueuse/core": "^14.2.0",
59
+ "@vueuse/components": "^14.2.1",
60
+ "@vueuse/core": "^14.2.1",
61
61
  "diff": "^8.0.3",
62
62
  "file-saver": "^2.0.5",
63
63
  "lodash-es": "^4.17.23",
64
- "modern-canvas": "^0.15.4",
64
+ "modern-canvas": "^0.15.5",
65
65
  "modern-font": "^0.4.4",
66
66
  "modern-idoc": "^0.10.21",
67
67
  "modern-text": "^1.10.15",
@@ -95,8 +95,8 @@
95
95
  "jiti": "^2.6.1",
96
96
  "modern-gif": "^2.0.4",
97
97
  "sass-embedded": "^1.97.3",
98
- "typedoc": "^0.28.16",
99
- "typedoc-plugin-markdown": "^4.9.0"
98
+ "typedoc": "^0.28.17",
99
+ "typedoc-plugin-markdown": "^4.10.0"
100
100
  },
101
101
  "scripts": {
102
102
  "build:code": "vite build",
@@ -1,21 +0,0 @@
1
- import type { Element2D } from 'modern-canvas';
2
- import type { NormalizedFill, NormalizedFragment } from 'modern-idoc';
3
- import type { Ref } from 'vue';
4
- declare global {
5
- namespace Mce {
6
- interface Editor {
7
- hasTextSelectionRange: Ref<boolean>;
8
- isTextAllSelected: Ref<boolean>;
9
- handleTextSelection: (textSelection: IndexCharacter[], cb: (arg: Record<string, any>) => boolean) => void;
10
- textFontSizeToFit: (element: Element2D, scale?: number) => void;
11
- textToFit: (element: Element2D, typography?: Mce.TypographyStrategy) => void;
12
- getTextStyle: (key: string) => any;
13
- setTextStyle: (key: string, value: any) => void;
14
- getTextFill: () => NormalizedFill | undefined;
15
- setTextFill: (value: NormalizedFill | undefined) => void;
16
- setTextContentByEachFragment: (handler: (fragment: NormalizedFragment) => void) => void;
17
- }
18
- }
19
- }
20
- declare const _default: import("..").Mixin;
21
- export default _default;
@@ -1,25 +0,0 @@
1
- import type { Vector2Like } from 'modern-canvas';
2
- import type { Reactive, Ref } from 'vue';
3
- declare global {
4
- namespace Mce {
5
- interface DrawingTools {
6
- }
7
- type DrawingToolHandle = (position: Vector2Like) => {
8
- move?: (position: Vector2Like) => void;
9
- end?: (position: Vector2Like) => void;
10
- } | void;
11
- interface DrawingTool {
12
- name: string;
13
- handle?: DrawingToolHandle;
14
- }
15
- interface Editor {
16
- drawingTools: Reactive<Map<string, Mce.DrawingTool>>;
17
- activeDrawingTool: Ref<Mce.DrawingTool>;
18
- registerDrawingTool: (tool: Mce.DrawingTool | Mce.DrawingTool[]) => void;
19
- unregisterDrawingTool: (tool: string) => void;
20
- setActiveDrawingTool: (tool: string | keyof DrawingTools | undefined) => void;
21
- }
22
- }
23
- }
24
- declare const _default: import("..").Mixin;
25
- export default _default;
@@ -1,20 +0,0 @@
1
- declare global {
2
- namespace Mce {
3
- type MoveCommandDirection = 'left' | 'top' | 'right' | 'bottom';
4
- interface Commands {
5
- move: (direction: MoveCommandDirection, distance?: number) => void;
6
- moveLeft: (distance?: number) => void;
7
- moveTop: (distance?: number) => void;
8
- moveRight: (distance?: number) => void;
9
- moveBottom: (distance?: number) => void;
10
- }
11
- interface Hotkeys {
12
- moveLeft: [event: KeyboardEvent];
13
- moveTop: [event: KeyboardEvent];
14
- moveRight: [event: KeyboardEvent];
15
- moveBottom: [event: KeyboardEvent];
16
- }
17
- }
18
- }
19
- declare const _default: import("..").Plugin;
20
- export default _default;
@@ -1,13 +0,0 @@
1
- declare global {
2
- namespace Mce {
3
- interface Panels {
4
- }
5
- interface Config extends Record<keyof Panels, boolean> {
6
- }
7
- interface Commands {
8
- panels: <T extends keyof Panels>(panel: T, ...args: Panels[T]) => Promise<boolean>;
9
- }
10
- }
11
- }
12
- declare const _default: import("..").Plugin;
13
- export default _default;
@@ -1,10 +0,0 @@
1
- declare global {
2
- namespace Mce {
3
- interface Commands {
4
- rotate: (deg: number) => void;
5
- rotate90: () => void;
6
- }
7
- }
8
- }
9
- declare const _default: import("..").Plugin;
10
- export default _default;
@@ -1,17 +0,0 @@
1
- import type { Element2D } from 'modern-canvas';
2
- declare global {
3
- namespace Mce {
4
- interface addTextElementOptions extends AddElementOptions {
5
- content?: string;
6
- style?: Record<string, any>;
7
- }
8
- interface Commands {
9
- addTextElement: (options?: addTextElementOptions) => Element2D;
10
- }
11
- interface DrawingTools {
12
- text: [options?: addTextElementOptions];
13
- }
14
- }
15
- }
16
- declare const _default: import("../plugin").Plugin;
17
- export default _default;
@@ -1,20 +0,0 @@
1
- import type { PointerInputEvent } from 'modern-canvas';
2
- declare global {
3
- namespace Mce {
4
- interface PointerDownOptions {
5
- allowTopFrame?: boolean;
6
- }
7
- interface Commands {
8
- pointerDown: (e: PointerInputEvent, options?: PointerDownOptions) => void;
9
- startTyping: (e?: MouseEvent | PointerEvent) => Promise<boolean>;
10
- startTransform: (e?: MouseEvent | PointerEvent) => boolean;
11
- openContextMenu: (e?: MouseEvent | PointerEvent) => boolean;
12
- layerScrollIntoView: () => boolean;
13
- }
14
- interface Events {
15
- pointerMove: [event: PointerEvent];
16
- }
17
- }
18
- }
19
- declare const _default: import("..").Plugin;
20
- export default _default;