@tmagic/editor 1.2.9 → 1.2.10

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.
@@ -197,7 +197,7 @@
197
197
  const props = __props;
198
198
  const services = vue.inject("services");
199
199
  const mForm = vue.inject("mForm");
200
- const codeDsl = vue.computed(() => services?.codeBlockService.getCodeDslSync());
200
+ const codeDsl = vue.computed(() => services?.codeBlockService.getCodeDsl());
201
201
  const tableConfig = vue.computed(() => {
202
202
  const defaultConfig = {
203
203
  dropSort: false,
@@ -1468,9 +1468,7 @@
1468
1468
  "move",
1469
1469
  "undo",
1470
1470
  "redo",
1471
- "highlight",
1472
- "getCodeDsl",
1473
- "setCodeDsl"
1471
+ "highlight"
1474
1472
  ],
1475
1473
  ["select", "update", "moveLayer"]
1476
1474
  );
@@ -1983,19 +1981,6 @@
1983
1981
  resetModifiedNodeId() {
1984
1982
  this.get("modifiedNodeIds").clear();
1985
1983
  }
1986
- async getCodeDsl() {
1987
- const root = this.get("root");
1988
- return root?.codeBlocks || null;
1989
- }
1990
- getCodeDslSync() {
1991
- const root = this.get("root");
1992
- return root?.codeBlocks || null;
1993
- }
1994
- async setCodeDsl(codeDsl) {
1995
- if (!this.state.root)
1996
- return;
1997
- this.state.root.codeBlocks = codeDsl;
1998
- }
1999
1984
  addModifiedNodeId(id) {
2000
1985
  if (!this.isHistoryStateChange) {
2001
1986
  this.get("modifiedNodeIds").set(id, id);
@@ -3330,7 +3315,7 @@
3330
3315
  codeContent.value = props.content;
3331
3316
  });
3332
3317
  const initTableModel = () => {
3333
- const codeDsl = lodashEs.cloneDeep(services?.codeBlockService.getCodeDslSync());
3318
+ const codeDsl = lodashEs.cloneDeep(services?.codeBlockService.getCodeDsl());
3334
3319
  if (!codeDsl)
3335
3320
  return;
3336
3321
  tableModel.value = {
@@ -3579,7 +3564,7 @@
3579
3564
  }
3580
3565
  );
3581
3566
  vue.watch(
3582
- [() => services?.codeBlockService.getCodeDslSync(), () => services?.codeBlockService.getCombineInfo()],
3567
+ [() => services?.codeBlockService.getCodeDsl(), () => services?.codeBlockService.getCombineInfo()],
3583
3568
  () => {
3584
3569
  refreshCodeList();
3585
3570
  },
@@ -5634,8 +5619,6 @@
5634
5619
  });
5635
5620
  constructor() {
5636
5621
  super([
5637
- "setCodeDsl",
5638
- "getCodeDsl",
5639
5622
  "getCodeContentById",
5640
5623
  "getCodeDslByIds",
5641
5624
  "getCurrentDsl",
@@ -5649,17 +5632,10 @@
5649
5632
  }
5650
5633
  async setCodeDsl(codeDsl2) {
5651
5634
  this.state.codeDsl = codeDsl2;
5652
- await editorService.setCodeDsl(this.state.codeDsl);
5653
5635
  info("[code-block]:code-dsl-change", this.state.codeDsl);
5654
5636
  this.emit("code-dsl-change", this.state.codeDsl);
5655
5637
  }
5656
- async getCodeDsl(forceRefresh = false) {
5657
- return this.getCodeDslSync(forceRefresh);
5658
- }
5659
- getCodeDslSync(forceRefresh = false) {
5660
- if (!this.state.codeDsl || forceRefresh) {
5661
- this.state.codeDsl = editorService.getCodeDslSync();
5662
- }
5638
+ getCodeDsl() {
5663
5639
  return this.state.codeDsl;
5664
5640
  }
5665
5641
  async getCodeContentById(id2) {
@@ -5671,28 +5647,19 @@
5671
5647
  return totalCodeDsl[id2] ?? null;
5672
5648
  }
5673
5649
  async setCodeDslById(id, codeConfig) {
5674
- let codeDsl = await this.getCodeDsl();
5650
+ const codeDsl = await this.getCodeDsl();
5651
+ if (!codeDsl) {
5652
+ throw new Error("dsl\u4E2D\u6CA1\u6709codeBlocks");
5653
+ }
5675
5654
  const codeConfigProcessed = codeConfig;
5676
5655
  if (codeConfig.content) {
5677
5656
  codeConfigProcessed.content = eval(codeConfig.content);
5678
5657
  }
5679
- if (!codeDsl) {
5680
- codeDsl = {
5681
- [id]: {
5682
- ...codeConfigProcessed
5683
- }
5684
- };
5685
- } else {
5686
- const existContent = codeDsl[id] || {};
5687
- codeDsl = {
5688
- ...codeDsl,
5689
- [id]: {
5690
- ...existContent,
5691
- ...codeConfigProcessed
5692
- }
5693
- };
5694
- }
5695
- await this.setCodeDsl(codeDsl);
5658
+ const existContent = codeDsl[id] || {};
5659
+ codeDsl[id] = {
5660
+ ...existContent,
5661
+ ...codeConfigProcessed
5662
+ };
5696
5663
  }
5697
5664
  async getCodeDslByIds(ids) {
5698
5665
  const codeDsl2 = await this.getCodeDsl();
@@ -5783,9 +5750,11 @@
5783
5750
  }
5784
5751
  async deleteCodeDslByIds(codeIds) {
5785
5752
  const currentDsl = await this.getCodeDsl();
5786
- const newDsl = lodashEs.omit(currentDsl, codeIds);
5787
- await this.setCodeDsl(newDsl);
5788
- return newDsl;
5753
+ if (!currentDsl)
5754
+ return;
5755
+ codeIds.forEach((id2) => {
5756
+ delete currentDsl[id2];
5757
+ });
5789
5758
  }
5790
5759
  async getUniqueId() {
5791
5760
  const newId = `code_${Math.random().toString(10).substring(2).substring(0, 4)}`;
@@ -5987,6 +5956,8 @@
5987
5956
  if (vue.toRaw(value) !== vue.toRaw(preValue)) {
5988
5957
  emit("update:modelValue", value);
5989
5958
  }
5959
+ value.codeBlocks = value.codeBlocks || {};
5960
+ codeBlockService.setCodeDsl(value.codeBlocks);
5990
5961
  };
5991
5962
  editorService.on("root-change", rootChangeHandler);
5992
5963
  vue.watch(