@hailin-zheng/editor-core 2.2.37 → 2.2.39

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
@@ -300,6 +300,33 @@ class RenderObject {
300
300
  };
301
301
  }
302
302
  }
303
+ const NS = "http://www.w3.org/2000/svg";
304
+ function HLNode(sel, attrs, child) {
305
+ attrs = attrs || {};
306
+ if (typeof child === 'string') {
307
+ return {
308
+ sel,
309
+ data: {
310
+ ns: NS,
311
+ ...attrs
312
+ },
313
+ text: child
314
+ };
315
+ }
316
+ else {
317
+ const node = {
318
+ sel,
319
+ data: {
320
+ ns: NS,
321
+ ...attrs
322
+ }
323
+ };
324
+ if (child && child.length > 0) {
325
+ node.children = child;
326
+ }
327
+ return node;
328
+ }
329
+ }
303
330
  /**
304
331
  * 叶子节点渲染元素
305
332
  */
@@ -1890,6 +1917,8 @@ class ViewOptions {
1890
1917
  shapeRendering = 'auto';
1891
1918
  //是否开启快速测量
1892
1919
  enableFastMeasure = false;
1920
+ //数据组双击选择模式
1921
+ dataGroupDblClickMode = 'default';
1893
1922
  get fullPageView() {
1894
1923
  return this._fullPageView;
1895
1924
  }
@@ -11265,7 +11294,11 @@ class ElementSerialize {
11265
11294
  * @param element
11266
11295
  * @param viewOptions
11267
11296
  */
11268
- static serialize(element, viewOptions) {
11297
+ static serialize(element, viewOptions, serializeOptions) {
11298
+ serializeOptions = serializeOptions || {};
11299
+ if (serializeOptions.excludeDel && element instanceof TrackRunElement && element.type === TrackRunTypeEnum.Deleted) {
11300
+ return null;
11301
+ }
11269
11302
  const result = element.serialize(viewOptions);
11270
11303
  if (!result) {
11271
11304
  return null;
@@ -11307,7 +11340,10 @@ class ElementSerialize {
11307
11340
  }
11308
11341
  return result;
11309
11342
  }
11310
- static serializeString(element, options = { includeRunDel: false }) {
11343
+ static serializeString(element, options) {
11344
+ options = options || {};
11345
+ options.includeRunDel = options.includeRunDel || false;
11346
+ options.dataEleValueMode = options.dataEleValueMode || 'text';
11311
11347
  if (!options.includeRunDel && element instanceof TrackRunElement && element.type === TrackRunTypeEnum.Deleted) {
11312
11348
  return '';
11313
11349
  }
@@ -11321,6 +11357,9 @@ class ElementSerialize {
11321
11357
  return '\n';
11322
11358
  }
11323
11359
  if (element instanceof BranchElement) {
11360
+ if (element instanceof DataElementInlineGroup && options.dataEleValueMode === 'value') {
11361
+ return element.getValue();
11362
+ }
11324
11363
  const items = [];
11325
11364
  for (let i = 0; i < element.length; i++) {
11326
11365
  const item = element.getChild(i);
@@ -11405,7 +11444,8 @@ class ElementSerialize {
11405
11444
  const selectedStructs = this.getSelectedStruct(ss, viewOptions);
11406
11445
  if (selectedStructs) {
11407
11446
  //return JSON.stringify(this.serialize(selectedStructs, viewOptions));
11408
- return JSON.stringify(selectedStructs.map(item => this.serialize(item, viewOptions)).filter(item => item));
11447
+ const serOptions = { excludeDel: true };
11448
+ return JSON.stringify(selectedStructs.map(item => this.serialize(item, viewOptions, serOptions)).filter(item => item));
11409
11449
  }
11410
11450
  else {
11411
11451
  return '';
@@ -17841,6 +17881,11 @@ class DocumentInput {
17841
17881
  this.onPasteEvent.next(evt);
17842
17882
  },
17843
17883
  cut: (evt) => {
17884
+ const event = new CopyElementEvent(this.docCtx);
17885
+ event.sourceEvent = evt;
17886
+ if (DocumentEvent.invokeEvent('ElementCut', this.docCtx.selectionState.startControl, event, 'All')) {
17887
+ return;
17888
+ }
17844
17889
  this.onCutEvent.next(evt);
17845
17890
  }
17846
17891
  };
@@ -19277,6 +19322,8 @@ class DocumentChange {
19277
19322
  console.log('粘贴反序列化数据失败', item);
19278
19323
  }
19279
19324
  });
19325
+ //清理track-run数据
19326
+ this.cleanTrackRun(pasteEles);
19280
19327
  if (!pasteEles.length) {
19281
19328
  return;
19282
19329
  }
@@ -19310,6 +19357,39 @@ class DocumentChange {
19310
19357
  this.selectionState.resetRange(lastEle, -1);
19311
19358
  }
19312
19359
  }
19360
+ /**
19361
+ * 整理数据:如果复制的数据包含留痕,需要把留痕的块替换为里面的文本内容
19362
+ * @param eles
19363
+ */
19364
+ cleanTrackRun(eles) {
19365
+ if (Array.isArray(eles)) {
19366
+ for (let i = 0; i < eles.length; i++) {
19367
+ const ele = eles[i];
19368
+ if (ele instanceof TrackRunElement) {
19369
+ const children = ElementUtil.getChildrenElements(ele).map(item => item.clone(true));
19370
+ eles.splice(i, 1, ...children);
19371
+ i--;
19372
+ continue;
19373
+ }
19374
+ this.cleanTrackRun(ele);
19375
+ }
19376
+ }
19377
+ else {
19378
+ if (eles instanceof BranchElement) {
19379
+ for (let j = 0; j < eles.length; j++) {
19380
+ const ele = eles.getChild(j);
19381
+ if (ele instanceof TrackRunElement) {
19382
+ const children = ElementUtil.getChildrenElements(ele).map(item => item.clone(true));
19383
+ children.forEach(item => ele.addChild(item, ele.getIndex()));
19384
+ eles.removeChild(ele);
19385
+ j--;
19386
+ continue;
19387
+ }
19388
+ this.cleanTrackRun(ele);
19389
+ }
19390
+ }
19391
+ }
19392
+ }
19313
19393
  /**
19314
19394
  * 处理表单模式下的粘贴事件
19315
19395
  * @param data 要粘贴的元素
@@ -19320,6 +19400,14 @@ class DocumentChange {
19320
19400
  // if (pasteString) {
19321
19401
  // this.pastePlainText(pasteString);
19322
19402
  // }
19403
+ //留痕模式下不支持粘贴格式
19404
+ if (this.viewOptions.enableTrackChanges) {
19405
+ const pasteString = data.map(item => ElementSerialize.serializeString(item)).join('');
19406
+ if (pasteString) {
19407
+ this.pastePlainText(pasteString);
19408
+ }
19409
+ return;
19410
+ }
19323
19411
  const { startControl, startOffset } = this.selectionState;
19324
19412
  const lastEle = this.insertElement(startControl, startOffset, data);
19325
19413
  this.selectionState.clear();
@@ -20586,10 +20674,13 @@ class EditorCalendarVNode {
20586
20674
  this.currMonth.value = new Date().getMonth();
20587
20675
  this.currCalendarMode.value = 'day';
20588
20676
  this.selectedDate.value = moment().format('YYYY-MM-DD');
20589
- this.currentDate = '';
20590
20677
  this.currTime.value = null;
20591
20678
  this.selectedTime.value = null;
20592
20679
  }
20680
+ clear() {
20681
+ this.reset();
20682
+ this.currentDate = '';
20683
+ }
20593
20684
  render(position, dataValue, format = 'YYYY-MM-DD HH:mm:ss') {
20594
20685
  format = format ?? 'YYYY-MM-DD HH:mm:ss';
20595
20686
  if (dataValue !== this.currentDate) {
@@ -20604,9 +20695,7 @@ class EditorCalendarVNode {
20604
20695
  this.currTime.value = currDataValue.format('HH:mm:ss');
20605
20696
  this.selectedTime.value = this.currTime.value;
20606
20697
  }
20607
- if (!this.currentDate) {
20608
- this.currentDate = moment().format('YYYY-MM-DD');
20609
- }
20698
+ if (!this.currentDate) ;
20610
20699
  if (!this.currTime.value) {
20611
20700
  this.currTime.value = moment().format('HH:mm:ss');
20612
20701
  this.selectedTime.value = this.currTime.value;
@@ -21055,7 +21144,7 @@ class EditorCalendarVNode {
21055
21144
  }
21056
21145
  getDays() {
21057
21146
  const days = [];
21058
- const nowStr = moment(this.currentDate).format('YYYY-MM-DD');
21147
+ const nowStr = moment().format('YYYY-MM-DD');
21059
21148
  //获取本月的第一天日期
21060
21149
  const firstDay = moment().set({ 'year': this.currYear.value, 'month': this.currMonth.value, 'date': 1 });
21061
21150
  firstDay.locale('zh-cn');
@@ -22337,6 +22426,8 @@ class DocEditor {
22337
22426
  docDblClickHandle(evt) {
22338
22427
  //1.如果在数据元中双击,则默认选中数据元内部的所有内容
22339
22428
  const currDataEle = this.getCurrentDataElement();
22429
+ //双击是否全选数据组内容
22430
+ const currDataGroup = this.viewOptions.dataGroupDblClickMode === 'selectall' ? this.getCurrentDataGroupElement() : null;
22340
22431
  if (currDataEle && currDataEle instanceof DataElementInlineGroup && currDataEle.length > 2 && this.selectionState.startControl instanceof TextGroupElement) {
22341
22432
  const range = new SelectionRange();
22342
22433
  range.setStart(currDataEle.startDecorate, 1);
@@ -22344,6 +22435,13 @@ class DocEditor {
22344
22435
  this.selectionState.addRange(range);
22345
22436
  this.flushToSchedule();
22346
22437
  }
22438
+ else if (currDataGroup && this.selectionState.startControl instanceof TextGroupElement) {
22439
+ const range = new SelectionRange();
22440
+ range.setStart(currDataGroup.startDecorate, 1);
22441
+ range.setEnd(currDataGroup.endDecorate, 0);
22442
+ this.selectionState.addRange(range);
22443
+ this.flushToSchedule();
22444
+ }
22347
22445
  else {
22348
22446
  //2.默认选词
22349
22447
  const res = getFocusTextSegment(this.selectionState);
@@ -23339,7 +23437,7 @@ class DocEditor {
23339
23437
  }
23340
23438
  return calendar.render(position, currVal);
23341
23439
  }
23342
- calendar.reset();
23440
+ calendar.clear();
23343
23441
  return null;
23344
23442
  }
23345
23443
  };
@@ -23419,7 +23517,7 @@ class DocEditor {
23419
23517
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
23420
23518
  }
23421
23519
  version() {
23422
- return "2.2.37";
23520
+ return "2.2.39";
23423
23521
  }
23424
23522
  switchPageHeaderEditor() {
23425
23523
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
@@ -29190,5 +29288,5 @@ function removeDuplicatesEvent(events) {
29190
29288
  return arr;
29191
29289
  }
29192
29290
 
29193
- 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, validateInlineDataEle, validateInlineInputRenderObj, watchChanged };
29291
+ 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, HLNode, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, InputElementEvent, IsInSideDataElement, IsInSideDataGroup, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LineElement, LineFactory, LineProps, LineRenderObject, LostCursorEvent, MarginProps, ModifyFlag, MouseElementEvent, MousedownElementEvent, MultiBlockLineRenderObject, NS, 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, validateInlineDataEle, validateInlineInputRenderObj, watchChanged };
29194
29292
  //# sourceMappingURL=index.js.map