mce 0.14.1 → 0.14.3

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.
@@ -1,5 +1,6 @@
1
1
  declare const _default: {
2
2
  cancel: string;
3
+ create: string;
3
4
  constrainToAxis: string;
4
5
  loading: string;
5
6
  drawing: string;
@@ -38,6 +39,7 @@ declare const _default: {
38
39
  'saveAs:pdf': string;
39
40
  'saveAs:pptx': string;
40
41
  'saveAs:json': string;
42
+ addSubNode: string;
41
43
  edit: string;
42
44
  undo: string;
43
45
  redo: string;
@@ -66,6 +68,8 @@ declare const _default: {
66
68
  'panels:layers': string;
67
69
  'panels:timeline': string;
68
70
  'panels:statusbar': string;
71
+ 'panels:nodeCreator': string;
72
+ nodeCreator: string;
69
73
  toolbelt: string;
70
74
  msaa: string;
71
75
  pixelate: string;
@@ -1,5 +1,6 @@
1
1
  declare const _default: {
2
2
  cancel: string;
3
+ create: string;
3
4
  constrainToAxis: string;
4
5
  loading: string;
5
6
  drawing: string;
@@ -39,6 +40,7 @@ declare const _default: {
39
40
  'saveAs:pdf': string;
40
41
  'saveAs:pptx': string;
41
42
  'saveAs:json': string;
43
+ addSubNode: string;
42
44
  edit: string;
43
45
  undo: string;
44
46
  redo: string;
@@ -67,6 +69,8 @@ declare const _default: {
67
69
  'panels:layers': string;
68
70
  'panels:statusbar': string;
69
71
  'panels:timeline': string;
72
+ 'panels:nodeCreator': string;
73
+ nodeCreator: string;
70
74
  toolbelt: string;
71
75
  msaa: string;
72
76
  pixelate: string;
@@ -30,6 +30,7 @@ declare global {
30
30
  drawboardDom: Ref<HTMLElement | undefined>;
31
31
  drawboardAabb: Ref<AxisAlignedBoundingBox>;
32
32
  drawboardPointer: Ref<Vector2Data | undefined>;
33
+ drawboardContextMenuPointer: Ref<Vector2Data | undefined>;
33
34
  doc: Ref<Doc>;
34
35
  root: ComputedRef<Node>;
35
36
  nodes: Ref<Node[]>;
@@ -0,0 +1,17 @@
1
+ import type { Node } from 'modern-canvas';
2
+ import type { Element } from 'modern-idoc';
3
+ declare global {
4
+ namespace Mce {
5
+ interface AddNodeOptions {
6
+ parent?: Node;
7
+ index?: number;
8
+ active?: boolean;
9
+ regenId?: boolean;
10
+ }
11
+ interface Editor {
12
+ addNode: (value: Element, options?: AddNodeOptions) => Node;
13
+ }
14
+ }
15
+ }
16
+ declare const _default: import("..").Mixin;
17
+ export default _default;
@@ -0,0 +1 @@
1
+ export declare const mixins: import("..").Mixin[];
@@ -4,19 +4,19 @@ import type { ModelEvents } from './Model';
4
4
  import { Node } from 'modern-canvas';
5
5
  import * as Y from 'yjs';
6
6
  import { Model } from './Model';
7
- interface AddElementOptions {
7
+ interface AddNodeOptions {
8
8
  parentId?: string;
9
9
  index?: number;
10
10
  regenId?: boolean;
11
11
  }
12
- export type YElement = Y.Map<unknown> & {
12
+ export type YNode = Y.Map<unknown> & {
13
13
  get: ((prop: 'id') => string) & ((prop: 'name') => string) & ((prop: 'parentId') => string) & ((prop: 'style') => Y.Map<unknown>) & ((prop: 'background') => Y.Map<unknown>) & ((prop: 'shape') => Y.Map<unknown>) & ((prop: 'fill') => Y.Map<unknown>) & ((prop: 'outline') => Y.Map<unknown>) & ((prop: 'text') => Y.Map<unknown>) & ((prop: 'foreground') => Y.Map<unknown>) & ((prop: 'shadow') => Y.Map<unknown>) & ((prop: 'meta') => Y.Map<unknown>) & ((prop: 'childrenIds') => Y.Array<string>) & (<T = unknown>(prop: string) => T);
14
14
  };
15
- export interface YElementResult {
15
+ export interface YNodeResult {
16
16
  id: string;
17
- element: YElement;
17
+ node: YNode;
18
18
  }
19
- export declare function iElementToYElements(element: Element, parentId: string | undefined, regenId?: boolean): YElementResult[];
19
+ export declare function iElementToYNodes(element: Element, parentId: string | undefined, regenId?: boolean): YNodeResult[];
20
20
  export interface DocEvents extends ModelEvents {
21
21
  history: [arg0: Y.UndoManager];
22
22
  }
@@ -27,11 +27,11 @@ export interface Doc {
27
27
  emit: <K extends keyof DocEvents & string>(event: K, ...args: DocEvents[K]) => this;
28
28
  }
29
29
  export declare class Doc extends Model {
30
- _yChildren: Y.Map<YElement>;
31
- _yChildrenIds: Y.Array<string>;
30
+ protected _yChildren: Y.Map<YNode>;
31
+ protected _yChildrenIds: Y.Array<string>;
32
32
  name: string;
33
33
  readonly root: Node;
34
- nodeMap: Map<string, Node>;
34
+ protected _nodeMap: Map<string, Node>;
35
35
  get meta(): import("modern-canvas").Meta;
36
36
  set meta(val: import("modern-canvas").Meta);
37
37
  constructor(id?: string);
@@ -41,17 +41,18 @@ export declare class Doc extends Model {
41
41
  protected _debug(..._args: any[]): void;
42
42
  protected _onChildrenChange(event: Y.YMapEvent<Y.Map<unknown>>, transaction: Y.Transaction): void;
43
43
  reset(): this;
44
- protected _addElement(element: Element, options?: AddElementOptions): Node;
45
- addElement(element: Element, options?: AddElementOptions): Node;
46
- addElements(elements: Element[], options?: AddElementOptions): Node[];
44
+ protected _addNode(node: Element, options?: AddNodeOptions): Node;
45
+ addNode(node: Element, options?: AddNodeOptions): Node;
46
+ addNodes(nodes: Element[], options?: AddNodeOptions): Node[];
47
47
  set(source: Document): this;
48
- protected _deleteElement(id: string): void;
49
- deleteElement(id: string): void;
50
- moveElement(id: string, toIndex: number): void;
48
+ protected _deleteNode(id: string): void;
49
+ deleteNode(id: string): void;
50
+ getNode<T extends Node = Node>(id: string): T | undefined;
51
+ moveNode(id: string, toIndex: number): void;
51
52
  protected _proxyProps(obj: CoreObject, yMap: Y.Map<any>, isMeta?: boolean): void;
52
53
  protected _proxyChildren(node: Node, childrenIds: Y.Array<string>): void;
53
- protected _proxyNode(node: Node, yEle: YElement): void;
54
- protected _getOrCreateNode(yNode: YElement): Node;
54
+ protected _proxyNode(node: Node, yEle: YNode): void;
55
+ protected _getOrCreateNode(yNode: YNode): Node;
55
56
  toJSON(): Record<string, any>;
56
57
  }
57
58
  export {};
@@ -0,0 +1 @@
1
+ export declare const plugins: import("..").Plugin[];
@@ -0,0 +1,12 @@
1
+ declare global {
2
+ namespace Mce {
3
+ interface Commands {
4
+ addSubNode: () => void;
5
+ }
6
+ interface Config {
7
+ nodeCreator: boolean;
8
+ }
9
+ }
10
+ }
11
+ declare const _default: import("../plugin").Plugin;
12
+ export default _default;
@@ -17,7 +17,8 @@ import './mixins/2.box'
17
17
  import './mixins/2.export'
18
18
  import './mixins/2.load'
19
19
  import './mixins/3.view'
20
- import './mixins/4.0.text'
20
+ import './mixins/4.0.node'
21
+ import './mixins/4.1.text'
21
22
  import './mixins/4.2.element'
22
23
  import './mixins/4.3.frame'
23
24
  import './mixins/4.4.doc'
@@ -48,6 +49,7 @@ import './plugins/madeWith'
48
49
  import './plugins/menu'
49
50
  import './plugins/move'
50
51
  import './plugins/new'
52
+ import './plugins/node'
51
53
  import './plugins/open'
52
54
  import './plugins/panels'
53
55
  import './plugins/pen'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mce",
3
3
  "type": "module",
4
- "version": "0.14.1",
4
+ "version": "0.14.3",
5
5
  "description": "The headless canvas editor framework. only the ESM.",
6
6
  "author": "wxm",
7
7
  "license": "MIT",
@@ -61,7 +61,7 @@
61
61
  "diff": "^8.0.2",
62
62
  "file-saver": "^2.0.5",
63
63
  "lodash-es": "^4.17.21",
64
- "modern-canvas": "^0.14.3",
64
+ "modern-canvas": "^0.14.5",
65
65
  "modern-font": "^0.4.4",
66
66
  "modern-idoc": "^0.10.6",
67
67
  "modern-text": "^1.10.4",
package/dist/mixins.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const mixins: import("./mixin").Mixin[];
package/dist/plugins.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const plugins: import("./plugin").Plugin[];
File without changes