@hailin-zheng/editor-core 2.2.29 → 2.2.30

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/index.js CHANGED
@@ -4229,12 +4229,15 @@ class DataElementInlineGroup extends InlineGroupInputElement {
4229
4229
  const depEleMap = new Map();
4230
4230
  let compliedCode = parser(this.props.expression, depIdItems);
4231
4231
  compliedCode = addReturn(compliedCode);
4232
+ const executeCtx = execute.setExecuteCtx(this);
4232
4233
  this.parserExpress = {
4233
4234
  compliedCode,
4234
4235
  func: new Function(`with(this){ ${compliedCode} }`),
4235
- depItems: depEleMap
4236
+ depItems: depEleMap,
4237
+ executeCtx
4236
4238
  };
4237
4239
  if (depIdItems.length) {
4240
+ //设置执行上下文,doc或者doc-part
4238
4241
  depIdItems.forEach(dep => {
4239
4242
  const refCtx = execute.getObject(dep);
4240
4243
  if (refCtx.ref) {
@@ -4258,6 +4261,8 @@ class DataElementInlineGroup extends InlineGroupInputElement {
4258
4261
  return;
4259
4262
  }
4260
4263
  const tempExecuter = execute.create();
4264
+ //设置执行上下文,doc或者doc-part
4265
+ tempExecuter.setExecuteCtx(this.parserExpress.executeCtx);
4261
4266
  tempExecuter.setCurrentCtx(this, this.parserExpress.depItems);
4262
4267
  const fn = func.bind(tempExecuter);
4263
4268
  fn();
@@ -14148,6 +14153,15 @@ class DynamicExecute {
14148
14153
  create() {
14149
14154
  return new DynamicExecute(this.doc, this.ss);
14150
14155
  }
14156
+ /**
14157
+ * 设置当前执行上下文
14158
+ * 一般情况下为document,但是如果为病程录文档,需要设置为当前病程录part
14159
+ */
14160
+ setExecuteCtx(parseEle) {
14161
+ const parentCtx = ElementUtil.getParent(parseEle, (item) => item.type === 'doc' || item.type === 'body-part');
14162
+ this.doc = parentCtx;
14163
+ return this.doc;
14164
+ }
14151
14165
  setCurrentCtx(ele, depItems) {
14152
14166
  this.current = ele;
14153
14167
  this.depItems = depItems;
@@ -14841,6 +14855,8 @@ class ParagraphMeasure {
14841
14855
  const depEleMap = new Map();
14842
14856
  let compliedCode = parser(ele.attribute?.visibleExpr, depIdItems);
14843
14857
  compliedCode = addReturn(compliedCode);
14858
+ //设置执行上下文,doc或者doc-part
14859
+ const executeCtx = execute.setExecuteCtx(ele);
14844
14860
  if (depIdItems.length) {
14845
14861
  depIdItems.forEach(dep => {
14846
14862
  const refCtx = execute.getObject(dep);
@@ -14862,7 +14878,7 @@ class ParagraphMeasure {
14862
14878
  }
14863
14879
  });
14864
14880
  }
14865
- ele.visibleExpr = { compliedCode, func: new Function(`with(this){ ${compliedCode} }`), depItems: depEleMap };
14881
+ ele.visibleExpr = { compliedCode, func: new Function(`with(this){ ${compliedCode} }`), depItems: depEleMap, executeCtx };
14866
14882
  }
14867
14883
  catch (e) {
14868
14884
  console.error('解析表达式出错', ele.attribute?.visibleExpr);
@@ -14933,6 +14949,8 @@ class ParagraphMeasure {
14933
14949
  evalVisibleExpr(ele, executeCtx) {
14934
14950
  if (ele.visibleExpr && ele.visibleExpr.func) {
14935
14951
  try {
14952
+ //设置执行上下文,doc或者doc-part
14953
+ executeCtx.setExecuteCtx(ele.visibleExpr.executeCtx);
14936
14954
  executeCtx.setCurrentCtx(ele, ele.visibleExpr.depItems);
14937
14955
  const func = ele.visibleExpr.func.bind(executeCtx);
14938
14956
  return func() === true;
@@ -23141,7 +23159,7 @@ class DocEditor {
23141
23159
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
23142
23160
  }
23143
23161
  version() {
23144
- return "2.2.29";
23162
+ return "2.2.30";
23145
23163
  }
23146
23164
  switchPageHeaderEditor() {
23147
23165
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);