@hailin-zheng/editor-core 2.2.37 → 2.2.38

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 '';
@@ -19277,6 +19317,8 @@ class DocumentChange {
19277
19317
  console.log('粘贴反序列化数据失败', item);
19278
19318
  }
19279
19319
  });
19320
+ //清理track-run数据
19321
+ this.cleanTrackRun(pasteEles);
19280
19322
  if (!pasteEles.length) {
19281
19323
  return;
19282
19324
  }
@@ -19310,6 +19352,39 @@ class DocumentChange {
19310
19352
  this.selectionState.resetRange(lastEle, -1);
19311
19353
  }
19312
19354
  }
19355
+ /**
19356
+ * 整理数据:如果复制的数据包含留痕,需要把留痕的块替换为里面的文本内容
19357
+ * @param eles
19358
+ */
19359
+ cleanTrackRun(eles) {
19360
+ if (Array.isArray(eles)) {
19361
+ for (let i = 0; i < eles.length; i++) {
19362
+ const ele = eles[i];
19363
+ if (ele instanceof TrackRunElement) {
19364
+ const children = ElementUtil.getChildrenElements(ele).map(item => item.clone(true));
19365
+ eles.splice(i, 1, ...children);
19366
+ i--;
19367
+ continue;
19368
+ }
19369
+ this.cleanTrackRun(ele);
19370
+ }
19371
+ }
19372
+ else {
19373
+ if (eles instanceof BranchElement) {
19374
+ for (let j = 0; j < eles.length; j++) {
19375
+ const ele = eles.getChild(j);
19376
+ if (ele instanceof TrackRunElement) {
19377
+ const children = ElementUtil.getChildrenElements(ele).map(item => item.clone(true));
19378
+ children.forEach(item => ele.addChild(item, ele.getIndex()));
19379
+ eles.removeChild(ele);
19380
+ j--;
19381
+ continue;
19382
+ }
19383
+ this.cleanTrackRun(ele);
19384
+ }
19385
+ }
19386
+ }
19387
+ }
19313
19388
  /**
19314
19389
  * 处理表单模式下的粘贴事件
19315
19390
  * @param data 要粘贴的元素
@@ -19320,6 +19395,14 @@ class DocumentChange {
19320
19395
  // if (pasteString) {
19321
19396
  // this.pastePlainText(pasteString);
19322
19397
  // }
19398
+ //留痕模式下不支持粘贴格式
19399
+ if (this.viewOptions.enableTrackChanges) {
19400
+ const pasteString = data.map(item => ElementSerialize.serializeString(item)).join('');
19401
+ if (pasteString) {
19402
+ this.pastePlainText(pasteString);
19403
+ }
19404
+ return;
19405
+ }
19323
19406
  const { startControl, startOffset } = this.selectionState;
19324
19407
  const lastEle = this.insertElement(startControl, startOffset, data);
19325
19408
  this.selectionState.clear();
@@ -20586,10 +20669,13 @@ class EditorCalendarVNode {
20586
20669
  this.currMonth.value = new Date().getMonth();
20587
20670
  this.currCalendarMode.value = 'day';
20588
20671
  this.selectedDate.value = moment().format('YYYY-MM-DD');
20589
- this.currentDate = '';
20590
20672
  this.currTime.value = null;
20591
20673
  this.selectedTime.value = null;
20592
20674
  }
20675
+ clear() {
20676
+ this.reset();
20677
+ this.currentDate = '';
20678
+ }
20593
20679
  render(position, dataValue, format = 'YYYY-MM-DD HH:mm:ss') {
20594
20680
  format = format ?? 'YYYY-MM-DD HH:mm:ss';
20595
20681
  if (dataValue !== this.currentDate) {
@@ -20604,9 +20690,7 @@ class EditorCalendarVNode {
20604
20690
  this.currTime.value = currDataValue.format('HH:mm:ss');
20605
20691
  this.selectedTime.value = this.currTime.value;
20606
20692
  }
20607
- if (!this.currentDate) {
20608
- this.currentDate = moment().format('YYYY-MM-DD');
20609
- }
20693
+ if (!this.currentDate) ;
20610
20694
  if (!this.currTime.value) {
20611
20695
  this.currTime.value = moment().format('HH:mm:ss');
20612
20696
  this.selectedTime.value = this.currTime.value;
@@ -21055,7 +21139,7 @@ class EditorCalendarVNode {
21055
21139
  }
21056
21140
  getDays() {
21057
21141
  const days = [];
21058
- const nowStr = moment(this.currentDate).format('YYYY-MM-DD');
21142
+ const nowStr = moment().format('YYYY-MM-DD');
21059
21143
  //获取本月的第一天日期
21060
21144
  const firstDay = moment().set({ 'year': this.currYear.value, 'month': this.currMonth.value, 'date': 1 });
21061
21145
  firstDay.locale('zh-cn');
@@ -22337,6 +22421,8 @@ class DocEditor {
22337
22421
  docDblClickHandle(evt) {
22338
22422
  //1.如果在数据元中双击,则默认选中数据元内部的所有内容
22339
22423
  const currDataEle = this.getCurrentDataElement();
22424
+ //双击是否全选数据组内容
22425
+ const currDataGroup = this.viewOptions.dataGroupDblClickMode === 'selectall' ? this.getCurrentDataGroupElement() : null;
22340
22426
  if (currDataEle && currDataEle instanceof DataElementInlineGroup && currDataEle.length > 2 && this.selectionState.startControl instanceof TextGroupElement) {
22341
22427
  const range = new SelectionRange();
22342
22428
  range.setStart(currDataEle.startDecorate, 1);
@@ -22344,6 +22430,13 @@ class DocEditor {
22344
22430
  this.selectionState.addRange(range);
22345
22431
  this.flushToSchedule();
22346
22432
  }
22433
+ else if (currDataGroup && this.selectionState.startControl instanceof TextGroupElement) {
22434
+ const range = new SelectionRange();
22435
+ range.setStart(currDataGroup.startDecorate, 1);
22436
+ range.setEnd(currDataGroup.endDecorate, 0);
22437
+ this.selectionState.addRange(range);
22438
+ this.flushToSchedule();
22439
+ }
22347
22440
  else {
22348
22441
  //2.默认选词
22349
22442
  const res = getFocusTextSegment(this.selectionState);
@@ -23339,7 +23432,7 @@ class DocEditor {
23339
23432
  }
23340
23433
  return calendar.render(position, currVal);
23341
23434
  }
23342
- calendar.reset();
23435
+ calendar.clear();
23343
23436
  return null;
23344
23437
  }
23345
23438
  };
@@ -23419,7 +23512,7 @@ class DocEditor {
23419
23512
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
23420
23513
  }
23421
23514
  version() {
23422
- return "2.2.37";
23515
+ return "2.2.38";
23423
23516
  }
23424
23517
  switchPageHeaderEditor() {
23425
23518
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
@@ -29190,5 +29283,5 @@ function removeDuplicatesEvent(events) {
29190
29283
  return arr;
29191
29284
  }
29192
29285
 
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 };
29286
+ 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
29287
  //# sourceMappingURL=index.js.map