@easy-editor/core 0.0.12 → 0.0.14

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.
@@ -5,6 +5,7 @@ export interface SetValueOptions {
5
5
  disableMutator?: boolean;
6
6
  type?: PropValueChangedType;
7
7
  fromSetHotValue?: boolean;
8
+ forceHotValue?: boolean;
8
9
  }
9
10
  export declare enum PropValueChangedType {
10
11
  /**
@@ -42,6 +43,7 @@ export declare class SettingField extends SettingPropEntry {
42
43
  getConfig<K extends keyof FieldConfig>(configName?: K): FieldConfig[K] | FieldConfig;
43
44
  getItems(filter?: (item: SettingField) => boolean): SettingField[];
44
45
  setValue(val: any, isHotValue?: boolean, extraOptions?: SetValueOptions): void;
46
+ clearValue(): void;
45
47
  getHotValue(): any;
46
48
  setHotValue(data: any, options?: SetValueOptions): void;
47
49
  }
@@ -24,6 +24,7 @@ export declare class History<T = RootSchema> {
24
24
  private timeGap;
25
25
  private serialization;
26
26
  setSerialization(serialization: Serialization<T, string>): void;
27
+ private disposer;
27
28
  constructor(dataFn: () => T | null, redoer: (data: T) => void, document?: Document | undefined);
28
29
  /**
29
30
  * check if there is unsaved change for history
@@ -5675,7 +5675,7 @@ class History {
5675
5675
  this.document = document;
5676
5676
  this.session = new Session(0, '', this.timeGap);
5677
5677
  this.records = [this.session];
5678
- reaction(() => {
5678
+ this.disposer = reaction(() => {
5679
5679
  return dataFn();
5680
5680
  }, data => {
5681
5681
  if (this.asleep) return;
@@ -5762,6 +5762,7 @@ class History {
5762
5762
  }
5763
5763
  destroy() {
5764
5764
  this.records = [];
5765
+ this.disposer();
5765
5766
  }
5766
5767
  getState() {
5767
5768
  const {
@@ -7783,6 +7784,7 @@ class Document {
7783
7784
  return this.rootNode.export(stage);
7784
7785
  }
7785
7786
  remove() {
7787
+ this.history.destroy();
7786
7788
  this.designer.postEvent(DOCUMENT_EVENT.REMOVE, {
7787
7789
  id: this.id
7788
7790
  });
@@ -8099,13 +8101,15 @@ class Project {
8099
8101
  if (index < 0) {
8100
8102
  return logger.warn('document not found', idOrDoc);
8101
8103
  }
8102
- document.remove();
8103
8104
  this.documents.splice(index, 1);
8104
8105
  this.documentsMap.delete(document.id);
8105
8106
  }
8106
8107
  getDocument(id) {
8107
8108
  return this.documents.find(doc => doc.id === id);
8108
8109
  }
8110
+ getDocumentByFileName(fileName) {
8111
+ return this.documents.find(doc => doc.fileName === fileName);
8112
+ }
8109
8113
  open(idOrDoc) {
8110
8114
  if (!idOrDoc) {
8111
8115
  const got = this.documents.find(item => item.isBlank());
@@ -8436,6 +8440,9 @@ class Simulator {
8436
8440
  get enableStrictNotFoundMode() {
8437
8441
  return this.editor.get('enableStrictNotFoundMode') ?? false;
8438
8442
  }
8443
+ get excuteLifeCycleInDesignMode() {
8444
+ return this.editor.get('excuteLifeCycleInDesignMode') ?? false;
8445
+ }
8439
8446
  get notFoundComponent() {
8440
8447
  return this.editor.get('notFoundComponent') ?? null;
8441
8448
  }
@@ -10061,6 +10068,10 @@ class SettingField extends SettingPropEntry {
10061
10068
  }
10062
10069
  super.setValue(val, isHotValue, extraOptions);
10063
10070
  }
10071
+ clearValue() {
10072
+ this.hotValue = null;
10073
+ super.clearValue();
10074
+ }
10064
10075
  getHotValue() {
10065
10076
  if (this.hotValue) {
10066
10077
  return this.hotValue;
@@ -10076,13 +10087,15 @@ class SettingField extends SettingPropEntry {
10076
10087
  const value = data;
10077
10088
  if (options) {
10078
10089
  options.fromSetHotValue = true;
10090
+ options.forceHotValue = true;
10079
10091
  } else {
10080
10092
  options = {
10081
- fromSetHotValue: true
10093
+ fromSetHotValue: true,
10094
+ forceHotValue: true
10082
10095
  };
10083
10096
  }
10084
- if (this.isUseVariable()) {
10085
- const oldValue = this.getValue();
10097
+ if (this.isUseVariable() || options?.forceHotValue) {
10098
+ const oldValue = this.getValue() || {};
10086
10099
  if (isJSExpression(value)) {
10087
10100
  this.setValue({
10088
10101
  type: 'JSExpression',