mce 0.24.4 → 0.25.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 (66) hide show
  1. package/README.md +237 -4
  2. package/dist/components/EditorPanels.vue.d.ts +6 -0
  3. package/dist/components/Interactions.vue.d.ts +3 -0
  4. package/dist/components/shared/Cropper.vue.d.ts +5 -1
  5. package/dist/components/shared/Dialog.vue.d.ts +33 -38
  6. package/dist/components/shared/FloatPanel.vue.d.ts +4 -2
  7. package/dist/components/shared/LayoutItem.vue.d.ts +29 -0
  8. package/dist/components/shared/PanelContent.vue.d.ts +29 -0
  9. package/dist/components/timeline/EasingCurve.vue.d.ts +11 -0
  10. package/dist/components/timeline/KeyframePopover.vue.d.ts +3 -0
  11. package/dist/crdt/YDoc.d.ts +27 -2
  12. package/dist/crdt/YDoc.test.d.ts +1 -0
  13. package/dist/crdt/index.d.ts +3 -0
  14. package/dist/crdt/providers/indexeddb/IndexeddbProvider.d.ts +3 -1
  15. package/dist/crdt/reactivity.d.ts +27 -0
  16. package/dist/crdt/reactivity.test.d.ts +1 -0
  17. package/dist/crdt/vueReactivity.d.ts +8 -0
  18. package/dist/index.css +1 -1
  19. package/dist/index.d.ts +3 -0
  20. package/dist/index.js +10300 -8946
  21. package/dist/locale/en.d.ts +51 -9
  22. package/dist/locale/zh-Hans.d.ts +51 -9
  23. package/dist/mixins/0.context.d.ts +2 -0
  24. package/dist/mixins/extensions.d.ts +105 -0
  25. package/dist/mixins/panels.d.ts +46 -0
  26. package/dist/plugin.d.ts +14 -0
  27. package/dist/plugins/animate.d.ts +40 -0
  28. package/dist/plugins/components.d.ts +32 -0
  29. package/dist/plugins/flexLayout.d.ts +15 -0
  30. package/dist/plugins/history.d.ts +2 -0
  31. package/dist/plugins/interactions.d.ts +44 -0
  32. package/dist/plugins/shape.d.ts +0 -4
  33. package/dist/plugins/slice.d.ts +10 -0
  34. package/dist/plugins/smartGuides.d.ts +2 -2
  35. package/dist/plugins/timeline.d.ts +17 -0
  36. package/dist/plugins/toolbelt.d.ts +4 -0
  37. package/dist/plugins/variables.d.ts +27 -0
  38. package/dist/plugins/zoom.d.ts +2 -0
  39. package/dist/scene/Doc.d.ts +13 -1
  40. package/dist/typed-global.d.ts +6 -2
  41. package/dist/typed-plugins.d.ts +6 -3
  42. package/dist/utils/animationPresets.d.ts +27 -0
  43. package/dist/utils/components.d.ts +33 -0
  44. package/dist/utils/components.test.d.ts +1 -0
  45. package/dist/utils/create.d.ts +1 -15
  46. package/dist/utils/easing.d.ts +23 -0
  47. package/dist/utils/easing.test.d.ts +1 -0
  48. package/dist/utils/index.d.ts +8 -1
  49. package/dist/utils/keyframes.d.ts +31 -0
  50. package/dist/utils/keyframes.test.d.ts +1 -0
  51. package/dist/utils/lottie.d.ts +27 -0
  52. package/dist/utils/lottie.test.d.ts +1 -0
  53. package/dist/utils/remapTextSelection.d.ts +23 -0
  54. package/dist/utils/remapTextSelection.test.d.ts +1 -0
  55. package/dist/utils/traverse.d.ts +9 -0
  56. package/dist/utils/variables.d.ts +58 -0
  57. package/dist/utils/variables.test.d.ts +1 -0
  58. package/package.json +4 -8
  59. package/dist/plugins/html.d.ts +0 -2
  60. package/dist/plugins/table.d.ts +0 -2
  61. package/dist/plugins/workflow.d.ts +0 -31
  62. package/dist/utils/table.d.ts +0 -93
  63. package/dist/utils/workflow.d.ts +0 -9
  64. /package/dist/components/{TableEditor.vue.d.ts → Components.vue.d.ts} +0 -0
  65. /package/dist/components/{Workflow.vue.d.ts → InteractionBadges.vue.d.ts} +0 -0
  66. /package/dist/utils/{smartGuides-geometry.d.ts → smartGuidesGeometry.d.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  import type { NodeEvents } from 'modern-canvas';
2
2
  import type { Document } from 'modern-idoc';
3
- import type * as Y from 'yjs';
4
3
  import { Node } from 'modern-canvas';
4
+ import * as Y from 'yjs';
5
5
  import { YDoc } from '../crdt';
6
6
  export interface DocEvents extends NodeEvents {
7
7
  update: [update: Uint8Array, origin: any];
@@ -16,7 +16,19 @@ export interface Doc {
16
16
  export declare class Doc extends Node {
17
17
  _yDoc: YDoc;
18
18
  protected _source: any;
19
+ /** 同一同步批次内累积的增量,flush 时用 Y.mergeUpdates 合并为一条转发——零丢失替代旧的 throttle。 */
20
+ protected _pendingYUpdates: Uint8Array[];
21
+ protected _pendingYOrigin: any;
22
+ protected _yFlushScheduled: boolean;
19
23
  constructor(source?: Mce.DocumentSource);
24
+ /**
25
+ * 累积增量并安排一个 microtask 合并转发。
26
+ * - 零丢失:同步批次内的每条增量都进入缓冲,绝不丢弃(旧 throttle 会丢中间增量导致两端发散)。
27
+ * - 合并:一个事件处理器里产生的多个事务在 microtask 边界前合并成一条,降低网络包数。
28
+ * - origin 纯净:origin 变化时先 flush 旧批,避免本地 / 远端增量被合进同一条而丢失来源。
29
+ */
30
+ protected _enqueueYUpdate(update: Uint8Array, origin: any): void;
31
+ protected _flushYUpdates(): void;
20
32
  transact: <T>(fn: () => T, should?: boolean) => T;
21
33
  undo: () => any | null;
22
34
  redo: () => any | null;
@@ -35,8 +35,12 @@ declare global {
35
35
  // Persistent editor mode, orthogonal to the transient `State`. 'canvas' is
36
36
  // the free-form editing experience; 'workflow' turns the canvas into a
37
37
  // node-graph editor (directional connections, port handles).
38
- type Mode = 'canvas' | 'workflow'
38
+ // 'canvas' 为核心自由编辑模式;插件可贡献其它模式(如 @mce/workflow 的 'workflow'),
39
+ // 故联合保留 `(string & {})` 以接纳任意字符串而不丢核心字面量补全。
40
+ type Mode = 'canvas' | (string & {})
39
41
 
42
+ // 插件可贡献自己的瞬时编辑态(如 @mce/table 的 'tableEditing'),故联合里保留
43
+ // `(string & {})` 以接纳任意字符串而不丢核心字面量的自动补全。
40
44
  type State
41
45
  = | 'loading'
42
46
  | 'hand'
@@ -45,12 +49,12 @@ declare global {
45
49
  | 'moving'
46
50
  | 'transforming'
47
51
  | 'typing'
48
- | 'tableEditing'
49
52
  | 'cropping'
50
53
  | 'pathEditing'
51
54
  | 'imageReplacing'
52
55
  | 'shapeReplacing'
53
56
  | 'painting'
57
+ | (string & {})
54
58
  | undefined
55
59
 
56
60
  interface DrawingContext {
@@ -17,16 +17,20 @@ import './mixins/4.0.node'
17
17
  import './mixins/4.2.frame'
18
18
  import './mixins/4.3.element'
19
19
  import './mixins/exporter'
20
+ import './mixins/extensions'
20
21
  import './mixins/hotkey'
21
22
  import './mixins/http'
22
23
  import './mixins/loader'
24
+ import './mixins/panels'
23
25
  import './mixins/snapper'
24
26
  import './mixins/snapshot'
25
27
  import './mixins/strategy'
26
28
  import './mixins/tool'
29
+ import './plugins/animate'
27
30
  import './plugins/arrange'
28
31
  import './plugins/autoNest'
29
32
  import './plugins/clipboard'
33
+ import './plugins/components'
30
34
  import './plugins/doc'
31
35
  import './plugins/edit'
32
36
  import './plugins/flexLayout'
@@ -34,9 +38,9 @@ import './plugins/formatPaint'
34
38
  import './plugins/frame'
35
39
  import './plugins/history'
36
40
  import './plugins/hover'
37
- import './plugins/html'
38
41
  import './plugins/image'
39
42
  import './plugins/import'
43
+ import './plugins/interactions'
40
44
  import './plugins/json'
41
45
  import './plugins/layers'
42
46
  import './plugins/madeWith'
@@ -54,7 +58,6 @@ import './plugins/smartGuides'
54
58
  import './plugins/smartSelection'
55
59
  import './plugins/state'
56
60
  import './plugins/statusbar'
57
- import './plugins/table'
58
61
  import './plugins/test'
59
62
  import './plugins/timeline'
60
63
  import './plugins/tool'
@@ -62,8 +65,8 @@ import './plugins/toolbelt'
62
65
  import './plugins/transform'
63
66
  import './plugins/typography'
64
67
  import './plugins/url'
68
+ import './plugins/variables'
65
69
  import './plugins/view'
66
- import './plugins/workflow'
67
70
  import './plugins/zoom'
68
71
 
69
72
  export {}
@@ -0,0 +1,27 @@
1
+ import type { Keyframe } from './keyframes';
2
+ /**
3
+ * 预设动画库(纯数据 / 纯函数)。每个预设按元素「当前基础样式」生成扁平关键帧
4
+ * (而非写死绝对值),分为进入 / 退出 / 强调三类。利用 modern-canvas Animation 的
5
+ * 两端填充特性:进入动画收尾停在基础值、退出动画收尾保持终值,无需额外 fill 配置。
6
+ */
7
+ export type PresetCategory = 'in' | 'out' | 'emphasis';
8
+ export interface PresetChannels {
9
+ left: number;
10
+ top: number;
11
+ rotate: number;
12
+ scaleX: number;
13
+ scaleY: number;
14
+ opacity: number;
15
+ }
16
+ export interface AnimationPreset {
17
+ id: string;
18
+ category: PresetCategory;
19
+ /** 默认时长(ms)。 */
20
+ duration: number;
21
+ /** 强调类通常循环。 */
22
+ loop?: boolean;
23
+ /** 依据元素基础样式生成关键帧。 */
24
+ build: (base: PresetChannels) => Keyframe[];
25
+ }
26
+ export declare const ANIMATION_PRESETS: AnimationPreset[];
27
+ export declare function getPreset(id: string): AnimationPreset | undefined;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * 组件 / 符号 / 实例系统的纯逻辑层(参考 components:master + instances + overrides)。
3
+ *
4
+ * - master 定义:一棵节点子树的 JSON 快照(node.toJSON())。
5
+ * - instance:从 master 克隆出的子树,记录 componentId 与一组路径级 override。
6
+ * - 传播:master 更新后,实例 = 重新实例化(master) 再叠加各自 override。
7
+ *
8
+ * 纯函数、无编辑器耦合,可独立单测;插件层负责存储、克隆入画布与传播。
9
+ */
10
+ export interface ComponentDef {
11
+ id: string;
12
+ name: string;
13
+ /** master 节点 JSON(来自 node.toJSON())。 */
14
+ node: any;
15
+ }
16
+ /** 实例覆盖:节点 JSON 内的路径(lodash 路径,如 'style.fill'、'children.0.text.content')→ 值。 */
17
+ export type InstanceOverrides = Record<string, any>;
18
+ /**
19
+ * 递归剥离子树里的 id,使实例化后每个节点都获得新 id。
20
+ * (addElement 的 regenId 只清顶层 id,子节点 id 会冲突。)
21
+ */
22
+ export declare function stripNodeIds<T>(node: T): T;
23
+ /**
24
+ * 按 path → value 应用一组覆盖。返回新对象,不改输入。
25
+ * 值为普通对象时与原值**深合并**(便于只覆盖 `style` 的部分字段而不丢其余);
26
+ * 基本类型 / 数组则整值替换。
27
+ */
28
+ export declare function applyOverrides<T>(node: T, overrides?: InstanceOverrides): T;
29
+ /**
30
+ * 从 master 定义实例化一份节点 JSON:先剥 id(保证新实例独立),再叠加 override。
31
+ * 返回的 JSON 交给 addElement(regenId) 落入画布。
32
+ */
33
+ export declare function instantiateComponent(def: ComponentDef, overrides?: InstanceOverrides): any;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { Chart, ChartType, Element, Fill, Outline, ShapeConnectionPoint } from 'modern-idoc';
1
+ import type { Element, Fill, Outline, ShapeConnectionPoint } from 'modern-idoc';
2
2
  import type { Options } from 'modern-text';
3
3
  export declare function createShapeElement(shape?: Element['shape'], fill?: Fill, outline?: Outline): Element;
4
4
  export declare function createTextElement(content: string, style?: Record<string, any>, fonts?: Options['fonts']): Element;
@@ -46,17 +46,3 @@ export interface CreateStickyElementOptions {
46
46
  }
47
47
  /** A solid colored note with top-aligned text, e.g. for whiteboard annotations. */
48
48
  export declare function createStickyElement(content: string, options?: CreateStickyElementOptions): Element;
49
- export interface CreateTableElementOptions {
50
- width?: number;
51
- height?: number;
52
- }
53
- /** A grid table backed by the native `table` element property; first row is a header. */
54
- export declare function createTableElement(rows?: number, cols?: number, options?: CreateTableElementOptions): Element;
55
- export interface CreateChartElementOptions {
56
- width?: number;
57
- height?: number;
58
- categories?: string[];
59
- series?: Chart['series'];
60
- }
61
- /** A chart backed by the native `chart` element property (column/line/pie/…). */
62
- export declare function createChartElement(type?: ChartType, options?: CreateChartElementOptions): Element;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 可复用缓动(easing)纯逻辑层。
3
+ *
4
+ * 与 modern-canvas Animation 的 easing 表示兼容(命名预设或 'cubic-bezier(...)' 字符串)。
5
+ * 这里额外提供:cubic-bezier 求值器(用于关键帧采样 / Lottie 导出预览)、命名预设表、
6
+ * 以及「自定义缓动注册表」解析(Jitter 式可复用缓动)。纯函数,可独立单测。
7
+ */
8
+ export type EasingCoords = [number, number, number, number];
9
+ /**
10
+ * 命名缓动预设 → cubic-bezier 控制点。
11
+ * 键名用 CSS 缓动写法,与 modern-canvas 内置缓动一致(关键帧里直接存这些名字引擎即可识别);
12
+ * 更复杂的曲线用 cubic-bezier 字符串。
13
+ */
14
+ export declare const EASING_PRESETS: Record<string, EasingCoords>;
15
+ /**
16
+ * 把 easing 表示解析为 cubic-bezier 控制点。
17
+ * 接受:命名预设、'cubic-bezier(...)' 字符串、或自定义注册表里的名字。无法解析 → linear。
18
+ */
19
+ export declare function parseEasing(easing: string | undefined, custom?: Record<string, string>): EasingCoords;
20
+ /** 由控制点构造 cubic-bezier 求值函数:输入进度 x∈[0,1],返回缓动后的 y。 */
21
+ export declare function cubicBezierEasing([x1, y1, x2, y2]: EasingCoords): (x: number) => number;
22
+ /** 直接对进度 t∈[0,1] 求缓动值。 */
23
+ export declare function evalEasing(easing: string | undefined, t: number, custom?: Record<string, string>): number;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,18 @@
1
+ export * from './animationPresets';
1
2
  export * from './arrow';
2
3
  export * from './box';
4
+ export * from './components';
3
5
  export * from './console';
4
6
  export * from './constants';
5
7
  export * from './create';
6
8
  export * from './dnd';
9
+ export * from './easing';
7
10
  export * from './helper';
8
11
  export * from './image';
12
+ export * from './keyframes';
13
+ export * from './lottie';
9
14
  export * from './propsFactory';
15
+ export * from './remapTextSelection';
10
16
  export * from './saveAs';
11
- export * from './table';
17
+ export * from './traverse';
18
+ export * from './variables';
@@ -0,0 +1,31 @@
1
+ /**
2
+ * 关键帧编辑纯逻辑层,与 modern-canvas Animation 的关键帧表示一致:关键帧是「扁平」结构
3
+ * —— { offset: 0..1, easing?, <styleProp>: value, ... },除 offset / easing 外的键即动画属性
4
+ * (modern-canvas 归一化时按 rest 收集这些键)。提供数组级 CRUD(不可变)与按进度采样插值,
5
+ * 供编辑面板与 Lottie 导出复用。纯函数,可独立单测。
6
+ */
7
+ export interface Keyframe {
8
+ /** 归一化时间点 0..1。 */
9
+ offset: number;
10
+ /** 命名预设 / cubic-bezier 字符串 / 自定义缓动名;缺省 linear。 */
11
+ easing?: string;
12
+ /** 其余键为该关键帧上的样式属性快照(如 left / top / rotate / scaleX / scaleY / opacity)。 */
13
+ [prop: string]: number | string | undefined;
14
+ }
15
+ /** 取出关键帧上的动画属性键(排除 offset / easing)。 */
16
+ export declare function keyframePropKeys(kf: Keyframe): string[];
17
+ /** 取出关键帧上的动画属性快照(不含 offset / easing)。 */
18
+ export declare function keyframeProps(kf: Keyframe): Record<string, any>;
19
+ export declare function sortKeyframes(keyframes: Keyframe[]): Keyframe[];
20
+ /** 插入或替换同 offset 的关键帧(合并属性),返回排序后的新数组。 */
21
+ export declare function upsertKeyframe(keyframes: Keyframe[], kf: Keyframe): Keyframe[];
22
+ export declare function removeKeyframeAt(keyframes: Keyframe[], offset: number): Keyframe[];
23
+ export declare function updateKeyframeProps(keyframes: Keyframe[], offset: number, props: Record<string, any>): Keyframe[];
24
+ export declare function setKeyframeEasing(keyframes: Keyframe[], offset: number, easing: string): Keyframe[];
25
+ /**
26
+ * 在进度 t∈[0,1] 处采样属性值。对每个属性在「t 所在区间」的左右关键帧之间插值,
27
+ * 区间缓动取**左关键帧**的 easing(与 CSS/Lottie 的「段缓动属于起点」一致);数值线性插值,
28
+ * 非数值用阶梯(取左值)。返回该时刻所有出现过的属性的值(不含 offset / easing)。
29
+ * custom 为自定义缓动注册表(名字 → cubic-bezier 字符串)。
30
+ */
31
+ export declare function sampleKeyframes(keyframes: Keyframe[], t: number, custom?: Record<string, string>): Record<string, any>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { Keyframe } from './keyframes';
2
+ /**
3
+ * 关键帧动画 → Lottie JSON 构建器(纯函数)。
4
+ *
5
+ * 限定到 transform / opacity 通道(position / rotation / scale / opacity)——这是画布动画里
6
+ * 最常见、也最能跨工具复用的部分;不导出形状几何(shapes 留空)。每个动画元素映射为一个
7
+ * Lottie layer,关键帧的 easing 转成 Lottie 的贝塞尔 in/out 手柄。结构层面可单测。
8
+ */
9
+ export interface LottieLayerInput {
10
+ name?: string;
11
+ width: number;
12
+ height: number;
13
+ /** 关键帧可含 left/top/opacity/rotate/scaleX/scaleY 等扁平属性。 */
14
+ keyframes: Keyframe[];
15
+ /** 未被关键帧覆盖的通道用此回退值(left/top/opacity/rotate/scaleX/scaleY)。 */
16
+ base?: Record<string, number>;
17
+ }
18
+ export interface LottieCompositionInput {
19
+ width: number;
20
+ height: number;
21
+ fps?: number;
22
+ durationMs: number;
23
+ layers: LottieLayerInput[];
24
+ /** 自定义缓动注册表(名字 → cubic-bezier 字符串)。 */
25
+ custom?: Record<string, string>;
26
+ }
27
+ export declare function buildLottie(comp: LottieCompositionInput): object;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { NormalizedTextContent } from 'modern-idoc';
2
+ /**
3
+ * 文本选区指针在内容结构里的逻辑定位(段 / 片段 / 段内字符)。
4
+ * 与 web-components 的 IndexCharacter 兼容,但只取逻辑字段以保持纯函数无渲染耦合。
5
+ */
6
+ export interface TextPointer {
7
+ paragraphIndex: number;
8
+ fragmentIndex: number;
9
+ charIndex: number;
10
+ }
11
+ /** 指针在其所属段落内的绝对字符偏移。 */
12
+ export declare function paragraphCharOffset(content: NormalizedTextContent, p: TextPointer): number;
13
+ /** 把段内绝对偏移映射回某结构下的 (fragmentIndex, charIndex)。 */
14
+ export declare function offsetToPointer(content: NormalizedTextContent, paragraphIndex: number, offset: number): {
15
+ fragmentIndex: number;
16
+ charIndex: number;
17
+ };
18
+ /**
19
+ * 设置样式时片段会按相同样式重新分组(字符与字形位置不变,仅 fragment 边界变化),
20
+ * 旧选区指针的 fragmentIndex 因此失效。此函数按「段内绝对字符偏移」把一对指针重映射到
21
+ * 新片段结构,保留指针的其余字段(含渲染坐标——它们仍然有效,因为字形位置未变)。
22
+ */
23
+ export declare function remapTextSelection<T extends TextPointer>(oldContent: NormalizedTextContent, newContent: NormalizedTextContent, selection: [T, T]): [T, T];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { Node } from 'modern-canvas';
2
+ /**
3
+ * 深度遍历节点(含内部层),对每个节点执行 cb。
4
+ *
5
+ * 关键:用 `getChildren(true)` 而非 `children`。表格单元格等内容被放在 `back` 内部层、
6
+ * 不进 `children` / `toJSON`,常规 `children` 遍历会漏。凡是「必须覆盖全部内容」的操作
7
+ * (字体重排、导出、查找、序列化前处理)都应走这里,否则表格内容会被静默漏掉。
8
+ */
9
+ export declare function eachElement(node: Node, cb: (node: Node) => void): void;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * 设计令牌 / 变量系统的纯逻辑层(参考 variables:collections + modes)。
3
+ *
4
+ * 一个 collection 含多个 mode(如「亮 / 暗」「手机 / 桌面」);每个变量按 mode 存值,
5
+ * 值可以是字面量,也可以是指向另一变量的别名(alias)。解析在变量所属 collection 的
6
+ * mode 内进行,支持跨 collection 别名与环检测。纯函数、无编辑器耦合,可独立单测;
7
+ * 插件层负责把状态存进文档并把解析结果应用到画布。
8
+ */
9
+ export type VariableType = 'color' | 'number' | 'string' | 'boolean';
10
+ export interface VariableAlias {
11
+ type: 'alias';
12
+ id: string;
13
+ }
14
+ export type VariableLiteral = string | number | boolean;
15
+ export type VariableValue = VariableLiteral | VariableAlias;
16
+ export interface VariableMode {
17
+ id: string;
18
+ name: string;
19
+ }
20
+ export interface Variable {
21
+ id: string;
22
+ name: string;
23
+ type: VariableType;
24
+ /** 按 mode id 存值。 */
25
+ valuesByMode: Record<string, VariableValue>;
26
+ }
27
+ export interface VariableCollection {
28
+ id: string;
29
+ name: string;
30
+ modes: VariableMode[];
31
+ defaultModeId: string;
32
+ variables: Variable[];
33
+ }
34
+ export interface VariablesState {
35
+ collections: VariableCollection[];
36
+ }
37
+ export declare function createVariablesState(): VariablesState;
38
+ export declare function isVariableAlias(v: unknown): v is VariableAlias;
39
+ /** 变量所属的 collection(用于查它该用哪个 active mode)。 */
40
+ export declare function getVariableCollection(state: VariablesState, variableId: string): VariableCollection | undefined;
41
+ /**
42
+ * 把变量解析为字面量值。modeId 在变量所属 collection 内解释(不存在则回退该 collection
43
+ * 的 defaultMode);别名递归解析并做环检测,遇环 / 缺值返回 undefined。
44
+ */
45
+ export declare function resolveVariable(state: VariablesState, variableId: string, modeId?: string, seen?: Set<string>): VariableLiteral | undefined;
46
+ export declare function addCollection(state: VariablesState, input: {
47
+ id: string;
48
+ name: string;
49
+ mode: VariableMode;
50
+ }): VariablesState;
51
+ export declare function addMode(state: VariablesState, collectionId: string, mode: VariableMode): VariablesState;
52
+ export declare function addVariable(state: VariablesState, collectionId: string, variable: {
53
+ id: string;
54
+ name: string;
55
+ type: VariableType;
56
+ value: VariableValue;
57
+ }): VariablesState;
58
+ export declare function setVariableValue(state: VariablesState, variableId: string, modeId: string, value: VariableValue): VariablesState;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mce",
3
3
  "type": "module",
4
- "version": "0.24.4",
4
+ "version": "0.25.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",
@@ -60,15 +60,14 @@
60
60
  "@vueuse/core": "^14.3.0",
61
61
  "diff": "^9.0.0",
62
62
  "lodash-es": "^4.18.1",
63
- "modern-canvas": "^0.23.8",
64
- "modern-font": "^0.6.0",
65
- "modern-idoc": "^0.11.9",
63
+ "modern-canvas": "^0.24.1",
64
+ "modern-font": "^0.6.1",
65
+ "modern-idoc": "^0.12.0",
66
66
  "modern-text": "^2.0.6",
67
67
  "y-protocols": "^1.0.7",
68
68
  "yjs": "^13.6.31"
69
69
  },
70
70
  "peerDependencies": {
71
- "echarts": "^5 || ^6",
72
71
  "lottie-web": "^5",
73
72
  "modern-gif": "^2",
74
73
  "typescript": ">=4.7",
@@ -76,9 +75,6 @@
76
75
  "yoga-layout": "^3"
77
76
  },
78
77
  "peerDependenciesMeta": {
79
- "echarts": {
80
- "optional": true
81
- },
82
78
  "lottie-web": {
83
79
  "optional": true
84
80
  },
@@ -1,2 +0,0 @@
1
- declare const _default: import("..").Plugin;
2
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: import("../plugin").Plugin;
2
- export default _default;
@@ -1,31 +0,0 @@
1
- import type { Element2D } from 'modern-canvas';
2
- declare global {
3
- namespace Mce {
4
- interface WorkflowNodeTemplate {
5
- /**
6
- * 覆盖节点名(写入 node.name)。不设时图层名走 i18n(key:workflow:<type>),
7
- * 切换语言即时生效;菜单项始终走 i18n。
8
- */
9
- label?: string;
10
- /** Bold first line shown inside the node. */
11
- title?: string;
12
- /** Gray hint paragraphs under the title. */
13
- body?: string[];
14
- /**
15
- * 默认占位图。设置后节点渲染这张图片而非 title/body 文字
16
- * (图片/视频生成节点用它呈现一张默认图)。
17
- */
18
- image?: string;
19
- }
20
- interface Options {
21
- /** Override/extend the workflow node content templates, keyed by node type. */
22
- workflowNodes?: Record<string, WorkflowNodeTemplate>;
23
- }
24
- interface Commands {
25
- addWorkflowNode: (type: string, position?: AddElementPosition) => Element2D;
26
- addWorkflowConnection: (startId: string, startIdx: number, endId: string, endIdx: number) => Element2D;
27
- }
28
- }
29
- }
30
- declare const _default: import("../plugin").Plugin;
31
- export default _default;
@@ -1,93 +0,0 @@
1
- import type { NormalizedTable, Table } from 'modern-idoc';
2
- /**
3
- * A mutable, editor-side mirror of an idoc table. It intentionally keeps the
4
- * same shape as {@link NormalizedTable} (flat `cells[]` keyed by `row`/`col`
5
- * with optional `rowSpan`/`colSpan`) so it can be written straight back via
6
- * `Element2DTable.setProperties()`.
7
- */
8
- export interface TableModelCell {
9
- row: number;
10
- col: number;
11
- rowSpan?: number;
12
- colSpan?: number;
13
- children?: any[];
14
- background?: any;
15
- style?: any;
16
- }
17
- export interface TableModel {
18
- columns: {
19
- width: number;
20
- }[];
21
- rows: {
22
- height: number;
23
- }[];
24
- cells: TableModelCell[];
25
- }
26
- export interface CellPos {
27
- row: number;
28
- col: number;
29
- }
30
- export interface CellRange {
31
- minRow: number;
32
- minCol: number;
33
- maxRow: number;
34
- maxCol: number;
35
- }
36
- export interface CellRect {
37
- left: number;
38
- top: number;
39
- width: number;
40
- height: number;
41
- }
42
- /** White cell fill so the canvas renders a solid table (not a transparent grid). */
43
- export declare const CELL_BACKGROUND = "#ffffff";
44
- /** 1px gridline drawn by the canvas on each cell. */
45
- export declare const CELL_BORDER_STYLE: {
46
- readonly borderColor: "#e5e7eb";
47
- readonly borderWidth: 1;
48
- readonly borderStyle: "solid";
49
- readonly boxSizing: "border-box";
50
- };
51
- export declare function defaultTextStyle(header?: boolean): any;
52
- /**
53
- * Build a fresh cell child. The text element is given a `width`/`height` to fill
54
- * its cell at render time (see {@link modelToTable}) so `verticalAlign` centers
55
- * the text — the canvas has no flex/percent path that does this otherwise.
56
- */
57
- export declare function createCellChild(text?: string, refStyle?: any): any;
58
- /** Deep-clone a live (normalized) table into an editable model. */
59
- export declare function cloneTableModel(table: Pick<NormalizedTable, 'columns' | 'rows' | 'cells'>): TableModel;
60
- /**
61
- * Serialise the model into the shape `Element2DTable.setProperties` accepts,
62
- * sizing each cell's text child to its (possibly merged) cell rect so the
63
- * canvas vertically/horizontally centers the text.
64
- */
65
- export declare function modelToTable(model: TableModel): Table;
66
- export declare function gridWidth(model: TableModel): number;
67
- export declare function gridHeight(model: TableModel): number;
68
- export declare function colLeft(model: TableModel, col: number): number;
69
- export declare function rowTop(model: TableModel, row: number): number;
70
- export declare function cellRowSpan(cell: TableModelCell): number;
71
- export declare function cellColSpan(cell: TableModelCell): number;
72
- /** Pixel rect (relative to the table's top-left) for an anchor cell. */
73
- export declare function getCellRect(model: TableModel, cell: TableModelCell): CellRect;
74
- export declare function cellRange(cell: TableModelCell): CellRange;
75
- /** Map every covered grid position `"row:col"` to its anchor cell. */
76
- export declare function buildCoverage(model: TableModel): Map<string, TableModelCell>;
77
- export declare function getCellAt(model: TableModel, row: number, col: number): TableModelCell | undefined;
78
- export declare function getCellText(cell: TableModelCell | undefined): string;
79
- export declare function setCellText(cell: TableModelCell, text: string): void;
80
- /**
81
- * Expand a raw selection so it never cuts through a merged cell — any cell
82
- * whose span overlaps the range pulls the range out to cover it fully.
83
- */
84
- export declare function normalizeRange(model: TableModel, range: CellRange): CellRange;
85
- export declare function insertRow(model: TableModel, index: number): void;
86
- export declare function insertColumn(model: TableModel, index: number): void;
87
- export declare function removeRow(model: TableModel, index: number): void;
88
- export declare function removeColumn(model: TableModel, index: number): void;
89
- /** Merge a (normalized) range into its top-left cell, dropping the rest. */
90
- export declare function mergeRange(model: TableModel, range: CellRange): TableModelCell | undefined;
91
- /** Reset a merged cell back to 1×1, re-filling the freed positions. */
92
- export declare function splitCell(model: TableModel, cell: TableModelCell): void;
93
- export declare function isMergedCell(cell: TableModelCell): boolean;
@@ -1,9 +0,0 @@
1
- import type { Element2D } from 'modern-canvas';
2
- import type { ShapeConnectionPoint } from 'modern-idoc';
3
- export interface WorkflowPort extends ShapeConnectionPoint {
4
- kind: 'input' | 'output';
5
- }
6
- export declare const INPUT_PORT: WorkflowPort;
7
- export declare const OUTPUT_PORT: WorkflowPort;
8
- export declare function getWorkflowPorts(el: Element2D): WorkflowPort[];
9
- export declare function toConnectionPoints(ports: WorkflowPort[]): ShapeConnectionPoint[];