@hailin-zheng/editor-core 2.2.30 → 2.2.32

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
@@ -1306,6 +1306,7 @@ class Element {
1306
1306
  this.disposed = true;
1307
1307
  this.visibleExpr = null;
1308
1308
  this.effectExpr = null;
1309
+ this._onChangeEvent.unsubscribe();
1309
1310
  }
1310
1311
  addEvent(event, handle, useCapture = false) {
1311
1312
  if (!this._eventMap) {
@@ -4208,7 +4209,7 @@ class DataElementInlineGroup extends InlineGroupInputElement {
4208
4209
  // this.expressFn = new Function();
4209
4210
  // }
4210
4211
  }
4211
- parserExpress;
4212
+ parserExpr;
4212
4213
  /**
4213
4214
  * 解析表达式
4214
4215
  * @param ele
@@ -4221,7 +4222,7 @@ class DataElementInlineGroup extends InlineGroupInputElement {
4221
4222
  if (!this.props.expression || !data.options.enableDyExpression)
4222
4223
  return;
4223
4224
  //存在表达式,并且已经解析过,不再做处理
4224
- if (this.parserExpress)
4225
+ if (this.parserExpr)
4225
4226
  return;
4226
4227
  const reactiveMode = data.renderCtx.drawMode !== 'print';
4227
4228
  try {
@@ -4230,7 +4231,7 @@ class DataElementInlineGroup extends InlineGroupInputElement {
4230
4231
  let compliedCode = parser(this.props.expression, depIdItems);
4231
4232
  compliedCode = addReturn(compliedCode);
4232
4233
  const executeCtx = execute.setExecuteCtx(this);
4233
- this.parserExpress = {
4234
+ this.parserExpr = {
4234
4235
  compliedCode,
4235
4236
  func: new Function(`with(this){ ${compliedCode} }`),
4236
4237
  depItems: depEleMap,
@@ -4256,20 +4257,20 @@ class DataElementInlineGroup extends InlineGroupInputElement {
4256
4257
  try {
4257
4258
  data.onNextView(() => {
4258
4259
  //当前元素可能被删除
4259
- const func = this.parserExpress.func;
4260
+ const func = this.parserExpr?.func;
4260
4261
  if (!func) {
4261
4262
  return;
4262
4263
  }
4263
4264
  const tempExecuter = execute.create();
4264
4265
  //设置执行上下文,doc或者doc-part
4265
- tempExecuter.setExecuteCtx(this.parserExpress.executeCtx);
4266
- tempExecuter.setCurrentCtx(this, this.parserExpress.depItems);
4266
+ tempExecuter.setExecuteCtx(this.parserExpr.executeCtx);
4267
+ tempExecuter.setCurrentCtx(this, this.parserExpr.depItems);
4267
4268
  const fn = func.bind(tempExecuter);
4268
4269
  fn();
4269
4270
  });
4270
4271
  }
4271
4272
  catch (e) {
4272
- console.error(e, "表达式执行出错", this.parserExpress.compliedCode);
4273
+ console.error(e, "表达式执行出错", this.parserExpr.compliedCode);
4273
4274
  }
4274
4275
  });
4275
4276
  });
@@ -4288,14 +4289,14 @@ class DataElementInlineGroup extends InlineGroupInputElement {
4288
4289
  * @private
4289
4290
  */
4290
4291
  evalEleExpr(executeCtx) {
4291
- if (this.parserExpress && this.parserExpress.func) {
4292
+ if (this.parserExpr && this.parserExpr.func) {
4292
4293
  try {
4293
- executeCtx.setCurrentCtx(this, this.parserExpress.depItems);
4294
- const func = this.parserExpress.func.bind(executeCtx);
4294
+ executeCtx.setCurrentCtx(this, this.parserExpr.depItems);
4295
+ const func = this.parserExpr.func.bind(executeCtx);
4295
4296
  func();
4296
4297
  }
4297
4298
  catch (e) {
4298
- console.error(e, "表达式执行出错:evalVisibleExpr", this.parserExpress.compliedCode);
4299
+ console.error(e, "表达式执行出错:evalVisibleExpr", this.parserExpr.compliedCode);
4299
4300
  }
4300
4301
  finally {
4301
4302
  executeCtx.clearCurrentCtx();
@@ -4313,6 +4314,11 @@ class DataElementInlineGroup extends InlineGroupInputElement {
4313
4314
  }
4314
4315
  this.errorTip = this.validate();
4315
4316
  }
4317
+ destroy() {
4318
+ this.visibleExpr = undefined;
4319
+ this.parserExpr = undefined;
4320
+ super.destroy();
4321
+ }
4316
4322
  }
4317
4323
  function getCurrOptions(ele) {
4318
4324
  const doc = ElementUtil.getParent(ele, item => item.type === 'doc');
@@ -9333,6 +9339,9 @@ class DataElementList extends DataElementInlineGroup {
9333
9339
  this.clearInnerItems();
9334
9340
  return;
9335
9341
  }
9342
+ if (typeof vals === 'string' && vals) {
9343
+ vals = vals.split(';');
9344
+ }
9336
9345
  if (!Array.isArray(vals)) {
9337
9346
  vals = [vals];
9338
9347
  }
@@ -11048,6 +11057,97 @@ class SVGFactory extends ElementFactory {
11048
11057
  }
11049
11058
  }
11050
11059
 
11060
+ class LineElement extends LeafElement {
11061
+ constructor() {
11062
+ super('line');
11063
+ this.props = new LineProps();
11064
+ }
11065
+ createRenderObject() {
11066
+ const symbol = new LineRenderObject(this);
11067
+ symbol.rect.height = Math.ceil(14 * TEXT_HEIGHT_FACTOR);
11068
+ symbol.rect.width = 20;
11069
+ return symbol;
11070
+ }
11071
+ serialize(options) {
11072
+ return {
11073
+ type: 'line',
11074
+ props: this.props.getSerializeProps(options)
11075
+ };
11076
+ }
11077
+ clone() {
11078
+ const clone = new LineElement();
11079
+ cloneElementBase(this, clone);
11080
+ this.props.clone(clone.props);
11081
+ return clone;
11082
+ }
11083
+ }
11084
+ class LineRenderObject extends LeafRenderObject {
11085
+ exportSVG(event) {
11086
+ return ElementUtil.createSvgLine({
11087
+ x1: this.rect.x,
11088
+ y1: this.rect.y,
11089
+ x2: this.rect.x + this.rect.width,
11090
+ y2: this.rect.y + this.rect.height,
11091
+ 'stroke-width': this.element.props.thickness,
11092
+ stroke: this.element.props.color,
11093
+ 'stroke-dasharray': this.element.props.type === LineType.Dashed ? '5,5' : ''
11094
+ });
11095
+ }
11096
+ clone() {
11097
+ const render = new LineRenderObject(this.element);
11098
+ render.rect = ElementUtil.cloneRect(this.rect);
11099
+ return render;
11100
+ }
11101
+ }
11102
+ class LineFactory extends ElementFactory {
11103
+ match(type) {
11104
+ return type === 'line';
11105
+ }
11106
+ createElement(data) {
11107
+ const ele = new LineElement();
11108
+ ele.props.width = data.props.width;
11109
+ ele.props.type = data.props.type ?? LineType.Solid;
11110
+ ele.props.thickness = data.props.thickness ?? 1;
11111
+ ele.props.color = data.props.color ?? '#000000';
11112
+ return ele;
11113
+ }
11114
+ }
11115
+ // 定义线段类型的枚举
11116
+ var LineType;
11117
+ (function (LineType) {
11118
+ LineType["Solid"] = "solid";
11119
+ LineType["Dashed"] = "dashed";
11120
+ LineType["Dotted"] = "dotted";
11121
+ LineType["DashDot"] = "dash-dot";
11122
+ })(LineType || (LineType = {}));
11123
+ class LineProps {
11124
+ width; // 线段的宽度,例如 '50%', '100px'
11125
+ type = LineType.Solid; // 线段的类型,例如 LineType.Solid
11126
+ thickness = 1; // 线段的粗细,例如 '2px'
11127
+ color = '#000000'; // 线段的颜色,例如 '#000000'
11128
+ clone(dest) {
11129
+ const clone = dest ?? new LineProps();
11130
+ clone.width = this.width;
11131
+ clone.type = this.type;
11132
+ clone.thickness = this.thickness;
11133
+ clone.color = this.color;
11134
+ return clone;
11135
+ }
11136
+ getSerializeProps(viewOptions) {
11137
+ const props = {};
11138
+ if (this.color !== '#000000') {
11139
+ props.color = this.color;
11140
+ }
11141
+ if (this.type !== LineType.Solid) {
11142
+ props.type = this.type;
11143
+ }
11144
+ if (this.thickness !== 1) {
11145
+ props.thickness = this.thickness;
11146
+ }
11147
+ return props;
11148
+ }
11149
+ }
11150
+
11051
11151
  class ElementSerialize {
11052
11152
  /**
11053
11153
  * 将当前文档对象构建并输出到标准的JSON对象
@@ -13802,6 +13902,14 @@ class EditorContext {
13802
13902
  getCtx(ele) {
13803
13903
  return new DocumentContext(ele, this.selectionState);
13804
13904
  }
13905
+ /**
13906
+ * 注入右键菜单事件处理器
13907
+ * @param elementType 元素类型
13908
+ * @param eventName 事件名称
13909
+ * @param handler 回调处理函数
13910
+ * @param useCapture 是否为捕获阶段
13911
+ * @returns
13912
+ */
13805
13913
  registerTypeHandlers(elementType, eventName, handler, useCapture = false) {
13806
13914
  if (elementTypeEventHandler.find(item => item.ctx === this && item.elementType === elementType && item.eventName === eventName && item.useCapture === useCapture)) {
13807
13915
  return;
@@ -20327,6 +20435,9 @@ class EditorCalendarVNode {
20327
20435
  }
20328
20436
  render(position, dataValue, format = 'YYYY-MM-DD HH:mm:ss') {
20329
20437
  format = format ?? 'YYYY-MM-DD HH:mm:ss';
20438
+ if (dataValue !== this.currentDate) {
20439
+ this.reset();
20440
+ }
20330
20441
  if (!this.currentDate && dataValue) {
20331
20442
  const currDataValue = moment(dataValue, format);
20332
20443
  this.currYear.value = currDataValue.year();
@@ -23159,7 +23270,7 @@ class DocEditor {
23159
23270
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
23160
23271
  }
23161
23272
  version() {
23162
- return "2.2.30";
23273
+ return "2.2.32";
23163
23274
  }
23164
23275
  switchPageHeaderEditor() {
23165
23276
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
@@ -28929,5 +29040,5 @@ function removeDuplicatesEvent(events) {
28929
29040
  return arr;
28930
29041
  }
28931
29042
 
28932
- export { BlockContainerElement, BlockContainerRenderObject, BlockContentElement, BlockContentRenderObject, BlockLineRectRenderObject, BodyPartProps, BooleanEnum, BorderProps, BranchElement, BranchRenderObject, BreakElement, BreakFactory, BreakRenderObject, CheckBoxElement, CheckBoxFactory, CheckBoxProps, CheckBoxRenderObject, ColumnPatchUtil, CommContentBaseElement, CommContentBaseRenderObject, CommContentElement, CommContentProps, CommContentRenderObject, CommProps, CommentContentFactory, CommentElement, CommentFactory, CommentRenderObject, CommentsFactory, CommonUtil, CommsContainerElement, CommsContainerRenderObject, ContentMenuItem, ContextMenuElementEvent, CopyElementEvent, DOMEventSource, DOMSubscription, DataContainerElement, DataContainerFactory, DataContainerProps, DataContainerRenderObject, DataDecorateElement, DataDecorateProps, DataDecorateRenderObject, DataEleBaseProps, DataEleBaseTextProps, DataEleCheckProps, DataEleDateProps, DataEleImageProps, DataEleListProps, DataEleMHProps, DataElementBarcode, DataElementBarcodeFactory, DataElementBarcodeProps, DataElementBarcodeRenderObject, DataElementBaseFactory, DataElementCheck, DataElementCheckFactory, DataElementCheckRenderObject, DataElementDate, DataElementDateFactory, DataElementDateRenderObject, DataElementGroupElement, DataElementGroupFactory, DataElementGroupProps, DataElementGroupRenderObject, DataElementImage, DataElementImgFactory, DataElementInlineGroup, DataElementLeaf, DataElementList, DataElementListFactory, DataElementListRenderObject, DataElementMH, DataElementMHFactory, DataElementRenderObject, DataElementText, DataElementTextFactory, DataElementTextRenderObject, DataImageRenderObject, DataRenderMH, DocEditor, DocInputSuggestions, DocMode, DocumentBodyElement, DocumentBodyFactory, DocumentBodyPartElement, DocumentBodyPartFactory, DocumentBodyPartRenderObject, DocumentBodyRenderObject, DocumentChange, DocumentCombine, DocumentComment, DocumentContainerRender, DocumentContext, DocumentCursor, DocumentElement, DocumentEvalFunc, DocumentEvent, DocumentFactory, DocumentFooterElement, DocumentFooterFactory, DocumentFooterRenderObject, DocumentHeaderElement, DocumentHeaderFactory, DocumentHeaderRenderObject, DocumentInput, DocumentPaginator, DocumentPrintOffscreen, DocumentPrintOffscreenBase, DocumentProps, DocumentRenderObject, DocumentSelection, DocumentTemplate, DropElementEvent, EditMode, EditorContext, Element, ElementEvent, ElementFactory, ElementReader, ElementSerialize, ElementUtil, EventBus, EventMap, EventSourceCore, FillNullSpaceElement, FillNullSpaceRenderObject, GetTrackTipsEvent, GotCursorEvent, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, InputElementEvent, IsInSideDataElement, IsInSideDataGroup, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag, MouseElementEvent, MousedownElementEvent, MultiBlockLineRenderObject, OnceSubject, PSymbolElement, PSymbolRenderObject, PaddingProps, PageBreakElement, PageBreakFactory, PageBreakRenderObject, PageOptions, PaintContent, ParagraphElement, ParagraphFactory, ParagraphLineRectRenderObject, ParagraphNumberType, ParagraphProps, ParagraphRenderObject, PasteElementEvent, PermanentTeethElement, PermanentTeethFactory, PermanentTeethProps, PermanentTeethRenderObject, PictureElement, PictureFactory, PictureProps, PictureRenderObject, RadioBoxElement, RadioBoxFactory, RadioBoxProps, RadioBoxRenderObject, RangeUtil, Rect, RenderContext, RenderObject, RenderObjectType, ResizeLeafRenderObject, RowMinHeight, RunElementFactory, SVGElement, SVGFactory, SVGProps, SVGRenderObject, SelectionOverlays, SelectionRange, SelectionState, Subject, SubjectSubscription, Subscription, TEXT_HEIGHT_FACTOR, TabElement, TabFactory, TabRenderObject, TableCellElement, TableCellFactory, TableCellProps, TableCellRenderObject, TableElement, TableFactory, TableProps, TableRenderObject, TableRowElement, TableRowFactory, TableRowProps, TableRowRenderObject, TableSplitCell, TableUtil, TextGroupElement, TextGroupFactory, TextGroupRenderObject, TextProps, TextUnitsHolder, TrackRunElement, TrackRunProps, TrackRunRenderObject, TrackRunTypeEnum, ValidateCondition, ValidateElement, ValidateProps, ValidateRenderObject, ViewOptions, addReturn, clearChildrenRenderCache, clearTraces, cloneChildren, cloneElementBase, defaultParaHanging, deleteCurrentParagraph, docOpsMap, elementTypeEventHandler, exportDataEleDecoratorSVG$1 as exportDataEleDecoratorSVG, falseChar, fontMapFunc, formatEle, fromEvent, generatePatch, getCalleeName, getCurrentParaGroupRenders, getFocusTextSegment, getRenderPosToDoc, inputText, insertEle, invokeTypeHandler, isDate, logUpdateEleProps, objectToString$4 as objectToString, onTableContextmenu, onceTask, parser, reactiveMap, refreshEditor, removeEle, removeText, renderErrorTip, renderUnderWavyLine, renderUnderline, runTextLineRender, setChildrenModifyFlag, setNotifyChangedCallback, setTraceTrackingFlag, suppressTracking, targetMaps, textLineRenderMode, toRawType, toTypeString, trueChar, updatePartialProps, validateDataEle, validateDataEleRenderObj, validateDataGroup, validateInlineInputRenderObj, watchChanged };
29043
+ export { BlockContainerElement, BlockContainerRenderObject, BlockContentElement, BlockContentRenderObject, BlockLineRectRenderObject, BodyPartProps, BooleanEnum, BorderProps, BranchElement, BranchRenderObject, BreakElement, BreakFactory, BreakRenderObject, CheckBoxElement, CheckBoxFactory, CheckBoxProps, CheckBoxRenderObject, ColumnPatchUtil, CommContentBaseElement, CommContentBaseRenderObject, CommContentElement, CommContentProps, CommContentRenderObject, CommProps, CommentContentFactory, CommentElement, CommentFactory, CommentRenderObject, CommentsFactory, CommonUtil, CommsContainerElement, CommsContainerRenderObject, ContentMenuItem, ContextMenuElementEvent, CopyElementEvent, DOMEventSource, DOMSubscription, DataContainerElement, DataContainerFactory, DataContainerProps, DataContainerRenderObject, DataDecorateElement, DataDecorateProps, DataDecorateRenderObject, DataEleBaseProps, DataEleBaseTextProps, DataEleCheckProps, DataEleDateProps, DataEleImageProps, DataEleListProps, DataEleMHProps, DataElementBarcode, DataElementBarcodeFactory, DataElementBarcodeProps, DataElementBarcodeRenderObject, DataElementBaseFactory, DataElementCheck, DataElementCheckFactory, DataElementCheckRenderObject, DataElementDate, DataElementDateFactory, DataElementDateRenderObject, DataElementGroupElement, DataElementGroupFactory, DataElementGroupProps, DataElementGroupRenderObject, DataElementImage, DataElementImgFactory, DataElementInlineGroup, DataElementLeaf, DataElementList, DataElementListFactory, DataElementListRenderObject, DataElementMH, DataElementMHFactory, DataElementRenderObject, DataElementText, DataElementTextFactory, DataElementTextRenderObject, DataImageRenderObject, DataRenderMH, DocEditor, DocInputSuggestions, DocMode, DocumentBodyElement, DocumentBodyFactory, DocumentBodyPartElement, DocumentBodyPartFactory, DocumentBodyPartRenderObject, DocumentBodyRenderObject, DocumentChange, DocumentCombine, DocumentComment, DocumentContainerRender, DocumentContext, DocumentCursor, DocumentElement, DocumentEvalFunc, DocumentEvent, DocumentFactory, DocumentFooterElement, DocumentFooterFactory, DocumentFooterRenderObject, DocumentHeaderElement, DocumentHeaderFactory, DocumentHeaderRenderObject, DocumentInput, DocumentPaginator, DocumentPrintOffscreen, DocumentPrintOffscreenBase, DocumentProps, DocumentRenderObject, DocumentSelection, DocumentTemplate, DropElementEvent, EditMode, EditorContext, Element, ElementEvent, ElementFactory, ElementReader, ElementSerialize, ElementUtil, EventBus, EventMap, EventSourceCore, FillNullSpaceElement, FillNullSpaceRenderObject, GetTrackTipsEvent, GotCursorEvent, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, InputElementEvent, IsInSideDataElement, IsInSideDataGroup, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LineElement, LineFactory, LineProps, LineRenderObject, LostCursorEvent, MarginProps, ModifyFlag, MouseElementEvent, MousedownElementEvent, MultiBlockLineRenderObject, OnceSubject, PSymbolElement, PSymbolRenderObject, PaddingProps, PageBreakElement, PageBreakFactory, PageBreakRenderObject, PageOptions, PaintContent, ParagraphElement, ParagraphFactory, ParagraphLineRectRenderObject, ParagraphNumberType, ParagraphProps, ParagraphRenderObject, PasteElementEvent, PermanentTeethElement, PermanentTeethFactory, PermanentTeethProps, PermanentTeethRenderObject, PictureElement, PictureFactory, PictureProps, PictureRenderObject, RadioBoxElement, RadioBoxFactory, RadioBoxProps, RadioBoxRenderObject, RangeUtil, Rect, RenderContext, RenderObject, RenderObjectType, ResizeLeafRenderObject, RowMinHeight, RunElementFactory, SVGElement, SVGFactory, SVGProps, SVGRenderObject, SelectionOverlays, SelectionRange, SelectionState, Subject, SubjectSubscription, Subscription, TEXT_HEIGHT_FACTOR, TabElement, TabFactory, TabRenderObject, TableCellElement, TableCellFactory, TableCellProps, TableCellRenderObject, TableElement, TableFactory, TableProps, TableRenderObject, TableRowElement, TableRowFactory, TableRowProps, TableRowRenderObject, TableSplitCell, TableUtil, TextGroupElement, TextGroupFactory, TextGroupRenderObject, TextProps, TextUnitsHolder, TrackRunElement, TrackRunProps, TrackRunRenderObject, TrackRunTypeEnum, ValidateCondition, ValidateElement, ValidateProps, ValidateRenderObject, ViewOptions, addReturn, clearChildrenRenderCache, clearTraces, cloneChildren, cloneElementBase, defaultParaHanging, deleteCurrentParagraph, docOpsMap, elementTypeEventHandler, exportDataEleDecoratorSVG$1 as exportDataEleDecoratorSVG, falseChar, fontMapFunc, formatEle, fromEvent, generatePatch, getCalleeName, getCurrentParaGroupRenders, getFocusTextSegment, getRenderPosToDoc, inputText, insertEle, invokeTypeHandler, isDate, logUpdateEleProps, objectToString$4 as objectToString, onTableContextmenu, onceTask, parser, reactiveMap, refreshEditor, removeEle, removeText, renderErrorTip, renderUnderWavyLine, renderUnderline, runTextLineRender, setChildrenModifyFlag, setNotifyChangedCallback, setTraceTrackingFlag, suppressTracking, targetMaps, textLineRenderMode, toRawType, toTypeString, trueChar, updatePartialProps, validateDataEle, validateDataEleRenderObj, validateDataGroup, validateInlineInputRenderObj, watchChanged };
28933
29044
  //# sourceMappingURL=index.js.map