@tmagic/editor 1.8.3 → 1.8.4-beta.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/types/index.d.ts CHANGED
@@ -1865,8 +1865,20 @@ export interface StageOptions {
1865
1865
  */
1866
1866
  disabledFlashTip?: boolean;
1867
1867
  zoom?: number;
1868
+ /** 画布 iframe 的 sandbox 属性值,不传 / false 表示不设置,见 @tmagic/stage 的 StageRenderConfig.iframeSandbox */
1869
+ iframeSandbox?: string | false;
1868
1870
  /** 画布双击前的钩子函数,返回 false 则阻止默认的双击行为 */
1869
1871
  beforeDblclick?: (event: MouseEvent) => Promise<boolean | void> | boolean | void;
1872
+ /**
1873
+ * 点击组件列表新增组件前的钩子,详见 EditorProps.beforeAppendComponent。
1874
+ * 仅点击新增时调用;返回 false 取消新增,支持异步。
1875
+ */
1876
+ beforeAppendComponent?: BeforeAppendComponent;
1877
+ /**
1878
+ * 组件列表拖入画布、写入节点前的钩子,详见 EditorProps.beforeDropComponent。
1879
+ * 仅 dragType 为组件列表时调用;返回 false 取消本次拖入,支持异步。
1880
+ */
1881
+ beforeDropComponent?: BeforeDropComponent;
1870
1882
  }
1871
1883
  /**
1872
1884
  * 节点校验错误信息,按来源(属性表单 / 样式表单)分别保存错误文案。
@@ -2238,6 +2250,16 @@ export interface ComponentItem {
2238
2250
  [key: string]: any;
2239
2251
  };
2240
2252
  }
2253
+ /**
2254
+ * 点击组件列表新增组件前的钩子。
2255
+ * 入参为当前组件列表项,允许异步;返回 false 时取消本次新增。
2256
+ */
2257
+ export type BeforeAppendComponent = (item: ComponentItem) => boolean | void | Promise<boolean | void>;
2258
+ /**
2259
+ * 组件列表拖入画布、写入节点前的钩子。
2260
+ * 入参为即将新增的节点和父节点,允许异步;返回 false 时取消本次拖入。
2261
+ */
2262
+ export type BeforeDropComponent = (dragData: AddMNode, parent: MContainer) => boolean | void | Promise<boolean | void>;
2241
2263
  export interface ComponentGroup {
2242
2264
  /** 显示文案 */
2243
2265
  title: string;
@@ -3792,6 +3814,16 @@ interface EditorProps {
3792
3814
  runtimeUrl?: string;
3793
3815
  /** 是用iframe渲染还是直接渲染 */
3794
3816
  renderType?: RenderType;
3817
+ /**
3818
+ * 画布 iframe 的 sandbox 属性值(仅 iframe 渲染时生效)
3819
+ *
3820
+ * - 不传 / `false`:不设置 sandbox 属性(默认)
3821
+ * - 字符串:原样写入,token 空格分隔,如 `'allow-scripts allow-same-origin allow-downloads'`
3822
+ *
3823
+ * 需要注意编辑器自身依赖 `allow-scripts` + `allow-same-origin`(读写 iframe 内 DOM),
3824
+ * 其余 token(`allow-downloads`、`allow-popups`、`allow-forms` 等)按业务需要放开。
3825
+ */
3826
+ iframeSandbox?: string | false;
3795
3827
  /** 选中时是否自动滚动到可视区域 */
3796
3828
  autoScrollIntoView?: boolean;
3797
3829
  /** 组件的属性配置表单的dsl */
@@ -3888,6 +3920,17 @@ interface EditorProps {
3888
3920
  canDropIn?: CanDropInFunction;
3889
3921
  /** 画布双击前的钩子函数,返回 false 则阻止默认的双击行为 */
3890
3922
  beforeDblclick?: (event: MouseEvent) => Promise<boolean | void> | boolean | void;
3923
+ /**
3924
+ * 点击组件列表新增组件前的钩子,入参为当前组件列表项,允许异步函数。
3925
+ * 仅点击新增时调用,拖入画布不走该钩子;返回 false 取消本次新增。
3926
+ * 可直接修改入参(例如补全 data),修改会反映到最终新增的节点上。
3927
+ */
3928
+ beforeAppendComponent?: BeforeAppendComponent;
3929
+ /**
3930
+ * 组件列表拖入画布、写入节点前的钩子,入参为即将新增的节点和父节点,允许异步函数。
3931
+ * 仅当拖拽类型为组件列表时,在位置计算完成之后调用;返回 false 取消本次拖入。
3932
+ */
3933
+ beforeDropComponent?: BeforeDropComponent;
3891
3934
  /** 组件树节点双击前的钩子函数,返回 false 则阻止默认的双击行为 */
3892
3935
  beforeLayerNodeDblclick?: (event: MouseEvent, data: TreeNodeData) => Promise<boolean | void> | boolean | void;
3893
3936
  /** 历史记录面板的自定义扩展 tab,追加在内置的页面/数据源/代码块 tab 之后 */
@@ -4126,7 +4169,7 @@ declare const __VLS_base$12: import("@vue/runtime-core").DefineComponent<EditorP
4126
4169
  "onField-input"?: ((...args: any[]) => any) | undefined;
4127
4170
  "onField-change"?: ((...args: any[]) => any) | undefined;
4128
4171
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
4129
- }>, "values" | "changeHandler" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "initialized" | "formState" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
4172
+ }>, "values" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "formState" | "initialized" | "changeHandler" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
4130
4173
  values: import("@tmagic/form-schema").FormValue;
4131
4174
  lastValuesProcessed: import("@tmagic/form-schema").FormValue;
4132
4175
  formState: import("@tmagic/form-schema").FormState;
@@ -4362,7 +4405,7 @@ declare const __VLS_base$12: import("@vue/runtime-core").DefineComponent<EditorP
4362
4405
  "onField-input"?: ((...args: any[]) => any) | undefined;
4363
4406
  "onField-change"?: ((...args: any[]) => any) | undefined;
4364
4407
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
4365
- }>, "values" | "changeHandler" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "initialized" | "formState" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
4408
+ }>, "values" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "formState" | "initialized" | "changeHandler" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
4366
4409
  values: import("@tmagic/form-schema").FormValue;
