@hailin-zheng/editor-core 1.0.61 → 1.0.62

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
@@ -1463,6 +1463,8 @@ class ViewOptions {
1463
1463
  pageNumOffset = 0;
1464
1464
  //页排版模式:单页模式、多页模式、适应页宽模式
1465
1465
  pageLayoutMode = 'singlePage';
1466
+ //默认tab缩进的量
1467
+ defaultIndent = 20;
1466
1468
  //内容区宽度,受审阅窗口宽度影响
1467
1469
  get contentWidth() {
1468
1470
  if (this.showReviewWindow) {
@@ -1725,6 +1727,12 @@ class TextProps extends INotifyPropertyChanged {
1725
1727
  && this.border === props.border;
1726
1728
  }
1727
1729
  }
1730
+ var ParagraphNumberType;
1731
+ (function (ParagraphNumberType) {
1732
+ ParagraphNumberType[ParagraphNumberType["none"] = -1] = "none";
1733
+ ParagraphNumberType[ParagraphNumberType["ul"] = 0] = "ul";
1734
+ ParagraphNumberType[ParagraphNumberType["ol"] = 1] = "ol";
1735
+ })(ParagraphNumberType || (ParagraphNumberType = {}));
1728
1736
  class ParagraphProps extends INotifyPropertyChanged {
1729
1737
  //段落默认的文本属性
1730
1738
  //textProps!: TextProps;
@@ -1732,7 +1740,7 @@ class ParagraphProps extends INotifyPropertyChanged {
1732
1740
  hanging = 0;
1733
1741
  lineHeight = 1.3;
1734
1742
  textAlign = 'left';
1735
- numberType = -1;
1743
+ numberType = ParagraphNumberType.none;
1736
1744
  pageBreak = false;
1737
1745
  clone(dest = null) {
1738
1746
  const clone = dest ?? new ParagraphProps();
@@ -1760,7 +1768,7 @@ class ParagraphProps extends INotifyPropertyChanged {
1760
1768
  if (this.textAlign && this.textAlign !== "left") {
1761
1769
  props["textAlign"] = this.textAlign;
1762
1770
  }
1763
- if (this.numberType !== -1) {
1771
+ if (this.numberType !== ParagraphNumberType.none) {
1764
1772
  props["numberType"] = this.numberType;
1765
1773
  }
1766
1774
  if (this.pageBreak) {
@@ -2370,6 +2378,13 @@ class ValidateProps {
2370
2378
  id;
2371
2379
  title;
2372
2380
  msg;
2381
+ clone(dest) {
2382
+ const clone = dest ?? new ValidateProps();
2383
+ clone.id = this.id;
2384
+ clone.title = this.title;
2385
+ clone.msg = this.msg;
2386
+ return clone;
2387
+ }
2373
2388
  }
2374
2389
  class DataElementGroupProps {
2375
2390
  id;
@@ -3292,6 +3307,19 @@ class ParagraphElement extends BlockContentElement {
3292
3307
  }
3293
3308
  }
3294
3309
  }, true);
3310
+ this.addEvent('ElementKeyDown', evt => {
3311
+ //当前存在缩进,点击tab
3312
+ if (evt.sourceEvent.keyCode === 9) {
3313
+ const { startControl, startOffset } = evt.selectionState;
3314
+ if (startOffset === 0 && startControl === this.getChild(0)) {
3315
+ const defaultIndent = evt.ctx.viewOptions.defaultIndent;
3316
+ let increaseValue = evt.sourceEvent.shiftKey ? -defaultIndent : defaultIndent;
3317
+ this.props.indent += increaseValue;
3318
+ evt.isCancel = true;
3319
+ evt.sourceEvent.preventDefault();
3320
+ }
3321
+ }
3322
+ }, true);
3295
3323
  }
3296
3324
  /**
3297
3325
  * 设置样式
@@ -3339,25 +3367,39 @@ class ParagraphRenderObject extends MuiltBlockLineRenderObject {
3339
3367
  */
3340
3368
  drawProjectNumber(ctx, viewOptions) {
3341
3369
  const paraElement = this.element;
3342
- if (paraElement.props.numberType >= 0) {
3370
+ if (paraElement.props.numberType !== ParagraphNumberType.none) {
3343
3371
  if (paraElement.paintRenders.indexOf(this) > 0) {
3344
3372
  return;
3345
3373
  }
3346
3374
  const firstLine = this.getChild(0);
3347
- if (!firstLine) {
3348
- debugger;
3349
- }
3350
3375
  const firstInline = firstLine.getChild(0);
3351
- if (!firstInline) {
3352
- debugger;
3353
- }
3354
3376
  const firstInlinePaintPos = ElementUtil.getRenderAbsolutePaintPos(firstInline, {
3355
3377
  x: 0,
3356
3378
  y: -viewOptions.translateY
3357
3379
  });
3358
- const numberSymbolY = firstInlinePaintPos.y + Math.ceil(firstInline.rect.height / 2);
3359
- //ctx.contentContext.drawText(str, textProps, firstInlinePaintPos.x - paraElement.paraProps.indent, numberSymbolY, 14, 14);
3360
- ctx.contentContext.fillCircular(firstInlinePaintPos.x - paraElement.props.indent + 2, numberSymbolY, 4);
3380
+ if (paraElement.props.numberType === ParagraphNumberType.ul) {
3381
+ const numberSymbolY = firstInlinePaintPos.y + Math.ceil(firstInline.rect.height / 2);
3382
+ ctx.contentContext.fillCircular(firstInlinePaintPos.x - paraElement.props.indent + 2, numberSymbolY, 4);
3383
+ }
3384
+ else if (paraElement.props.numberType === ParagraphNumberType.ol) {
3385
+ const parent = paraElement.parent;
3386
+ let i = paraElement.getIndex() - 1;
3387
+ for (; i >= 0; i--) {
3388
+ if (parent.getChild(i) instanceof ParagraphElement) {
3389
+ //紧挨上面的段落
3390
+ const prevSiblingPara = parent.getChild(i);
3391
+ if (prevSiblingPara.props.numberType !== paraElement.props.numberType || prevSiblingPara.props.indent !== paraElement.props.indent) {
3392
+ break;
3393
+ }
3394
+ }
3395
+ }
3396
+ const olText = (paraElement.getIndex() - i) + '.';
3397
+ const textProps = new TextProps();
3398
+ textProps.color = '#000';
3399
+ textProps.fontSize = firstInline.rect.height - 4;
3400
+ textProps.fontName = '宋体';
3401
+ ctx.contentContext.drawText(olText, textProps, firstInlinePaintPos.x - paraElement.props.indent + 2, firstInlinePaintPos.y + 2, 40, textProps.fontSize);
3402
+ }
3361
3403
  }
3362
3404
  }
3363
3405
  clone() {
@@ -7036,7 +7078,14 @@ class CommContentElement extends CommContentBaseElement {
7036
7078
  };
7037
7079
  }
7038
7080
  clone(data) {
7039
- throw new Error('不支持');
7081
+ const clone = new CommContentElement();
7082
+ this.props.clone(clone.props);
7083
+ if (data) {
7084
+ for (let i = 0; i < this.length; i++) {
7085
+ clone.addChild(this.getChild(i).clone(true));
7086
+ }
7087
+ }
7088
+ return clone;
7040
7089
  }
7041
7090
  }
7042
7091
  class CommContentRenderObject extends CommContentBaseRenderObject {
@@ -7052,7 +7101,10 @@ class CommContentRenderObject extends CommContentBaseRenderObject {
7052
7101
  });
7053
7102
  const commMarkLinePos = ElementUtil.getParaLinePos(this.commMarkRender.render, commMarkPos);
7054
7103
  commMarkPos.y = commMarkLinePos.y + 2;
7055
- const docRenderPos = ElementUtil.getRenderAbsolutePaintPos(docRender, { x: 0, y: -e.docCtx.viewOptions.translateY });
7104
+ const docRenderPos = ElementUtil.getRenderAbsolutePaintPos(docRender, {
7105
+ x: 0,
7106
+ y: -e.docCtx.viewOptions.translateY
7107
+ });
7056
7108
  const marginLeft = commMarkPos.x - docRenderPos.x - docRender.padding.left;
7057
7109
  const marginRight = e.docCtx.viewOptions.docPageSettings.width - marginLeft - docRender.padding.right * 2;
7058
7110
  e.render.overlaysContext.drawDashLine([commMarkPos, {
@@ -7249,7 +7301,14 @@ class ValidateElement extends CommContentBaseElement {
7249
7301
  return null;
7250
7302
  }
7251
7303
  clone(data) {
7252
- throw new Error("Method not implemented.");
7304
+ const clone = new ValidateElement();
7305
+ this.props.clone(clone.props);
7306
+ if (data) {
7307
+ for (let i = 0; i < this.length; i++) {
7308
+ clone.addChild(this.getChild(i).clone(true));
7309
+ }
7310
+ }
7311
+ return clone;
7253
7312
  }
7254
7313
  setContent(content) {
7255
7314
  this.clearItems();
@@ -11657,63 +11716,6 @@ class DocumentPaint {
11657
11716
  }
11658
11717
  }
11659
11718
 
11660
- /**
11661
- * 段落行
11662
- */
11663
- class ParaLineElement extends LeafElement {
11664
- constructor() {
11665
- super('p-line');
11666
- this.props = new ParaLineProps();
11667
- }
11668
- clone(data) {
11669
- const clone = new ParaLineElement();
11670
- this.props.clone(clone.props);
11671
- return clone;
11672
- }
11673
- createRenderObject(options, renderCtx) {
11674
- const render = new ParaLineRenderObject(this);
11675
- render.rect.width = 9999;
11676
- return render;
11677
- }
11678
- serialize(viewOptions) {
11679
- return {
11680
- type: this.type,
11681
- props: {
11682
- ...this.props
11683
- }
11684
- };
11685
- }
11686
- }
11687
- class ParaLineRenderObject extends LeafRenderObject {
11688
- clone() {
11689
- const clone = new ParaLineRenderObject(this.element);
11690
- clone.rect = ElementUtil.cloneRect(this.rect);
11691
- return clone;
11692
- }
11693
- render(e) {
11694
- const { render, position } = e;
11695
- render.contentContext.drawHoriLine(position.x, position.y, this.parent.rect.width, 'black', 1);
11696
- }
11697
- }
11698
- class ParaLineElementFactory extends ElementFactory {
11699
- createElement(data, renderCtx) {
11700
- const ele = new ParaLineElement();
11701
- ele.props.lineType = data.props?.lineType ?? 'solid';
11702
- return ele;
11703
- }
11704
- match(type) {
11705
- return type === 'p-line';
11706
- }
11707
- }
11708
- class ParaLineProps {
11709
- lineType = 'solid';
11710
- clone(dest) {
11711
- const clone = dest ?? new ParaLineProps();
11712
- clone.lineType = this.lineType;
11713
- return clone;
11714
- }
11715
- }
11716
-
11717
11719
  class ElementReader {
11718
11720
  docCtx;
11719
11721
  renderCtx;
@@ -11755,7 +11757,6 @@ class ElementReader {
11755
11757
  this.addFactory(RunElementFactory);
11756
11758
  this.addFactory(DataElementGroupFactory);
11757
11759
  this.addFactory(DocumentBodyPartFactory);
11758
- this.addFactory(ParaLineElementFactory);
11759
11760
  // this.registerReadFunc<TrackRunProps>('ins-run', (data) => {
11760
11761
  // const props = new TrackRunProps(data.type);
11761
11762
  // props.userId = data.userId;
@@ -14435,12 +14436,12 @@ class DocumentChange {
14435
14436
  }
14436
14437
  const para = ElementUtil.getParentByType(startControl, ParagraphElement);
14437
14438
  const format = {};
14438
- if (para.props.numberType >= 0) {
14439
- format.numberType = -1;
14439
+ if (para.props.numberType !== ParagraphNumberType.none) {
14440
+ format.numberType = ParagraphNumberType.none;
14440
14441
  format.indent = 0;
14441
14442
  }
14442
14443
  else {
14443
- format.numberType = 0;
14444
+ format.numberType = ParagraphNumberType.ul;
14444
14445
  format.indent = 15;
14445
14446
  }
14446
14447
  para.setFormat(format);
@@ -16659,27 +16660,6 @@ class CanvasTextEditor {
16659
16660
  }
16660
16661
  this.flushToSchedule();
16661
16662
  }
16662
- test2() {
16663
- //获取文档上下文
16664
- const docEleCtx = this.docCtx.getCtx(this.docCtx.document);
16665
- //获取年龄数据元
16666
- const dataEle = docEleCtx.getControlById('1493477712134672386');
16667
- //获取要隐藏的数据组
16668
- const dataGroup = docEleCtx.ctx.treeFind((item) => item instanceof DataElementGroupElement);
16669
- //侦听数据元更改时间
16670
- dataEle.onChangeSubject.subscribe((e) => {
16671
- //在文档重新排版、绘制前,获取最终的指定节点的内容
16672
- const beforeRefreshSub = this.onBeforeRefreshDocument.subscribe((e2) => {
16673
- console.log('内容发生改变,隐藏数据组');
16674
- //获取年龄数据元输入的值
16675
- const age = Number.parseInt(dataEle.getValue());
16676
- //年龄大于20,隐藏数据元
16677
- dataGroup.props.hidden = age > 20;
16678
- //取消订阅事件
16679
- beforeRefreshSub.unsubscribe();
16680
- });
16681
- });
16682
- }
16683
16663
  }
16684
16664
 
16685
16665
  /**
@@ -16963,5 +16943,5 @@ function removeDuplicatesEvent(events) {
16963
16943
  return arr;
16964
16944
  }
16965
16945
 
16966
- export { BlockContainerElement, BlockContainerRenderObject, BlockContentElement, BlockContentRenderObject, BlockLineRectRenderObject, BodyPartProps, BooleanEnum, BorderProps, BranchElement, BranchRenderObject, BreakElement, BreakFactory, BreakRenderObject, CanvasTextEditor, CheckBoxElement, CheckBoxFactory, CheckBoxProps, CheckBoxRenderObject, ColumnPatchUtil, CommContentBaseElement, CommContentBaseRenderObject, CommContentElement, CommContentProps, CommContentRenderObject, CommProps, CommentContentFactory, CommentElement, CommentFactory, CommentRenderObject, CommentsFactory, CommentsUtil, CommonUtil, CommsContainerElement, CommsContainerRenderObject, ContentMenuItem, ContextMenuElementEvent, DOMEventSource, DOMSubscription, 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, DocMode, DocRule, DocumentBodyElement, DocumentBodyFactory, DocumentBodyPartElement, DocumentBodyPartFactory, DocumentBodyPartRenderObject, DocumentBodyRenderObject, DocumentChange, DocumentCombine, DocumentComment, DocumentContainerRender, DocumentContext, DocumentCursor, DocumentElement, DocumentEvalFunc, DocumentEvent, DocumentFactory, DocumentFooterElement, DocumentFooterFactory, DocumentFooterRenderObject, DocumentHeaderElement, DocumentHeaderFactory, DocumentHeaderRenderObject, DocumentImagesBaseLoader, DocumentImagesLoader, DocumentInput, DocumentPaint, DocumentPrintOffscreen, DocumentPrintOffscreenBase, DocumentProps, DocumentRenderObject, DocumentSelection, DocumentTemplate, DropElementEvent, EditMode, EditorContext, Element, ElementEvent, ElementFactory, ElementMeasure, ElementPaint, ElementReader, ElementRenderCut, ElementSerialize, ElementUtil, EventMap, EventSourceCore, FillNullSpaceElement, FillNullSpaceRenderObject, GetTrackTipsEvent, GotCursorEvent, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, IsInSideDataElement, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag, MouseElementEvent, MousedownElementEvent, MuiltBlockLineRenderObject, PSymbolElement, PSymbolRenderObject, PaddingProps, PageOptions, PaintContent, ParagraphElement, ParagraphFactory, ParagraphLineRectRenderObject, ParagraphProps, ParagraphRenderObject, PictureElement, PictureFactory, PictureProps, PictureRenderObject, RadioBoxElement, RadioBoxFactory, RadioBoxProps, RadioBoxRenderObject, RangeUtil, Rect, RenderContext, RenderObject, RenderObjectType, ResizeLeafRenderObject, RunElementFactory, SelectionOverlays, SelectionRange, SelectionState, Subject, SubjectSubscription, Subscription, TableCellElement, TableCellFactory, TableCellProps, TableCellRenderObject, TableElement, TableFactory, TableProps, TableRenderObject, TableRowElement, TableRowFactory, TableRowProps, TableRowRenderObject, TableSplitCell, TableUtil, TextGroupElement, TextGroupFactory, TextGroupRenderObject, TextProps, TrackRunElement, TrackRunProps, TrackRunRenderObject, TrackRunTypeEnum, ValidateCondition, ValidateElement, ValidateProps, ValidateRenderObject, ViewOptions, createPrintTemplate, deleteCurrentParagraph, documentPrint, elementTypeEventHandler, fontMapFunc, fromEvent, getFocusTextSegment, invokeTypeHandler, isDate, objectToString, onTableContextmenu, onceTask, printDocOnContextmenu, printNodes, reactiveMap, runTextLineRender, setDataElementProps, setNotifyChangedCallback, targetMaps, textLineRenderMode, toRawType, toTypeString, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
16946
+ export { BlockContainerElement, BlockContainerRenderObject, BlockContentElement, BlockContentRenderObject, BlockLineRectRenderObject, BodyPartProps, BooleanEnum, BorderProps, BranchElement, BranchRenderObject, BreakElement, BreakFactory, BreakRenderObject, CanvasTextEditor, CheckBoxElement, CheckBoxFactory, CheckBoxProps, CheckBoxRenderObject, ColumnPatchUtil, CommContentBaseElement, CommContentBaseRenderObject, CommContentElement, CommContentProps, CommContentRenderObject, CommProps, CommentContentFactory, CommentElement, CommentFactory, CommentRenderObject, CommentsFactory, CommentsUtil, CommonUtil, CommsContainerElement, CommsContainerRenderObject, ContentMenuItem, ContextMenuElementEvent, DOMEventSource, DOMSubscription, 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, DocMode, DocRule, DocumentBodyElement, DocumentBodyFactory, DocumentBodyPartElement, DocumentBodyPartFactory, DocumentBodyPartRenderObject, DocumentBodyRenderObject, DocumentChange, DocumentCombine, DocumentComment, DocumentContainerRender, DocumentContext, DocumentCursor, DocumentElement, DocumentEvalFunc, DocumentEvent, DocumentFactory, DocumentFooterElement, DocumentFooterFactory, DocumentFooterRenderObject, DocumentHeaderElement, DocumentHeaderFactory, DocumentHeaderRenderObject, DocumentImagesBaseLoader, DocumentImagesLoader, DocumentInput, DocumentPaint, DocumentPrintOffscreen, DocumentPrintOffscreenBase, DocumentProps, DocumentRenderObject, DocumentSelection, DocumentTemplate, DropElementEvent, EditMode, EditorContext, Element, ElementEvent, ElementFactory, ElementMeasure, ElementPaint, ElementReader, ElementRenderCut, ElementSerialize, ElementUtil, EventMap, EventSourceCore, FillNullSpaceElement, FillNullSpaceRenderObject, GetTrackTipsEvent, GotCursorEvent, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, IsInSideDataElement, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag, MouseElementEvent, MousedownElementEvent, MuiltBlockLineRenderObject, PSymbolElement, PSymbolRenderObject, PaddingProps, PageOptions, PaintContent, ParagraphElement, ParagraphFactory, ParagraphLineRectRenderObject, ParagraphNumberType, ParagraphProps, ParagraphRenderObject, PictureElement, PictureFactory, PictureProps, PictureRenderObject, RadioBoxElement, RadioBoxFactory, RadioBoxProps, RadioBoxRenderObject, RangeUtil, Rect, RenderContext, RenderObject, RenderObjectType, ResizeLeafRenderObject, RunElementFactory, SelectionOverlays, SelectionRange, SelectionState, Subject, SubjectSubscription, Subscription, TableCellElement, TableCellFactory, TableCellProps, TableCellRenderObject, TableElement, TableFactory, TableProps, TableRenderObject, TableRowElement, TableRowFactory, TableRowProps, TableRowRenderObject, TableSplitCell, TableUtil, TextGroupElement, TextGroupFactory, TextGroupRenderObject, TextProps, TrackRunElement, TrackRunProps, TrackRunRenderObject, TrackRunTypeEnum, ValidateCondition, ValidateElement, ValidateProps, ValidateRenderObject, ViewOptions, createPrintTemplate, deleteCurrentParagraph, documentPrint, elementTypeEventHandler, fontMapFunc, fromEvent, getFocusTextSegment, invokeTypeHandler, isDate, objectToString, onTableContextmenu, onceTask, printDocOnContextmenu, printNodes, reactiveMap, runTextLineRender, setDataElementProps, setNotifyChangedCallback, targetMaps, textLineRenderMode, toRawType, toTypeString, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
16967
16947
  //# sourceMappingURL=index.js.map