4367
4410
  lastValuesProcessed: import("@tmagic/form-schema").FormValue;
4368
4411
  formState: import("@tmagic/form-schema").FormState;
@@ -4611,7 +4654,7 @@ declare const __VLS_base$12: import("@vue/runtime-core").DefineComponent<EditorP
4611
4654
  "onField-input"?: ((...args: any[]) => any) | undefined;
4612
4655
  "onField-change"?: ((...args: any[]) => any) | undefined;
4613
4656
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
4614
- }>, "values" | "changeHandler" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "initialized" | "formState" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
4657
+ }>, "values" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "formState" | "initialized" | "changeHandler" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
4615
4658
  values: import("@tmagic/form-schema").FormValue;
4616
4659
  lastValuesProcessed: import("@tmagic/form-schema").FormValue;
4617
4660
  formState: import("@tmagic/form-schema").FormState;
@@ -4847,7 +4890,7 @@ declare const __VLS_base$12: import("@vue/runtime-core").DefineComponent<EditorP
4847
4890
  "onField-input"?: ((...args: any[]) => any) | undefined;
4848
4891
  "onField-change"?: ((...args: any[]) => any) | undefined;
4849
4892
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
4850
- }>, "values" | "changeHandler" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "initialized" | "formState" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
4893
+ }>, "values" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "formState" | "initialized" | "changeHandler" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
4851
4894
  values: import("@tmagic/form-schema").FormValue;
4852
4895
  lastValuesProcessed: import("@tmagic/form-schema").FormValue;
4853
4896
  formState: import("@tmagic/form-schema").FormState;
@@ -4895,10 +4938,10 @@ declare const __VLS_base$12: import("@vue/runtime-core").DefineComponent<EditorP
4895
4938
  historyListExtraTabs: HistoryListExtraTab[];
4896
4939
  disabledShowSrc: boolean;
4897
4940
  customContentMenu: CustomContentMenuFunction;
4898
- layerContentMenu: (MenuButton | MenuComponent)[];
4941
+ layerContentMenu: (MenuComponent | MenuButton)[];
4899
4942
  isContainer: (el: HTMLElement) => boolean | Promise<boolean>;
4900
4943
  containerHighlightClassName: string;
4901
- stageContentMenu: (MenuButton | MenuComponent)[];
4944
+ stageContentMenu: (MenuComponent | MenuButton)[];
4902
4945
  disabledStageOverlay: boolean;
4903
4946
  containerHighlightDuration: number;
4904
4947
  containerHighlightType: import("@tmagic/stage").ContainerHighlightType;
@@ -5488,7 +5531,7 @@ declare const __VLS_base$7: import("@vue/runtime-core").DefineComponent<__VLS_Pr
5488
5531
  "onField-input"?: ((...args: any[]) => any) | undefined;
5489
5532
  "onField-change"?: ((...args: any[]) => any) | undefined;
5490
5533
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
5491
- }>, "values" | "changeHandler" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "initialized" | "formState" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
5534
+ }>, "values" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "formState" | "initialized" | "changeHandler" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
5492
5535
  values: FormValue;
5493
5536
  lastValuesProcessed: FormValue;
5494
5537
  formState: import("@tmagic/form-schema").FormState;
@@ -5724,7 +5767,7 @@ declare const __VLS_base$7: import("@vue/runtime-core").DefineComponent<__VLS_Pr
5724
5767
  "onField-input"?: ((...args: any[]) => any) | undefined;
5725
5768
  "onField-change"?: ((...args: any[]) => any) | undefined;
5726
5769
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
5727
- }>, "values" | "changeHandler" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "initialized" | "formState" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
5770
+ }>, "values" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "formState" | "initialized" | "changeHandler" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
5728
5771
  values: FormValue;
5729
5772
  lastValuesProcessed: FormValue;
5730
5773
  formState: import("@tmagic/form-schema").FormState;
@@ -5971,7 +6014,7 @@ declare const __VLS_base$7: import("@vue/runtime-core").DefineComponent<__VLS_Pr
5971
6014
  "onField-input"?: ((...args: any[]) => any) | undefined;
5972
6015
  "onField-change"?: ((...args: any[]) => any) | undefined;
5973
6016
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
5974
- }>, "values" | "changeHandler" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "initialized" | "formState" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
6017
+ }>, "values" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "formState" | "initialized" | "changeHandler" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
5975
6018
  values: FormValue;
5976
6019
  lastValuesProcessed: FormValue;
5977
6020
  formState: import("@tmagic/form-schema").FormState;
@@ -6207,7 +6250,7 @@ declare const __VLS_base$7: import("@vue/runtime-core").DefineComponent<__VLS_Pr
6207
6250
  "onField-input"?: ((...args: any[]) => any) | undefined;
6208
6251
  "onField-change"?: ((...args: any[]) => any) | undefined;
6209
6252
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
6210
- }>, "values" | "changeHandler" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "initialized" | "formState" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
6253
+ }>, "values" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "formState" | "initialized" | "changeHandler" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
6211
6254
  values: FormValue;
6212
6255
  lastValuesProcessed: FormValue;
6213
6256
  formState: import("@tmagic/form-schema").FormState;
@@ -6433,7 +6476,7 @@ declare const __VLS_base$6: import("@vue/runtime-core").DefineComponent<__VLS_Pr
6433
6476
  "onField-input"?: ((...args: any[]) => any) | undefined;
6434
6477
  "onField-change"?: ((...args: any[]) => any) | undefined;
6435
6478
  "onUpdate:stepActive"?: ((...args: any[]) => any) | undefined;
6436
- }>, "values" | "changeHandler" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "initialized" | "formState" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
6479
+ }>, "values" | "validate" | "lastValuesProcessed" | "submitForm" | "changeRecords" | "formState" | "initialized" | "changeHandler" | "resetForm" | "getTextByName" | ("disabled" | "labelWidth" | "inline" | "labelPosition" | "config" | "height" | "initValues" | "lastValues" | "isCompare" | "keyProp" | "parentValues" | "useFieldTextInError" | "stepActive" | "validateOnInit")> & {
6437
6480
  values: FormValue;
6438
6481
  lastValuesProcessed: FormValue;
6439
6482
  formState: import("@tmagic/form-schema").FormState;
@@ -6477,8 +6520,8 @@ type __VLS_Props$14 = {
6477
6520
  declare const __VLS_export$17: import("@vue/runtime-core").DefineComponent<__VLS_Props$14, {
6478
6521
  getElRef: () => Readonly<import("@vue/reactivity").ShallowRef<HTMLDivElement | null>>;
6479
6522
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<__VLS_Props$14> & Readonly<{}>, {
6480
- data: MenuButton | MenuComponent;
6481
- eventType: "mousedown" | "mouseup" | "click";
6523
+ data: MenuComponent | MenuButton;
6524
+ eventType: "click" | "mousedown" | "mouseup";
6482
6525
  }, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
6483
6526
  declare const _default$36: typeof __VLS_export$17;
6484
6527
  //#endregion
@@ -6524,7 +6567,7 @@ declare const __VLS_base$5: import("@vue/runtime-core").DefineComponent<__VLS_Pr
6524
6567
  onShow?: (() => any) | undefined;
6525
6568
  onHide?: (() => any) | undefined;
6526
6569
  }>, {
6527
- menuData: (MenuButton | MenuComponent)[];
6570
+ menuData: (MenuComponent | MenuButton)[];
6528
6571
  isSubMenu: boolean;
6529
6572
  autoHide: boolean;
6530
6573
  }, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
@@ -6649,7 +6692,7 @@ declare const __VLS_export$11: import("@vue/runtime-core").DefineComponent<__VLS
6649
6692
  reload: () => Promise<void>;
6650
6693
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<__VLS_Props$9> & Readonly<{}>, {
6651
6694
  labelWidth: string;
6652
- category: CompareCategory;
6695
+ category: string;
6653
6696
  }, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
6654
6697
  declare const _default$5: typeof __VLS_export$11;
6655
6698
  //#endregion
@@ -6665,7 +6708,7 @@ declare const __VLS_export$10: import("@vue/runtime-core").DefineComponent<__VLS
6665
6708
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<__VLS_Props$8> & Readonly<{}>, {
6666
6709
  disabled: boolean;
6667
6710
  labelWidth: string;
6668
- category: CompareCategory;
6711
+ category: string;
6669
6712
  }, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
6670
6713
  declare const _default$39: typeof __VLS_export$10;
6671
6714
  //#endregion
package/types/sdk.d.ts CHANGED
@@ -1766,8 +1766,20 @@ interface StageOptions {
1766
1766
  */
1767
1767
  disabledFlashTip?: boolean;
1768
1768
  zoom?: number;
1769
+ /** 画布 iframe 的 sandbox 属性值,不传 / false 表示不设置,见 @tmagic/stage 的 StageRenderConfig.iframeSandbox */
1770
+ iframeSandbox?: string | false;
1769
1771
  /** 画布双击前的钩子函数,返回 false 则阻止默认的双击行为 */
1770
1772
  beforeDblclick?: (event: MouseEvent) => Promise<boolean | void> | boolean | void;
1773
+ /**
1774
+ * 点击组件列表新增组件前的钩子,详见 EditorProps.beforeAppendComponent。
1775
+ * 仅点击新增时调用;返回 false 取消新增,支持异步。
1776
+ */
1777
+ beforeAppendComponent?: BeforeAppendComponent;
1778
+ /**
1779
+ * 组件列表拖入画布、写入节点前的钩子,详见 EditorProps.beforeDropComponent。
1780
+ * 仅 dragType 为组件列表时调用;返回 false 取消本次拖入,支持异步。
1781
+ */
1782
+ beforeDropComponent?: BeforeDropComponent;
1771
1783
  }
1772
1784
  /**
1773
1785
  * 节点校验错误信息,按来源(属性表单 / 样式表单)分别保存错误文案。
@@ -1954,6 +1966,16 @@ interface ComponentItem {
1954
1966
  [key: string]: any;
1955
1967
  };
1956
1968
  }
1969
+ /**
1970
+ * 点击组件列表新增组件前的钩子。
1971
+ * 入参为当前组件列表项,允许异步;返回 false 时取消本次新增。
1972
+ */
1973
+ type BeforeAppendComponent = (item: ComponentItem) => boolean | void | Promise<boolean | void>;
1974
+ /**
1975
+ * 组件列表拖入画布、写入节点前的钩子。
1976
+ * 入参为即将新增的节点和父节点,允许异步;返回 false 时取消本次拖入。
1977
+ */
1978
+ type BeforeDropComponent = (dragData: AddMNode, parent: MContainer) => boolean | void | Promise<boolean | void>;
1957
1979
  interface ComponentGroup {
1958
1980
  /** 显示文案 */
1959
1981
  title: string;