@hailin-zheng/editor-core 2.2.2 → 2.2.4

Sign up to get free protection for your applications and to get access to all the features.
package/index.js CHANGED
@@ -40,9 +40,9 @@ class ElementEvent {
40
40
  }
41
41
  }
42
42
  class ContentMenuItem {
43
- icon;
44
43
  caption;
45
- eventObj;
44
+ checked;
45
+ click = () => { };
46
46
  subItems = [];
47
47
  }
48
48
  /**
@@ -973,6 +973,12 @@ function generatePatch(doc, clear = true) {
973
973
  if ('insert' in op.ops) {
974
974
  insertOpsMap.set(ele, op);
975
975
  }
976
+ //当前为新插入的元素
977
+ if ('insText' in op.ops) {
978
+ if (insertOpsMap.has(ele)) {
979
+ continue;
980
+ }
981
+ }
976
982
  // if ('insert' in op.ops) {
977
983
  // op.ops.insert = ele.clone(true);
978
984
  // const log = getOpsLog(ele, op.ops);
@@ -1028,7 +1034,11 @@ class Subscription {
1028
1034
  class EventSourceCore {
1029
1035
  closed = false;
1030
1036
  subs = [];
1037
+ state = 'running';
1031
1038
  next(data) {
1039
+ if (this.state === 'pause') {
1040
+ return;
1041
+ }
1032
1042
  const subs = [...this.subs];
1033
1043
  subs.forEach((sub) => {
1034
1044
  sub.invoke(data);
@@ -1172,6 +1182,8 @@ class Rect {
1172
1182
  width = 0;
1173
1183
  height = 0;
1174
1184
  }
1185
+ // 定义文本占用高度系数
1186
+ const TEXT_HEIGHT_FACTOR = 1.4;
1175
1187
  /**
1176
1188
  * 修改标志
1177
1189
  */
@@ -1674,6 +1686,7 @@ class PageOptions {
1674
1686
  }
1675
1687
  class ViewOptions {
1676
1688
  copyRightInfo;
1689
+ trialVersion = false;
1677
1690
  watermark;
1678
1691
  drawLineRectColor = "rgb(0,0,0)";
1679
1692
  drawCharRectColor = "rgb(0,0,0)";
@@ -1682,6 +1695,8 @@ class ViewOptions {
1682
1695
  editorVersion = '';
1683
1696
  defaultFontSize = 14;
1684
1697
  defaultColor = "#000000";
1698
+ currentFontSize = 14;
1699
+ currentFontName = '宋体';
1685
1700
  selectionOverlaysColor = 'rgb(131,175,155,0.5)';
1686
1701
  dataEleOverlaysColor = 'rgb(131,175,155,0.5)';
1687
1702
  dataEleFocusedBgColor = 'rgb(131,175,155,0.8)';
@@ -1732,6 +1747,7 @@ class ViewOptions {
1732
1747
  //显示段落回车符号
1733
1748
  showEnterSymbol = false;
1734
1749
  enableVisibleExpression = false;
1750
+ shapeRendering = 'auto';
1735
1751
  get fullPageView() {
1736
1752
  return this._fullPageView;
1737
1753
  }
@@ -1779,6 +1795,8 @@ class ViewOptions {
1779
1795
  _showTrackChanges = true;
1780
1796
  //是否显示审阅痕迹提示
1781
1797
  _showTrackChangesTip = true;
1798
+ //是否开启留痕
1799
+ enableTrackChanges = false;
1782
1800
  get showTrackChanges() {
1783
1801
  return this._showTrackChanges;
1784
1802
  }
@@ -1807,6 +1825,8 @@ class ViewOptions {
1807
1825
  onChange = new Subject();
1808
1826
  //打印模式,普通模式,续打模式
1809
1827
  printMode = 'normal';
1828
+ //是否开启候选词输入联想
1829
+ enableSuggestions = false;
1810
1830
  constructor() {
1811
1831
  }
1812
1832
  }
@@ -2889,7 +2909,7 @@ class DataDecorateElement extends LeafElement {
2889
2909
  createRenderObject() {
2890
2910
  const render = new DataDecorateRenderObject(this);
2891
2911
  //render.rect.width = this.dProps.size / 2;
2892
- render.rect.width = 3;
2912
+ render.rect.width = 1;
2893
2913
  render.rect.height = 14;
2894
2914
  return render;
2895
2915
  }
@@ -3626,6 +3646,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3626
3646
  };
3627
3647
  const pageCorner = this.exportPageCornerHTML(event);
3628
3648
  const pageNum = this.exportPageNumHTML(event);
3649
+ const copyright = this.exportCopyRight(event);
3629
3650
  return {
3630
3651
  sel: "svg",
3631
3652
  isCompleted: true,
@@ -3636,11 +3657,11 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3636
3657
  height: this.rect.height - 1,
3637
3658
  viewBox: `0 0 ${this.rect.width} ${this.rect.height - 1}`,
3638
3659
  overflow: "hidden",
3639
- "shape-rendering": "optimizeSpeed"
3660
+ "shape-rendering": event.options.shapeRendering
3640
3661
  },
3641
3662
  },
3642
3663
  children: [
3643
- pageCorner, highlight, ...CommonUtil.toArray(event.getChildNodes(this)), pageNum, selection
3664
+ pageCorner, copyright, highlight, ...CommonUtil.toArray(event.getChildNodes(this)), pageNum, selection
3644
3665
  ]
3645
3666
  };
3646
3667
  }
@@ -3672,6 +3693,41 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3672
3693
  pageCorner.children?.push(ElementUtil.getStrokeSvgPath(`M ${paddingPos.x + lineWidth} ${paddingPos.y} L ${paddingPos.x} ${paddingPos.y} L ${paddingPos.x} ${paddingPos.y + lineWidth}`, "grey", drawLineWidth));
3673
3694
  return pageCorner;
3674
3695
  }
3696
+ exportCopyRight(event) {
3697
+ if (!event.options.trialVersion) {
3698
+ return null;
3699
+ }
3700
+ const str = "\u6f14\u793a\u7248\u672c";
3701
+ const textProps = new TextProps();
3702
+ textProps.color = "#000";
3703
+ textProps.fontName = '仿宋';
3704
+ textProps.fontSize = 80;
3705
+ textProps.fontStyle = 'italic';
3706
+ event.renderCtx.contentContext.measureText(str, textProps);
3707
+ const getTextRotationAngle = (width, height) => {
3708
+ return Math.atan(height / width) * 180 / Math.PI;
3709
+ };
3710
+ const angle = getTextRotationAngle(this.rect.width, this.rect.height);
3711
+ return {
3712
+ sel: 'text',
3713
+ text: str,
3714
+ data: {
3715
+ ns: "http://www.w3.org/2000/svg",
3716
+ attrs: {
3717
+ transform: `rotate(${360 - angle})`,
3718
+ 'transform-origin': 'center',
3719
+ 'dominant-baseline': 'Hanging',
3720
+ 'text-anchor': 'middle',
3721
+ 'font-family': textProps.fontName,
3722
+ 'font-size': textProps.fontSize,
3723
+ "stroke": textProps.color,
3724
+ 'fill': '#fff',
3725
+ x: this.rect.width / 2,
3726
+ y: this.rect.height / 2,
3727
+ }
3728
+ },
3729
+ };
3730
+ }
3675
3731
  }
3676
3732
  class DocumentFactory extends ElementFactory {
3677
3733
  match(type) {
@@ -4182,8 +4238,6 @@ function getCurrentParaGroupRenders(r) {
4182
4238
  }
4183
4239
 
4184
4240
  class DocumentBodyElement extends BlockContainerElement {
4185
- //当前区域内是否留痕
4186
- trackChanges = false;
4187
4241
  constructor() {
4188
4242
  super('body');
4189
4243
  //this.editMode = EditMode.Free;
@@ -4308,7 +4362,6 @@ class TableCellElement extends BlockContainerElement {
4308
4362
  //this.addPropValueChangedSub(this.props);
4309
4363
  }
4310
4364
  beginMeasure(data) {
4311
- //不被合并的单元格
4312
4365
  if (!this.length) {
4313
4366
  this.addChild(data.createParaFn());
4314
4367
  }
@@ -4678,7 +4731,7 @@ class TextGroupRenderObject extends LeafRenderObject {
4678
4731
  }
4679
4732
  measure() {
4680
4733
  this.rect.width = this.textMeasures.reduce((prev, curr) => prev + curr.actualSize, 0);
4681
- this.rect.height = Math.ceil(this.element.props.fontSize * 1.4);
4734
+ this.rect.height = Math.ceil(this.element.props.fontSize * TEXT_HEIGHT_FACTOR);
4682
4735
  // this.element.fontBoundingBox.fontBoundingBoxAscent + this.element.fontBoundingBox.fontBoundingBoxDescent;
4683
4736
  }
4684
4737
  exportSVG(event) {
@@ -6600,17 +6653,20 @@ class DocumentSelection {
6600
6653
  ss.endOffset = range.endOffset;
6601
6654
  ss.endControlIndex = ElementUtil.getControlIndex(range.endControl);
6602
6655
  ss.ancestorCommonControl = DocumentSelection.getAncestorCommonControl(ss.startControl, ss.endControl);
6603
- ss.enableTrackChanges = this.getEnableTrackChanges(range.startControl);
6604
6656
  ss.rangeDirty = false;
6605
6657
  return true;
6606
6658
  }
6607
- /**
6608
- * 获取当前选区区域内是否支持留痕
6609
- * @private
6610
- */
6611
- getEnableTrackChanges(ele) {
6612
- const body = ElementUtil.getParentByType(ele, DocumentBodyElement);
6613
- return body?.trackChanges || false;
6659
+ isSelectionChanged() {
6660
+ if (!this.snapshotSelectionState) {
6661
+ return true;
6662
+ }
6663
+ if (this.selectionState.startControl !== this.snapshotSelectionState.startControl || this.selectionState.startOffset !== this.snapshotSelectionState.startOffset) {
6664
+ return true;
6665
+ }
6666
+ if (this.selectionState.endControl !== this.snapshotSelectionState.endControl || this.selectionState.endOffset !== this.snapshotSelectionState.endOffset) {
6667
+ return true;
6668
+ }
6669
+ return false;
6614
6670
  }
6615
6671
  /**
6616
6672
  * 转换选区内容
@@ -6707,8 +6763,6 @@ class SelectionState {
6707
6763
  renderContainer;
6708
6764
  //光标所在的位置,当前位置时相对文档的位置,而非DOM页面中的位置
6709
6765
  cursorPos;
6710
- //当前选区的上下文是否支持留痕修改
6711
- enableTrackChanges = false;
6712
6766
  constructor() {
6713
6767
  this.clear();
6714
6768
  }
@@ -8416,7 +8470,10 @@ class DataElementDate extends DataElementInlineGroup {
8416
8470
  this.props.value = '';
8417
8471
  return;
8418
8472
  }
8419
- const format = this.props.format ?? 'YYYY-MM-DD';
8473
+ let format = 'YYYY-MM-DD';
8474
+ if (this.props.format) {
8475
+ format = this.props.format;
8476
+ }
8420
8477
  const date = moment(val, format);
8421
8478
  if (!date.isValid()) {
8422
8479
  return;
@@ -8947,6 +9004,102 @@ class DataElementTextFactory extends DataElementBaseFactory {
8947
9004
  }
8948
9005
  }
8949
9006
 
9007
+ /**
9008
+ * 数据块容器,包裹多个段落
9009
+ */
9010
+ class DataContainerElement extends BlockContainerElement {
9011
+ constructor() {
9012
+ super('data-container');
9013
+ this.props = new DataContainerProps();
9014
+ this.addEvent('GotCursor', (evt) => {
9015
+ this.isFocused = true;
9016
+ this.refreshView();
9017
+ });
9018
+ this.addEvent('LostCursor', (evt) => {
9019
+ this.isFocused = false;
9020
+ this.refreshView();
9021
+ });
9022
+ }
9023
+ createRenderObject() {
9024
+ return new DataContainerRenderObject(this);
9025
+ }
9026
+ beginMeasure(data) {
9027
+ if (!this.length) {
9028
+ this.addChild(data.createParaFn());
9029
+ }
9030
+ super.beginMeasure(data);
9031
+ }
9032
+ serialize() {
9033
+ const p = {
9034
+ type: this.type,
9035
+ props: {}
9036
+ };
9037
+ if (this.props.id) {
9038
+ p['id'] = this.props.id;
9039
+ }
9040
+ if (this.props.name) {
9041
+ p['name'] = this.props.name;
9042
+ }
9043
+ if (this.props.caption) {
9044
+ p['caption'] = this.props.caption;
9045
+ }
9046
+ return p;
9047
+ }
9048
+ clone(data) {
9049
+ const clone = new DataContainerElement();
9050
+ clone.props.id = this.props.id;
9051
+ clone.props.name = this.props.name;
9052
+ clone.props.caption = this.props.caption;
9053
+ cloneElementBase(this, clone);
9054
+ cloneChildren(this, clone, data);
9055
+ return clone;
9056
+ }
9057
+ }
9058
+ class DataContainerRenderObject extends MuiltBlockLineRenderObject {
9059
+ clone(cloneData = true) {
9060
+ const cloneRender = new DataContainerRenderObject(this.element);
9061
+ cloneRender.rect = ElementUtil.cloneRect(this.rect);
9062
+ if (cloneData) {
9063
+ for (let i = 0; i < this.length; i++) {
9064
+ cloneRender.addChild(this.getChild(i).clone());
9065
+ }
9066
+ }
9067
+ return cloneRender;
9068
+ }
9069
+ exportSVG(event) {
9070
+ const t = super.exportSVG(event);
9071
+ if (event.mode === 'view') {
9072
+ const border = ElementUtil.getStrokeSvgPath(ElementUtil.getRectPath(0, 0, this.rect.width, this.rect.height), '#000', 0.5);
9073
+ t.children = [border];
9074
+ }
9075
+ return t;
9076
+ }
9077
+ }
9078
+ class DataContainerFactory extends ElementFactory {
9079
+ match(type) {
9080
+ return type === 'data-container';
9081
+ }
9082
+ createElement(data) {
9083
+ const element = new DataContainerElement();
9084
+ const props = data.props;
9085
+ if (props?.id) {
9086
+ element.props.id = props.id;
9087
+ }
9088
+ if (props?.name) {
9089
+ element.props.name = props.name;
9090
+ }
9091
+ if (props?.caption) {
9092
+ element.props.caption = props.caption;
9093
+ }
9094
+ return element;
9095
+ }
9096
+ }
9097
+ class DataContainerProps {
9098
+ caption;
9099
+ id;
9100
+ name;
9101
+ }
9102
+
8950
9103
  /**
8951
9104
  * 当前数据元内容长度小于最小长度时,需要当前元素撑开以达到最小长度
8952
9105
  */
@@ -12904,6 +13057,29 @@ class PaintContent {
12904
13057
  }
12905
13058
  }
12906
13059
 
13060
+ /**
13061
+ * 处理文档输入联想
13062
+ */
13063
+ class DocInputSuggestions {
13064
+ currentInputTextGroup;
13065
+ currentMatchedText = '';
13066
+ currentInputOffset = 0;
13067
+ suggestionsList = [];
13068
+ prepareSuggestions = [];
13069
+ selectedIndex = -1;
13070
+ clear() {
13071
+ this.prepareSuggestions.length = 0;
13072
+ this.currentInputTextGroup = undefined;
13073
+ this.selectedIndex = -1;
13074
+ this.currentInputOffset = 0;
13075
+ this.currentMatchedText = '';
13076
+ }
13077
+ destroy() {
13078
+ this.clear();
13079
+ this.suggestionsList.length = 0;
13080
+ }
13081
+ }
13082
+
12907
13083
  /**
12908
13084
  * 当前打开的文档的上下文信息,当前文档所有的属性设置都暴露在上下文中
12909
13085
  */
@@ -12922,6 +13098,10 @@ class EditorContext {
12922
13098
  commentFlag = false;
12923
13099
  //留痕元素存在的标志,用于判断文档空间进行布局
12924
13100
  trackFlag = false;
13101
+ //suggestionsList: Array<ISuggestionData> = [];
13102
+ //currentSuggestionsList: Array<ISuggestionData> = [];
13103
+ suggestions = new DocInputSuggestions();
13104
+ onKeyDownEvent = new Subject();
12925
13105
  constructor(selectionState, viewOptions) {
12926
13106
  this.selectionState = selectionState;
12927
13107
  this.viewOptions = viewOptions;
@@ -12972,6 +13152,7 @@ class EditorContext {
12972
13152
  clear() {
12973
13153
  this.selectionState.clear();
12974
13154
  this.isDirty = false;
13155
+ this.suggestions.clear();
12975
13156
  //this.clearEleDepMaps();
12976
13157
  }
12977
13158
  get defaultCtx() {
@@ -13014,6 +13195,7 @@ class EditorContext {
13014
13195
  //this.ele_types_handlers.length = 0;
13015
13196
  //this.imageLoader.clear();
13016
13197
  this._document = null;
13198
+ this.suggestions.destroy();
13017
13199
  }
13018
13200
  /**
13019
13201
  * 切换行打印模式
@@ -13034,6 +13216,7 @@ class EditorContext {
13034
13216
  //删除旧节点
13035
13217
  oldDataElement.remove();
13036
13218
  }
13219
+ currentRefreshType = null;
13037
13220
  get refreshType() {
13038
13221
  if (!this._document) {
13039
13222
  return null;
@@ -13491,6 +13674,10 @@ class ParagraphMeasure {
13491
13674
  child.rect.width = tab - currTabX;
13492
13675
  }
13493
13676
  }
13677
+ //如果当前段落行只包含当前换行元素或者段落元素,则根据当前输入设置,自动将行高度撑开到理想高度font-size*1.4
13678
+ if (this.lineLength() === 1 && child.element && (child.element.type === 'br' || child.element.type === 'psym')) {
13679
+ child.rect.height = Math.ceil(options.defaultFontSize * TEXT_HEIGHT_FACTOR);
13680
+ }
13494
13681
  this.arrange();
13495
13682
  this.updateHeight(child);
13496
13683
  },
@@ -15016,6 +15203,7 @@ class ElementReader {
15016
15203
  this.addFactory(TabFactory);
15017
15204
  this.addFactory(PermanentTeethFactory);
15018
15205
  this.addFactory(SVGFactory);
15206
+ this.addFactory(DataContainerFactory);
15019
15207
  // this.registerReadFunc<TrackRunProps>('ins-run', (data) => {
15020
15208
  // const props = new TrackRunProps(data.type);
15021
15209
  // props.userId = data.userId;
@@ -15174,26 +15362,37 @@ class DocumentEvent {
15174
15362
  };
15175
15363
  }
15176
15364
  bindEvent() {
15177
- this.documentInput.onLeftEvent.subscribe(() => {
15178
- this.moveCursorToLeft();
15179
- });
15180
- this.documentInput.onRightEvent.subscribe(() => {
15181
- this.moveCursorToRight();
15182
- });
15183
- this.documentInput.onSelectAllEvent.subscribe(() => {
15184
- this.selectAll();
15185
- });
15186
- this.documentInput.onHomeEvent.subscribe(() => {
15187
- this.moveCursorToLineStart();
15188
- });
15189
- this.documentInput.onEndEvent.subscribe(() => {
15190
- this.moveCursorToLineEnd();
15191
- });
15192
- this.documentInput.onUpEvent.subscribe(() => {
15193
- this.moveCursorToUpOrDown(true);
15194
- });
15195
- this.documentInput.onDownEvent.subscribe(() => {
15196
- this.moveCursorToUpOrDown(false);
15365
+ this.docCtx.onKeyDownEvent.subscribe(evt => {
15366
+ if (!this.docCtx.selectionState.editable) {
15367
+ return;
15368
+ }
15369
+ const os = ElementUtil.getOSPlatform();
15370
+ if (evt.keyCode === 37) {
15371
+ this.moveCursorToLeft();
15372
+ }
15373
+ else if (evt.keyCode === 39) {
15374
+ this.moveCursorToRight();
15375
+ }
15376
+ else if (evt.keyCode === 38) {
15377
+ this.moveCursorToUpOrDown(true);
15378
+ }
15379
+ else if (evt.keyCode === 40) {
15380
+ this.moveCursorToUpOrDown(false);
15381
+ }
15382
+ else if (evt.keyCode === 36) {
15383
+ this.moveCursorToLineStart();
15384
+ }
15385
+ else if (evt.keyCode === 35) {
15386
+ this.moveCursorToLineEnd();
15387
+ }
15388
+ else if (evt.ctrlKey && evt.keyCode === 65 && os !== 'Mac') {
15389
+ evt.preventDefault();
15390
+ this.selectAll();
15391
+ }
15392
+ else if (evt.metaKey && evt.keyCode === 65 && os === 'Mac') {
15393
+ evt.preventDefault();
15394
+ this.selectAll();
15395
+ }
15197
15396
  });
15198
15397
  }
15199
15398
  addSubEvent(sub) {
@@ -16383,15 +16582,15 @@ class DocumentInput {
16383
16582
  //输入内容事件
16384
16583
  onInputEvent = new Subject();
16385
16584
  //backspace 键盘事件
16386
- onBackspaceEvent = new Subject();
16585
+ //onBackspaceEvent: Subject<KeyboardEvent> = new Subject();
16387
16586
  //delete 键盘事件
16388
- onDeleteEvent = new Subject();
16587
+ //onDeleteEvent: Subject<KeyboardEvent> = new Subject();
16389
16588
  //enter 键盘事件
16390
- onEnterEvent = new Subject();
16589
+ //onEnterEvent: Subject<void> = new Subject();
16391
16590
  //左键
16392
- onLeftEvent = new Subject();
16591
+ //onLeftEvent: Subject<void> = new Subject();
16393
16592
  //右键
16394
- onRightEvent = new Subject();
16593
+ //onRightEvent: Subject<void> = new Subject();
16395
16594
  //复制
16396
16595
  onCopyEvent = new Subject();
16397
16596
  //剪切
@@ -16399,30 +16598,31 @@ class DocumentInput {
16399
16598
  //粘贴
16400
16599
  onPasteEvent = new Subject();
16401
16600
  //插入换行符
16402
- onInsertBr = new Subject();
16601
+ //onInsertBr: Subject<void> = new Subject();
16403
16602
  //ctrl+A 全选事件
16404
- onSelectAllEvent = new Subject();
16603
+ //onSelectAllEvent: Subject<void> = new Subject();
16405
16604
  //home 事件
16406
- onHomeEvent = new Subject();
16605
+ //onHomeEvent: Subject<void> = new Subject();
16407
16606
  //end 事件
16408
- onEndEvent = new Subject();
16409
- onUpEvent = new Subject();
16410
- onDownEvent = new Subject();
16411
- onTabKeyEvent = new Subject();
16607
+ //onEndEvent: Subject<void> = new Subject();
16608
+ //onUpEvent: Subject<void> = new Subject();
16609
+ //onDownEvent: Subject<void> = new Subject();
16610
+ //onTabKeyEvent: Subject<void> = new Subject();
16611
+ onKeyDownEvent = new Subject();
16412
16612
  constructor(docCtx) {
16413
16613
  this.docCtx = docCtx;
16414
16614
  }
16415
16615
  composition = false;
16416
16616
  inputTargetStrPosition = -1;
16417
- inputTargetStr = undefined;
16617
+ inputTargetStrLength = 0;
16418
16618
  inputEle;
16419
16619
  correctInputEle(ele, str, pos) {
16420
16620
  this.inputTargetStrPosition = pos;
16421
- this.inputTargetStr = str;
16621
+ this.inputTargetStrLength = str ? str.length : 0;
16422
16622
  this.inputEle = ele;
16423
16623
  }
16424
16624
  getEventListener() {
16425
- const os = ElementUtil.getOSPlatform();
16625
+ ElementUtil.getOSPlatform();
16426
16626
  return {
16427
16627
  input: (evt) => {
16428
16628
  const target = evt.target;
@@ -16440,7 +16640,7 @@ class DocumentInput {
16440
16640
  this.inputTargetStrPosition = startOffset;
16441
16641
  this.inputEle = startControl;
16442
16642
  if (startControl instanceof TextGroupElement) {
16443
- this.inputTargetStr = startControl.text;
16643
+ this.inputTargetStrLength = startControl.text.length;
16444
16644
  }
16445
16645
  },
16446
16646
  compositionupdate: (evt) => {
@@ -16460,60 +16660,48 @@ class DocumentInput {
16460
16660
  this.composition = false;
16461
16661
  this.inputEle = null;
16462
16662
  this.inputTargetStrPosition = -1;
16463
- this.inputTargetStr = undefined;
16663
+ this.inputTargetStrLength = 0;
16464
16664
  },
16465
16665
  keydown: (evt) => {
16666
+ this.onKeyDownEvent.next(evt);
16667
+ if (evt.defaultPrevented) {
16668
+ return;
16669
+ }
16466
16670
  const keyEvent = new KeyboradElementEvent(this.docCtx);
16467
16671
  keyEvent.sourceEvent = evt;
16468
16672
  if (DocumentEvent.invokeEvent('ElementKeyDown', this.docCtx.selectionState.startControl, keyEvent, 'All')) {
16469
16673
  return;
16470
16674
  }
16471
- if (!this.docCtx.selectionState.editable) {
16472
- return;
16473
- }
16474
- if (evt.keyCode === 8) {
16475
- this.onBackspaceEvent.next(evt);
16476
- }
16477
- else if (evt.keyCode === 13 && !evt.shiftKey) {
16478
- this.onEnterEvent.next();
16479
- }
16480
- else if (evt.keyCode === 37) {
16481
- this.onLeftEvent.next();
16482
- }
16483
- else if (evt.keyCode === 39) {
16484
- this.onRightEvent.next();
16485
- }
16486
- else if (evt.keyCode === 38) {
16487
- this.onUpEvent.next();
16488
- }
16489
- else if (evt.keyCode === 40) {
16490
- this.onDownEvent.next();
16491
- }
16492
- else if (evt.keyCode === 9) {
16493
- evt.preventDefault();
16494
- this.onTabKeyEvent.next();
16495
- }
16496
- else if (evt.keyCode === 13 && evt.shiftKey) {
16497
- evt.preventDefault();
16498
- this.onInsertBr.next();
16499
- }
16500
- else if (evt.keyCode === 46) {
16501
- this.onDeleteEvent.next(evt);
16502
- }
16503
- else if (evt.ctrlKey && evt.keyCode === 65 && os !== 'Mac') {
16504
- evt.preventDefault();
16505
- this.onSelectAllEvent.next();
16506
- }
16507
- else if (evt.metaKey && evt.keyCode === 65 && os === 'Mac') {
16508
- evt.preventDefault();
16509
- this.onSelectAllEvent.next();
16510
- }
16511
- else if (evt.keyCode === 36) {
16512
- this.onHomeEvent.next();
16513
- }
16514
- else if (evt.keyCode === 35) {
16515
- this.onEndEvent.next();
16516
- }
16675
+ // if (!this.docCtx.selectionState.editable) {
16676
+ // return;
16677
+ // }
16678
+ // if (evt.keyCode === 8) {
16679
+ // //this.onBackspaceEvent.next(evt);
16680
+ // } else if (evt.keyCode === 13 && !evt.shiftKey) {
16681
+ // //this.onEnterEvent.next();
16682
+ // } else if (evt.keyCode === 37) {
16683
+ // //this.onLeftEvent.next();
16684
+ // } else if (evt.keyCode === 39) {
16685
+ // //this.onRightEvent.next();
16686
+ // } else if (evt.keyCode === 9) {
16687
+ // // evt.preventDefault();
16688
+ // // this.onTabKeyEvent.next();
16689
+ // } else if (evt.keyCode === 13 && evt.shiftKey) {
16690
+ // // evt.preventDefault();
16691
+ // // this.onInsertBr.next();
16692
+ // } else if (evt.keyCode === 46) {
16693
+ // //this.onDeleteEvent.next(evt);
16694
+ // } else if (evt.ctrlKey && evt.keyCode === 65 && os !== 'Mac') {
16695
+ // // evt.preventDefault();
16696
+ // // this.onSelectAllEvent.next();
16697
+ // } else if (evt.metaKey && evt.keyCode === 65 && os === 'Mac') {
16698
+ // // evt.preventDefault();
16699
+ // // this.onSelectAllEvent.next();
16700
+ // } else if (evt.keyCode === 36) {
16701
+ // //this.onHomeEvent.next();
16702
+ // } else if (evt.keyCode === 35) {
16703
+ // //this.onEndEvent.next();
16704
+ // }
16517
16705
  },
16518
16706
  copy: (evt) => {
16519
16707
  const event = new CopyElementEvent(this.docCtx);
@@ -16540,7 +16728,7 @@ class DocumentInput {
16540
16728
  const { startControl, startOffset } = this.docCtx.selectionState;
16541
16729
  this.onInputEvent.next({
16542
16730
  data: data,
16543
- prevInputData: this.inputTargetStr,
16731
+ prevInputDataLength: this.inputTargetStrLength,
16544
16732
  composition: this.composition,
16545
16733
  compositionStartInfo: {
16546
16734
  element: startControl,
@@ -16570,12 +16758,34 @@ class DocumentChange {
16570
16758
  this.documentInput.onInputEvent.subscribe(data => {
16571
16759
  this.newInput(data);
16572
16760
  });
16573
- this.documentInput.onBackspaceEvent.subscribe((evt) => {
16574
- this.onBackspace(evt);
16575
- });
16576
- this.documentInput.onEnterEvent.subscribe(() => {
16577
- this.onEnter();
16761
+ this.docCtx.onKeyDownEvent.subscribe(evt => {
16762
+ if (!this.docCtx.selectionState.editable) {
16763
+ return;
16764
+ }
16765
+ if (evt.keyCode === 8) {
16766
+ this.onBackspace(evt);
16767
+ }
16768
+ else if (evt.keyCode === 13 && !evt.shiftKey) {
16769
+ this.onEnter();
16770
+ }
16771
+ if (evt.keyCode === 13 && evt.shiftKey) {
16772
+ evt.preventDefault();
16773
+ this.insertSoftBr();
16774
+ }
16775
+ else if (evt.keyCode === 46) {
16776
+ this.onDeleteKeyHandler(evt);
16777
+ }
16778
+ if (evt.keyCode === 9) {
16779
+ evt.preventDefault();
16780
+ this.insertTabElement();
16781
+ }
16578
16782
  });
16783
+ /* this.documentInput.onBackspaceEvent.subscribe((evt) => {
16784
+ this.onBackspace(evt)
16785
+ });*/
16786
+ // this.documentInput.onEnterEvent.subscribe(() => {
16787
+ // this.onEnter()
16788
+ // });
16579
16789
  this.documentInput.onCopyEvent.subscribe((evt) => {
16580
16790
  this.onCopy(evt);
16581
16791
  });
@@ -16585,21 +16795,10 @@ class DocumentChange {
16585
16795
  this.documentInput.onPasteEvent.subscribe((evt) => {
16586
16796
  this.onPaste(evt);
16587
16797
  });
16588
- this.documentInput.onInsertBr.subscribe(() => {
16589
- this.insertSoftBr();
16590
- });
16591
- this.documentInput.onDeleteEvent.subscribe((evt) => {
16592
- this.onDeleteKeyHandler(evt);
16593
- });
16594
- this.documentInput.onTabKeyEvent.subscribe(() => {
16595
- this.insertTabElement();
16596
- });
16597
16798
  }
16598
16799
  newInput(data) {
16599
- if (data.composition && data.data === '啊') {
16600
- debugger;
16601
- }
16602
- const { startControl, startOffset, collapsed, enableTrackChanges } = this.selectionState;
16800
+ const { startControl, startOffset, collapsed } = this.selectionState;
16801
+ const enableTrackChanges = this.viewOptions.enableTrackChanges;
16603
16802
  if (!collapsed) {
16604
16803
  this.onInputBySelectRange(data);
16605
16804
  return;
@@ -16618,12 +16817,7 @@ class DocumentChange {
16618
16817
  //当前输入节点是在留痕区域中,但是当前关闭了审阅模式,需要拆分留痕区域,创建新输入节点
16619
16818
  if (!enableTrackChanges && this.isInTrackBlock(startControl)) {
16620
16819
  const newInput = this.splitTrackElement(startControl, startOffset);
16621
- const comp = data.compositionStartInfo;
16622
- comp.element = newInput;
16623
- comp.offset = 0;
16624
- //修正数据
16625
- if (data.composition)
16626
- this.documentInput.correctInputEle(newInput, newInput.text, 0);
16820
+ this.correctInputEle(newInput, newInput.text, 0, data);
16627
16821
  this.inputTextGroup(newInput, data);
16628
16822
  return;
16629
16823
  }
@@ -16633,26 +16827,27 @@ class DocumentChange {
16633
16827
  }
16634
16828
  const siblingTextEle = startOffset === 1 ? ElementUtil.getNextSiblingElement(startControl) : ElementUtil.getPrevSiblingElement(startControl);
16635
16829
  if (siblingTextEle instanceof TextGroupElement) {
16636
- data.compositionStartInfo.offset = startOffset === 0 ? siblingTextEle.text.length : 0;
16637
- //修正数据
16638
- if (data.composition) {
16639
- this.documentInput.correctInputEle(siblingTextEle, siblingTextEle.text, data.compositionStartInfo.offset);
16640
- }
16830
+ const pos = startOffset === 0 ? siblingTextEle.text.length : 0;
16831
+ this.correctInputEle(siblingTextEle, siblingTextEle.text, pos, data);
16641
16832
  this.inputTextGroup(siblingTextEle, data);
16642
16833
  }
16643
16834
  else {
16644
16835
  const inputTextProps = this.getDefaultTextProps(startControl, startOffset);
16645
16836
  const newTextGroup = ElementUtil.getNewTextGroup(inputTextProps);
16646
16837
  startControl.parent.addChild(newTextGroup, startControl.getIndex() + startOffset);
16647
- if (data.composition) {
16648
- this.documentInput.correctInputEle(newTextGroup, '', 0);
16649
- }
16838
+ this.correctInputEle(newTextGroup, '', 0, data);
16650
16839
  this.inputTextGroup(newTextGroup, data);
16651
16840
  }
16652
16841
  return;
16653
16842
  }
16654
16843
  this.inputTextGroup(startControl, data);
16655
16844
  }
16845
+ correctInputEle(ele, str, pos, data) {
16846
+ this.documentInput.correctInputEle(ele, str, pos);
16847
+ data.compositionStartInfo.element = ele;
16848
+ data.compositionStartInfo.offset = pos;
16849
+ data.prevInputDataLength = str.length;
16850
+ }
16656
16851
  /**
16657
16852
  * 选中区域后进行输入
16658
16853
  * 需要处理将选中的区域删除后,进行输入的情况
@@ -16710,24 +16905,20 @@ class DocumentChange {
16710
16905
  */
16711
16906
  newInputTrackChanges(data, startControl, startOffset) {
16712
16907
  this.viewOptions.editUser.id;
16713
- const compInfo = data.compositionStartInfo;
16908
+ data.compositionStartInfo;
16714
16909
  if (this.isInCorrectTrackRegion(startControl, TrackRunTypeEnum.Inserted)) {
16715
16910
  return;
16716
16911
  }
16717
16912
  if (this.isInTrackBlock(startControl)) {
16718
16913
  const newInput = this.createNewTrackInput(startControl, startOffset, TrackRunTypeEnum.Inserted);
16719
- compInfo.offset = 0;
16720
- compInfo.element = newInput;
16721
- this.documentInput.correctInputEle(newInput, '', 0);
16914
+ this.correctInputEle(newInput, '', 0, data);
16722
16915
  this.inputTextGroup(newInput, data);
16723
16916
  return;
16724
16917
  }
16725
16918
  else {
16726
16919
  const { trackElement, newTextGroup } = this.createTextTrackElement(startControl, null, TrackRunTypeEnum.Inserted);
16727
16920
  this.insertElement(startControl, startOffset, [trackElement]);
16728
- compInfo.offset = 0;
16729
- compInfo.element = newTextGroup;
16730
- this.documentInput.correctInputEle(newTextGroup, '', 0);
16921
+ this.correctInputEle(newTextGroup, '', 0, data);
16731
16922
  this.inputTextGroup(newTextGroup, data);
16732
16923
  return;
16733
16924
  }
@@ -16770,24 +16961,23 @@ class DocumentChange {
16770
16961
  * @returns
16771
16962
  */
16772
16963
  getDefaultTextProps(startControl, offset) {
16773
- let textProps = this.getDefaultTextPropsByOptions();
16774
- if (startControl instanceof TextGroupElement) {
16775
- textProps = startControl.props;
16776
- }
16777
16964
  const dataEle = ElementUtil.getDataElement(startControl);
16778
16965
  if (dataEle && IsInSideDataElement(startControl, offset)) {
16779
16966
  return dataEle.props.valueTextProps;
16780
16967
  }
16781
- return textProps;
16968
+ else {
16969
+ return this.getDefaultTextPropsByOptions();
16970
+ }
16782
16971
  }
16783
16972
  /**
16784
16973
  * 根据选项配置返回创建文本的默认文本属性
16785
16974
  * @private
16786
16975
  */
16787
16976
  getDefaultTextPropsByOptions() {
16977
+ const { defaultFontSize, defaultFontName, currentFontSize, currentFontName } = this.viewOptions;
16788
16978
  const props = new TextProps();
16789
- props.fontName = this.viewOptions.defaultFontName;
16790
- props.fontSize = this.viewOptions.defaultFontSize;
16979
+ props.fontSize = currentFontSize > 0 ? currentFontSize : defaultFontSize;
16980
+ props.fontName = currentFontName ? currentFontName : defaultFontName;
16791
16981
  props.color = this.viewOptions.defaultColor;
16792
16982
  return props;
16793
16983
  }
@@ -16850,15 +17040,20 @@ class DocumentChange {
16850
17040
  return trackElement;
16851
17041
  }
16852
17042
  inputTextGroup(text, data) {
16853
- const prevInputData = data.prevInputData || '';
16854
- const prevInputDataLength = prevInputData.length;
16855
- if (!data.compositionStartInfo) {
16856
- throw new Error('compositionStartInfo is null');
16857
- }
17043
+ const prevInputDataLength = data.prevInputDataLength ?? 0;
16858
17044
  const { element, offset } = data.compositionStartInfo;
17045
+ //处理当前输入字体大小和名称;当前手动更改了字体信息,需要重新创建文本元素进行输入处理
17046
+ if (text.props.fontSize !== this.viewOptions.currentFontSize || text.props.fontName !== this.viewOptions.currentFontName) {
17047
+ //创建新输入项
17048
+ const newInput = this.createNewInputText();
17049
+ //插入到文档
17050
+ this.insertElement(element, offset, [newInput]);
17051
+ this.correctInputEle(newInput, '', 0, data);
17052
+ this.inputTextGroup(newInput, data);
17053
+ return;
17054
+ }
16859
17055
  let startInputOffset = offset;
16860
17056
  const deleteCount = data.composition ? text.textMeasures.length - prevInputDataLength : 0;
16861
- //startInputOffset -= prevInputDataLength;
16862
17057
  if (!(element instanceof TextGroupElement)) {
16863
17058
  //当前选中元素位于输入元素是起始还是结束位置,如果位于起始位置,则输入偏移量为0,否则为未变更之前的内容length
16864
17059
  if (ElementUtil.getNextSiblingElement(element) === text) {
@@ -17061,7 +17256,7 @@ class DocumentChange {
17061
17256
  const currPara = ElementUtil.getParentByType(control, ParagraphElement);
17062
17257
  //表明是紧挨着的两个段落,要进行段落合并
17063
17258
  if (ElementUtil.getPrevSiblingElement(currPara) === prevPara) {
17064
- if (this.selectionState.enableTrackChanges) {
17259
+ if (this.viewOptions.enableTrackChanges) {
17065
17260
  this.selectionState.resetRange(prevEle, -1);
17066
17261
  return;
17067
17262
  }
@@ -17152,7 +17347,7 @@ class DocumentChange {
17152
17347
  const currPara = ElementUtil.getParentByType(control, ParagraphElement);
17153
17348
  //表明是紧挨着的两个段落,要进行段落合并
17154
17349
  if (ElementUtil.getNextSiblingElement(currPara) === nextPara) {
17155
- if (this.selectionState.enableTrackChanges) {
17350
+ if (this.viewOptions.enableTrackChanges) {
17156
17351
  this.selectionState.resetRange(nextEle, 0);
17157
17352
  return;
17158
17353
  }
@@ -17214,7 +17409,7 @@ class DocumentChange {
17214
17409
  return dataEle.length === 2;
17215
17410
  }
17216
17411
  onDeleteText(text, offset, len) {
17217
- if (this.selectionState.enableTrackChanges) {
17412
+ if (this.viewOptions.enableTrackChanges) {
17218
17413
  this.updateDeletedTrackText(text, offset, len);
17219
17414
  }
17220
17415
  else {
@@ -17222,7 +17417,7 @@ class DocumentChange {
17222
17417
  }
17223
17418
  }
17224
17419
  onDeleteItem(item) {
17225
- if (this.selectionState.enableTrackChanges) {
17420
+ if (this.viewOptions.enableTrackChanges) {
17226
17421
  //删除符号不进行留痕
17227
17422
  if (item.type === 'psym') {
17228
17423
  return;
@@ -17313,6 +17508,16 @@ class DocumentChange {
17313
17508
  return newTextGroup;
17314
17509
  }
17315
17510
  }
17511
+ /**
17512
+ * 创建一个待输入的文本元素
17513
+ * @private
17514
+ */
17515
+ createNewInputText() {
17516
+ const { startControl, startOffset } = this.selectionState;
17517
+ const textProps = this.getDefaultTextProps(startControl, startOffset);
17518
+ const newInput = ElementUtil.getNewTextGroup(textProps);
17519
+ return newInput;
17520
+ }
17316
17521
  getNextTrackElement(target, trackType) {
17317
17522
  let trackElement = ElementUtil.getNextSiblingTrackElement(target, trackType, this.viewOptions.editUser.id);
17318
17523
  if (!trackElement) {
@@ -17402,9 +17607,16 @@ class DocumentChange {
17402
17607
  * @returns
17403
17608
  */
17404
17609
  insertTable(tb) {
17610
+ this.insertLayoutContainer(tb);
17611
+ }
17612
+ /**
17613
+ * 插入布局容器,比如表格、数据容器等
17614
+ * @param ele
17615
+ */
17616
+ insertLayoutContainer(ele) {
17405
17617
  const breakPara = this.splitCurrentParagraph();
17406
- breakPara.parent.addChild(tb, breakPara.getIndex());
17407
- this.selectionState.resetRange(tb, 0);
17618
+ breakPara.parent.addChild(ele, breakPara.getIndex());
17619
+ this.selectionState.resetRange(ele, 0);
17408
17620
  }
17409
17621
  /**
17410
17622
  * 分割当前段落用于插入表格或者粘贴的内容
@@ -17466,7 +17678,7 @@ class DocumentChange {
17466
17678
  }
17467
17679
  else if (childTarget instanceof BranchElement) {
17468
17680
  //留痕模式
17469
- if (this.selectionState.enableTrackChanges) {
17681
+ if (this.viewOptions.enableTrackChanges) {
17470
17682
  this.deleteRange(childRange);
17471
17683
  }
17472
17684
  else {
@@ -17974,7 +18186,7 @@ class DocumentChange {
17974
18186
  data: text,
17975
18187
  compositionStartInfo: {
17976
18188
  element: startControl,
17977
- offset: startOffset
18189
+ offset: startOffset,
17978
18190
  }
17979
18191
  });
17980
18192
  }
@@ -17991,6 +18203,31 @@ class DocumentChange {
17991
18203
  this.selectionState.resetRange(breakPara, 0);
17992
18204
  }
17993
18205
  }
18206
+ /**
18207
+ * 向当前光标追加文本
18208
+ * @param appendStr
18209
+ * @param inputOffset
18210
+ * @param replaceLength
18211
+ * @private
18212
+ */
18213
+ appendText(appendStr, replaceText) {
18214
+ const { startControl, startOffset } = this.selectionState;
18215
+ if (startControl instanceof TextGroupElement) {
18216
+ const data = {
18217
+ data: appendStr,
18218
+ prevInputDataLength: startControl.text.length - replaceText.length,
18219
+ composition: true,
18220
+ compositionStartInfo: {
18221
+ element: startControl,
18222
+ offset: startOffset - replaceText.length
18223
+ }
18224
+ };
18225
+ this.inputTextGroup(startControl, data);
18226
+ }
18227
+ else {
18228
+ console.warn("当前光标所在的元素类型不正确,不能进行追加文本操作");
18229
+ }
18230
+ }
17994
18231
  /**
17995
18232
  * 设置当前段落项目符号类型
17996
18233
  */
@@ -18018,7 +18255,7 @@ class DocumentChange {
18018
18255
  /**
18019
18256
  * 插入批注
18020
18257
  */
18021
- insertComment() {
18258
+ insertComment(text) {
18022
18259
  const { startControl, startOffset, endControl, endOffset, collapsed } = this.selectionState;
18023
18260
  if (collapsed || !startControl || !endControl) {
18024
18261
  return;
@@ -18035,7 +18272,7 @@ class DocumentChange {
18035
18272
  endCommMark.props.markType = 'end';
18036
18273
  this.insertElement(endControl, endOffset, [endCommMark]);
18037
18274
  this.insertElement(startControl, startOffset, [startCommMark]);
18038
- startCommMark.props.text = '插入测试批注信息' + new Date();
18275
+ startCommMark.props.text = text;
18039
18276
  // const commContent = new CommContentElement();
18040
18277
  // commContent.props.id = id;
18041
18278
  // commContent.props.createId = this.viewOptions.editUser.id;
@@ -18640,13 +18877,19 @@ class ElementTrackManage {
18640
18877
  //前后是连续的操作
18641
18878
  const { format: currFormat } = currOp.ops;
18642
18879
  const { format: prevFormat } = prevOp.ops;
18880
+ //const applyProps = {};
18643
18881
  Object.keys(currFormat).forEach(key => {
18644
18882
  const currValue = currFormat[key].newValue;
18645
- const prevValue = prevFormat[key].newValue;
18646
- if (CommonUtil.isEqual(currValue, prevValue)) {
18883
+ if (prevFormat[key] && CommonUtil.isEqual(currValue, prevFormat[key])) {
18647
18884
  return;
18648
18885
  }
18649
- prevFormat[key].newValue = currValue;
18886
+ if (prevFormat[key]) {
18887
+ prevFormat[key].newValue = currValue;
18888
+ }
18889
+ else {
18890
+ prevFormat[key] = { oldValue: currFormat[key].oldValue, newValue: currValue };
18891
+ }
18892
+ //applyProps[key] = currValue;
18650
18893
  });
18651
18894
  return true;
18652
18895
  }
@@ -20089,7 +20332,8 @@ function calculateDistance(a, b) {
20089
20332
 
20090
20333
  class DocEditor {
20091
20334
  svgContainer;
20092
- //private docContent!: HTMLElement;
20335
+ //设置vue 不允许代理
20336
+ __v_skip = true;
20093
20337
  contentCtx;
20094
20338
  viewOptions;
20095
20339
  docCtx;
@@ -20123,10 +20367,18 @@ class DocEditor {
20123
20367
  onDestroy = new Subject();
20124
20368
  beforeNodePatch = new Subject();
20125
20369
  afterNodePatch = new Subject();
20370
+ //文档内容输入改变的时候,触发此事件(输入、删除文字),可以监听该事件,实现候选词、联想词等功能
20371
+ onTextChanged = new Subject();
20372
+ //联想词处理:文档处理之前
20373
+ onSuggestionsProcess = new Subject();
20126
20374
  //自定义事件传递消息
20127
20375
  eventBus;
20128
20376
  editInput;
20129
20377
  scrollContainer;
20378
+ // //输入候选建议词列表
20379
+ // private suggestions: Array<ISuggestionData> = [];
20380
+ //光标keydown事件
20381
+ onKeyDownEvent = new Subject();
20130
20382
  constructor(svgContainer) {
20131
20383
  this.svgContainer = svgContainer;
20132
20384
  this.createCanvasContext();
@@ -20181,6 +20433,17 @@ class DocEditor {
20181
20433
  });
20182
20434
  this.documentEvent.trackTipsChanged.subscribe(data => {
20183
20435
  });
20436
+ this.documentInput.onKeyDownEvent.subscribe((evt) => {
20437
+ this.onKeyDownEvent.next(evt);
20438
+ if (evt.defaultPrevented) {
20439
+ return;
20440
+ }
20441
+ this.processKeyDownEvent(evt);
20442
+ if (evt.defaultPrevented) {
20443
+ return;
20444
+ }
20445
+ this.docCtx.onKeyDownEvent.next(evt);
20446
+ });
20184
20447
  this.docCtx.docChange = this.documentChange;
20185
20448
  this.docCtx.syncRefresh = () => {
20186
20449
  this.flushToSchedule();
@@ -20197,14 +20460,19 @@ class DocEditor {
20197
20460
  const docPagesFunc = this.getVNode();
20198
20461
  const calendarFunc = this.renderCalendar();
20199
20462
  const menuFunc = this.renderContextmenu();
20463
+ const suggestionFunc = this.renderSuggestions();
20200
20464
  const ruleFunc = new DocRule(this.docCtx);
20201
20465
  const onSizeChange = () => {
20202
20466
  this.adjustPageLayout();
20203
20467
  };
20204
- window.addEventListener('resize', onSizeChange);
20468
+ // window.addEventListener('resize', onSizeChange);
20205
20469
  this.onDestroy.subscribe(() => {
20206
- window.removeEventListener('resize', onSizeChange);
20470
+ ro.unobserve(this.svgContainer);
20471
+ });
20472
+ const ro = new ResizeObserver(entries => {
20473
+ onSizeChange();
20207
20474
  });
20475
+ ro.observe(this.svgContainer);
20208
20476
  return {
20209
20477
  render: () => {
20210
20478
  const docContentVNode = docPagesFunc.render();
@@ -20233,7 +20501,7 @@ class DocEditor {
20233
20501
  'transform': `scale(${this.viewOptions.scale})`
20234
20502
  }
20235
20503
  },
20236
- children: [inputVNode, listVNode.render(), calendarFunc.render(), menuFunc.render()]
20504
+ children: [inputVNode, listVNode.render(), calendarFunc.render(), menuFunc.render(), suggestionFunc.render()]
20237
20505
  };
20238
20506
  return {
20239
20507
  sel: 'div.svg-container',
@@ -20244,8 +20512,14 @@ class DocEditor {
20244
20512
  hook: {
20245
20513
  insert: (vNode) => {
20246
20514
  this.svgContainer = vNode.elm;
20515
+ ro.observe(this.svgContainer);
20247
20516
  this.updateViewOption();
20248
20517
  }
20518
+ },
20519
+ on: {
20520
+ resize: () => {
20521
+ console.log('resize');
20522
+ }
20249
20523
  }
20250
20524
  },
20251
20525
  children: [
@@ -20255,7 +20529,7 @@ class DocEditor {
20255
20529
  style: {
20256
20530
  overflow: 'auto',
20257
20531
  position: 'relative',
20258
- height: this.viewOptions.viewSettings.height + 'px'
20532
+ height: "100%"
20259
20533
  },
20260
20534
  on: {
20261
20535
  scroll: (evt) => {
@@ -20263,6 +20537,9 @@ class DocEditor {
20263
20537
  this.viewOptions.pageOffset.x = target.scrollLeft;
20264
20538
  this.viewOptions.pageOffset.y = target.scrollTop;
20265
20539
  this.onChange();
20540
+ },
20541
+ resize: () => {
20542
+ console.log('resize');
20266
20543
  }
20267
20544
  },
20268
20545
  hook: {
@@ -20381,10 +20658,9 @@ class DocEditor {
20381
20658
  if (this.docCtx.refreshType === null) {
20382
20659
  return;
20383
20660
  }
20384
- let rePaint = this.docCtx.refreshType === 'content';
20385
- if (rePaint) {
20661
+ this.docCtx.currentRefreshType = this.docCtx.refreshType;
20662
+ if (this.docCtx.currentRefreshType) {
20386
20663
  this.onBeforeRefreshDocument.next();
20387
- this.documentSelection.clearSnapshot();
20388
20664
  this.docComment.readComments();
20389
20665
  suppressTracking(() => {
20390
20666
  this.documentPaginator.rePages();
@@ -20404,14 +20680,33 @@ class DocEditor {
20404
20680
  let ssChanged = false;
20405
20681
  try {
20406
20682
  //防止由于选区不正确导致的错误,导致后续的当前任务无法释放
20407
- ssChanged = this.documentSelection.updateSelectionState();
20683
+ this.documentSelection.updateSelectionState();
20684
+ ssChanged = this.documentSelection.isSelectionChanged();
20408
20685
  }
20409
20686
  catch (e) {
20410
20687
  console.error(e);
20411
20688
  }
20412
20689
  this.selectionOverlays.getSelectionTreeData();
20690
+ ssChanged && this.updateInputFont();
20413
20691
  ssChanged && this.selectionChanged.next(this.documentSelection.selectionState);
20414
20692
  ssChanged && this.documentEvent.invokeCursor(this.selectionState.startControl);
20693
+ this.documentSelection.clearSnapshot();
20694
+ this.documentSelection.takeSnapshot();
20695
+ }
20696
+ /**
20697
+ * 根据当前选区,更新待输入文本字体信息
20698
+ * @private
20699
+ */
20700
+ updateInputFont() {
20701
+ const { startControl } = this.selectionState;
20702
+ if (startControl instanceof TextGroupElement) {
20703
+ this.viewOptions.currentFontSize = startControl.props.fontSize;
20704
+ this.viewOptions.currentFontName = startControl.props.fontName;
20705
+ }
20706
+ else {
20707
+ this.viewOptions.currentFontSize = this.viewOptions.defaultFontSize;
20708
+ this.viewOptions.currentFontName = this.viewOptions.defaultFontName;
20709
+ }
20415
20710
  }
20416
20711
  hitInfoChanged(hitInfo) {
20417
20712
  this.documentSelection.setSelectionState(hitInfo);
@@ -20707,6 +21002,9 @@ class DocEditor {
20707
21002
  this.documentChange.insertTable(tb);
20708
21003
  return tb;
20709
21004
  }
21005
+ insertLayoutContainer(ele) {
21006
+ this.documentChange.insertLayoutContainer(ele);
21007
+ }
20710
21008
  /**
20711
21009
  * 插入软换行符
20712
21010
  */
@@ -20891,8 +21189,8 @@ class DocEditor {
20891
21189
  /**
20892
21190
  * 插入批注
20893
21191
  */
20894
- insertComment() {
20895
- this.documentChange.insertComment();
21192
+ insertComment(text) {
21193
+ this.documentChange.insertComment(text);
20896
21194
  }
20897
21195
  /**
20898
21196
  * 清除所有批注
@@ -20957,16 +21255,12 @@ class DocEditor {
20957
21255
  canRedo() {
20958
21256
  return this.historyMange.canRedo;
20959
21257
  }
20960
- switchTrackChanges(eleCtx = null) {
21258
+ /**
21259
+ * 切换文档留痕开关
21260
+ */
21261
+ switchTrackChanges() {
20961
21262
  this.selectionState.clear();
20962
- eleCtx = eleCtx || this.docCtx.document;
20963
- const body = eleCtx.treeFind(item => item instanceof DocumentBodyElement);
20964
- if (body) {
20965
- body.trackChanges = !body.trackChanges;
20966
- }
20967
- else {
20968
- throw new Error('未找到doc-body');
20969
- }
21263
+ this.viewOptions.enableTrackChanges = !this.viewOptions.enableTrackChanges;
20970
21264
  }
20971
21265
  get trackTipsChanged() {
20972
21266
  return this.documentEvent.trackTipsChanged;
@@ -21311,14 +21605,18 @@ class DocEditor {
21311
21605
  if (this.viewOptions.reviewWindowWidth > 0) {
21312
21606
  this.viewOptions.reviewWindowWidth = 0;
21313
21607
  //刷新页面
21314
- this.docCtx.onNextView(() => { this.adjustPageLayout(); });
21608
+ this.docCtx.onNextView(() => {
21609
+ this.adjustPageLayout();
21610
+ });
21315
21611
  }
21316
21612
  }
21317
21613
  else {
21318
21614
  if (this.viewOptions.reviewWindowWidth === 0) {
21319
21615
  this.viewOptions.reviewWindowWidth = 250;
21320
21616
  //刷新页面
21321
- this.docCtx.onNextView(() => { this.adjustPageLayout(); });
21617
+ this.docCtx.onNextView(() => {
21618
+ this.adjustPageLayout();
21619
+ });
21322
21620
  }
21323
21621
  }
21324
21622
  }
@@ -21414,11 +21712,13 @@ class DocEditor {
21414
21712
  //ckbVNode.data.attrs['checked'] = true;
21415
21713
  }
21416
21714
  return {
21417
- sel: 'div', data: { on: {
21715
+ sel: 'div', data: {
21716
+ on: {
21418
21717
  click: () => {
21419
21718
  onChangeHandler(item.code);
21420
21719
  }
21421
- } }, children: [ckbVNode, {
21720
+ }
21721
+ }, children: [ckbVNode, {
21422
21722
  sel: 'label',
21423
21723
  data: {},
21424
21724
  text: item.value
@@ -21426,18 +21726,12 @@ class DocEditor {
21426
21726
  };
21427
21727
  });
21428
21728
  return {
21429
- sel: 'div#data-list-container',
21729
+ sel: 'div.data-list-container',
21430
21730
  data: {
21431
21731
  style: {
21432
21732
  position: 'absolute',
21433
21733
  left: (position.x - 10) + 'px',
21434
21734
  top: position.y + 5 + position.height + 'px',
21435
- 'min-width': '100px',
21436
- 'background-color': 'white',
21437
- 'z-index': '1000',
21438
- 'border-radius': '5px',
21439
- 'box-shadow': '0 0 5px 0 rgba(0,0,0,0.2)',
21440
- 'user-select': 'none',
21441
21735
  },
21442
21736
  hook: {
21443
21737
  insert: (vnode) => {
@@ -21534,6 +21828,44 @@ class DocEditor {
21534
21828
  if (!editor.menusData) {
21535
21829
  return null;
21536
21830
  }
21831
+ const renderMenu = (menus) => {
21832
+ if (!menus) {
21833
+ return [];
21834
+ }
21835
+ return [
21836
+ {
21837
+ sel: 'ul.editor-overlays-menus',
21838
+ data: {},
21839
+ children: menus.map((menu) => renderMenuItem(menu))
21840
+ }
21841
+ ];
21842
+ };
21843
+ const renderSubItems = (menu) => {
21844
+ if (!menu.subItems)
21845
+ return [];
21846
+ return renderMenu(menu.subItems);
21847
+ };
21848
+ const renderMenuItem = (menu) => {
21849
+ return {
21850
+ sel: 'li' + (menu.subItems && menu.subItems.length ? '.sub' : ''),
21851
+ data: {
21852
+ on: {
21853
+ click: () => {
21854
+ menu.click?.();
21855
+ editor.menusData = null;
21856
+ editor.onChange();
21857
+ }
21858
+ }
21859
+ },
21860
+ children: [{
21861
+ sel: 'span',
21862
+ data: {},
21863
+ text: menu.caption
21864
+ },
21865
+ ...renderSubItems(menu)
21866
+ ]
21867
+ };
21868
+ };
21537
21869
  return {
21538
21870
  sel: 'div.editor-contextmenu',
21539
21871
  data: {
@@ -21542,27 +21874,7 @@ class DocEditor {
21542
21874
  top: editor.menusData.position.y + 'px',
21543
21875
  }
21544
21876
  },
21545
- children: [
21546
- {
21547
- sel: 'ul.editor-overlays-menus',
21548
- data: {},
21549
- children: editor.menusData.menus.map((menu) => {
21550
- return {
21551
- sel: 'li',
21552
- data: {
21553
- on: {
21554
- click: (evt) => {
21555
- menu.eventObj["onClick"]();
21556
- editor.menusData = null;
21557
- editor.onChange();
21558
- }
21559
- }
21560
- },
21561
- text: menu.caption
21562
- };
21563
- })
21564
- }
21565
- ]
21877
+ children: renderMenu(editor.menusData.menus)
21566
21878
  };
21567
21879
  }
21568
21880
  };
@@ -21584,7 +21896,7 @@ class DocEditor {
21584
21896
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
21585
21897
  }
21586
21898
  version() {
21587
- return "2.2.2";
21899
+ return "2.2.4";
21588
21900
  }
21589
21901
  switchPageHeaderEditor() {
21590
21902
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
@@ -21667,6 +21979,7 @@ class DocEditor {
21667
21979
  readDocChangeLog() {
21668
21980
  //获取文档的变更日志
21669
21981
  const ops = generatePatch(this.docCtx.document, false);
21982
+ //1.处理批注删除不对称的问题
21670
21983
  for (let i = 0; i < ops.length; i++) {
21671
21984
  const op = ops[i];
21672
21985
  if ('delete' in op.ops) {
@@ -21693,6 +22006,192 @@ class DocEditor {
21693
22006
  }
21694
22007
  }
21695
22008
  }
22009
+ //处理文字输入
22010
+ if (this.viewOptions.enableSuggestions && ops.length && ops.every(op => 'delText' in op.ops || 'insText' in op.ops || ('insert' in op.ops && op.ops.insert.type === 'text'))) {
22011
+ this.processSuggestionsHandle();
22012
+ }
22013
+ else {
22014
+ this.docCtx.suggestions.clear();
22015
+ }
22016
+ }
22017
+ /**
22018
+ * 处理候选词
22019
+ * @private
22020
+ */
22021
+ processSuggestionsHandle() {
22022
+ this.docCtx.suggestions.clear();
22023
+ //this.suggestionSelectIndex.value = -1;
22024
+ const sub = this.selectionChanged.subscribe(() => {
22025
+ this.createAutoCompleteOptions();
22026
+ });
22027
+ sub.once = true;
22028
+ }
22029
+ createAutoCompleteOptions() {
22030
+ if (!this.viewOptions.enableSuggestions || !this.selectionState.editable) {
22031
+ return;
22032
+ }
22033
+ if (this.selectionState.collapsed && this.selectionState.startControl instanceof TextGroupElement) {
22034
+ const { startControl, startOffset } = this.selectionState;
22035
+ const text = startControl.text;
22036
+ //根据标点符号分割文本
22037
+ let findText = text.substring(0, startOffset);
22038
+ //循环当前字符串,根据startOffset向前寻找,直到找到标点符号
22039
+ for (let i = startOffset; i >= 0; i--) {
22040
+ const char = text.charAt(i);
22041
+ if (char.match(/[\s,,。?!;:、]/)) {
22042
+ findText = text.substring(i + 1, startOffset);
22043
+ break;
22044
+ }
22045
+ }
22046
+ //结尾为标点符号
22047
+ if (!findText.length) {
22048
+ return;
22049
+ }
22050
+ const filterSuggestions = this.docCtx.suggestions.suggestionsList.filter(item => item.label.includes(findText));
22051
+ const data = {
22052
+ filterSuggestions,
22053
+ inputTextGroup: startControl,
22054
+ inputOffset: startOffset,
22055
+ findText
22056
+ };
22057
+ this.onSuggestionsProcess.next(data);
22058
+ this.docCtx.suggestions.prepareSuggestions.push(...data.filterSuggestions);
22059
+ this.docCtx.suggestions.currentInputTextGroup = data.inputTextGroup;
22060
+ this.docCtx.suggestions.currentInputOffset = data.inputOffset;
22061
+ this.docCtx.suggestions.currentMatchedText = data.findText;
22062
+ //this.suggestions.push('文本输入1', '文本输入2', '文本输入3');
22063
+ }
22064
+ }
22065
+ processKeyDownEvent(evt) {
22066
+ if (evt.keyCode === 38 || evt.keyCode === 40) {
22067
+ if (this.docCtx.suggestions.prepareSuggestions.length) {
22068
+ this.onSuggestionsKeydown(evt);
22069
+ }
22070
+ }
22071
+ else if (evt.keyCode === 27) {
22072
+ if (this.docCtx.suggestions.prepareSuggestions.length) {
22073
+ evt.preventDefault();
22074
+ this.docCtx.suggestions.clear();
22075
+ this.onPatchVNodeSubject.next();
22076
+ }
22077
+ }
22078
+ else if (evt.keyCode === 13) {
22079
+ if (this.docCtx.suggestions.prepareSuggestions.length) {
22080
+ evt.preventDefault();
22081
+ const suggestions = this.docCtx.suggestions;
22082
+ const suggestion = suggestions.prepareSuggestions[suggestions.selectedIndex];
22083
+ if (suggestion) {
22084
+ this.insertSuggestion(suggestion);
22085
+ suggestions.clear();
22086
+ this.onPatchVNodeSubject.next();
22087
+ }
22088
+ else {
22089
+ suggestions.clear();
22090
+ this.onPatchVNodeSubject.next();
22091
+ }
22092
+ }
22093
+ }
22094
+ }
22095
+ /**
22096
+ * 处理候选词,键盘选择定位
22097
+ * @private
22098
+ */
22099
+ onSuggestionsKeydown(evt) {
22100
+ evt.preventDefault();
22101
+ let index = this.docCtx.suggestions.selectedIndex;
22102
+ if (evt.keyCode === 38) {
22103
+ index--;
22104
+ }
22105
+ else {
22106
+ index++;
22107
+ }
22108
+ if (index < 0) {
22109
+ index = this.docCtx.suggestions.prepareSuggestions.length - 1;
22110
+ }
22111
+ else if (index >= this.docCtx.suggestions.prepareSuggestions.length) {
22112
+ index = 0;
22113
+ }
22114
+ this.docCtx.suggestions.selectedIndex = index;
22115
+ this.onPatchVNodeSubject.next();
22116
+ }
22117
+ /**
22118
+ * 渲染联想、候选词
22119
+ * @private
22120
+ */
22121
+ renderSuggestions() {
22122
+ const editor = this;
22123
+ return {
22124
+ render() {
22125
+ if (!editor.docCtx.suggestions.prepareSuggestions || !editor.viewOptions.enableSuggestions) {
22126
+ editor.docCtx.suggestions.clear();
22127
+ return null;
22128
+ }
22129
+ const cursorPos = editor.selectionState.cursorPos;
22130
+ if (!cursorPos) {
22131
+ return null;
22132
+ }
22133
+ const renderSuggestion = (suggestions) => {
22134
+ if (!suggestions || !suggestions.length) {
22135
+ return [];
22136
+ }
22137
+ return [
22138
+ {
22139
+ sel: 'ul.editor-suggestions',
22140
+ data: {
22141
+ hook: {
22142
+ insert: (vNode) => {
22143
+ const elm = vNode.elm;
22144
+ elm.focus();
22145
+ }
22146
+ },
22147
+ on: {
22148
+ keydown: (evt) => {
22149
+ console.log("ul.editor-suggestions", evt);
22150
+ }
22151
+ }
22152
+ },
22153
+ children: suggestions.map((suggestion, index) => renderSuggestionItem(suggestion, index))
22154
+ }
22155
+ ];
22156
+ };
22157
+ const renderSuggestionItem = (suggestion, index) => {
22158
+ return {
22159
+ sel: 'li' + (index === editor.docCtx.suggestions.selectedIndex ? '.hovered' : ''),
22160
+ data: {
22161
+ on: {
22162
+ click: () => {
22163
+ editor.insertSuggestion(suggestion);
22164
+ }
22165
+ }
22166
+ },
22167
+ children: [{
22168
+ sel: 'span',
22169
+ data: {},
22170
+ text: suggestion.label
22171
+ }]
22172
+ };
22173
+ };
22174
+ return {
22175
+ sel: 'div.editor-suggestions-container',
22176
+ data: {
22177
+ style: {
22178
+ left: cursorPos.x + 'px',
22179
+ top: cursorPos.y + cursorPos.height + 'px',
22180
+ }
22181
+ },
22182
+ children: renderSuggestion(editor.docCtx.suggestions.prepareSuggestions)
22183
+ };
22184
+ }
22185
+ };
22186
+ }
22187
+ insertSuggestion(suggestion) {
22188
+ if (suggestion.action) {
22189
+ suggestion.action(suggestion);
22190
+ }
22191
+ else {
22192
+ const text = suggestion.value ? suggestion.value : suggestion.label;
22193
+ this.documentChange.appendText(text, this.docCtx.suggestions.currentMatchedText);
22194
+ }
21696
22195
  }
21697
22196
  }
21698
22197
 
@@ -26845,7 +27344,7 @@ class DocumentPrintOffscreenBase {
26845
27344
  afterPrint = new Subject();
26846
27345
  constructor() {
26847
27346
  this.viewOptions = new ViewOptions();
26848
- this.viewOptions.copyRightInfo = '万达信息电子病历编辑器,www.wondersgroup.com';
27347
+ this.viewOptions.copyRightInfo = '';
26849
27348
  this.viewOptions.showCharRect = true;
26850
27349
  this.viewOptions.drawCharRectColor = 'green';
26851
27350
  this.viewOptions.showLineRect = true;
@@ -27004,27 +27503,25 @@ function runTextLineRender(ele, data) {
27004
27503
  const deleteCurrentParagraph = (evt) => {
27005
27504
  const { selectionState, ctx: { viewOptions }, currentElement } = evt;
27006
27505
  evt.menus.push({
27007
- icon: 'DeleteTable', caption: '删除段落', eventObj: {
27008
- onClick: (cevt) => {
27009
- selectionState.clear();
27010
- const psymbol = ElementUtil.getLastLeafElement(currentElement);
27011
- const nextFocusableEle = ElementUtil.getRecursionNextSiblingElement(psymbol, false, true, viewOptions);
27012
- const parentContainer = currentElement.parent;
27013
- if (nextFocusableEle) {
27014
- if (nextFocusableEle.parent === parentContainer) {
27015
- selectionState.resetRange(nextFocusableEle, 0);
27016
- }
27017
- else {
27018
- selectionState.resetRange(parentContainer, 0);
27019
- }
27506
+ caption: '删除段落', click: () => {
27507
+ selectionState.clear();
27508
+ const psymbol = ElementUtil.getLastLeafElement(currentElement);
27509
+ const nextFocusableEle = ElementUtil.getRecursionNextSiblingElement(psymbol, false, true, viewOptions);
27510
+ const parentContainer = currentElement.parent;
27511
+ if (nextFocusableEle) {
27512
+ if (nextFocusableEle.parent === parentContainer) {
27513
+ selectionState.resetRange(nextFocusableEle, 0);
27020
27514
  }
27021
27515
  else {
27022
27516
  selectionState.resetRange(parentContainer, 0);
27023
- //selectionState.clear();
27024
27517
  }
27025
- currentElement.remove();
27026
- currentElement.destroy();
27027
27518
  }
27519
+ else {
27520
+ selectionState.resetRange(parentContainer, 0);
27521
+ //selectionState.clear();
27522
+ }
27523
+ currentElement.remove();
27524
+ currentElement.destroy();
27028
27525
  }
27029
27526
  });
27030
27527
  };
@@ -27048,39 +27545,24 @@ const deleteCurrentParagraph = (evt) => {
27048
27545
  // }
27049
27546
  // });
27050
27547
  // };
27051
- const setDataElementProps = (evt) => {
27052
- evt.menus.push({
27053
- icon: 'Settings', caption: '内容控制设置', eventObj: {
27054
- onClick: (e) => {
27055
- console.log('点击了');
27056
- }
27057
- }
27058
- });
27059
- };
27060
27548
  const onTableContextmenu = (evt) => {
27061
27549
  const { selectionState, ctx: { viewOptions }, currentElement } = evt;
27062
27550
  if (TableUtil.canDeleteTable(selectionState)) {
27063
27551
  evt.menus.push({
27064
- icon: 'DeleteTable', caption: '删除表格', eventObj: {
27065
- onClick: (cevt) => {
27066
- selectionState.clear();
27067
- const prevEle = ElementUtil.getRecursionPrevSiblingElement(currentElement, false, true, viewOptions);
27068
- if (prevEle) {
27069
- selectionState.resetRange(prevEle, -1);
27070
- }
27071
- currentElement.remove();
27072
- currentElement.destroy();
27552
+ caption: '删除表格', click: () => {
27553
+ selectionState.clear();
27554
+ const prevEle = ElementUtil.getRecursionPrevSiblingElement(currentElement, false, true, viewOptions);
27555
+ if (prevEle) {
27556
+ selectionState.resetRange(prevEle, -1);
27073
27557
  }
27558
+ currentElement.remove();
27559
+ currentElement.destroy();
27074
27560
  }
27075
27561
  });
27076
27562
  }
27077
27563
  if (TableUtil.canMergeCells(selectionState)) {
27078
27564
  evt.menus.push({
27079
- icon: 'MergeDuplicate', caption: '合并单元格', eventObj: {
27080
- onClick: (cevt) => {
27081
- TableUtil.mergeCells(selectionState);
27082
- }
27083
- }
27565
+ caption: '合并单元格', click: () => { TableUtil.mergeCells(selectionState); }
27084
27566
  });
27085
27567
  }
27086
27568
  if (TableUtil.canSplitCell(selectionState)) {
@@ -27092,27 +27574,19 @@ const onTableContextmenu = (evt) => {
27092
27574
  // }
27093
27575
  // });
27094
27576
  evt.menus.push({
27095
- icon: 'Combine', caption: '合并单元格还原', eventObj: {
27096
- onClick: (cevt) => {
27097
- TableUtil.restoreCell(selectionState);
27098
- }
27099
- }
27577
+ caption: '拆分单元格', click: () => { TableUtil.restoreCell(selectionState); }
27100
27578
  });
27101
27579
  }
27102
27580
  evt.menus.push({
27103
- icon: "Insert", caption: '上方插入段落', eventObj: {
27104
- onClick: (cevt) => {
27105
- currentElement.parent.addChild(ParagraphElement.createElement(), currentElement.getIndex());
27106
- currentElement.refreshView();
27107
- }
27581
+ caption: '上方插入段落', click: () => {
27582
+ currentElement.parent.addChild(ParagraphElement.createElement(), currentElement.getIndex());
27583
+ currentElement.refreshView();
27108
27584
  }
27109
27585
  });
27110
27586
  evt.menus.push({
27111
- icon: "Insert", caption: '下方插入段落', eventObj: {
27112
- onClick: (cevt) => {
27113
- currentElement.parent.addChild(ParagraphElement.createElement(), currentElement.getIndex() + 1);
27114
- currentElement.refreshView();
27115
- }
27587
+ caption: '下方插入段落', click: () => {
27588
+ currentElement.parent.addChild(ParagraphElement.createElement(), currentElement.getIndex() + 1);
27589
+ currentElement.refreshView();
27116
27590
  }
27117
27591
  });
27118
27592
  evt.menus = removeDuplicatesEvent(evt.menus);
@@ -27128,5 +27602,5 @@ function removeDuplicatesEvent(events) {
27128
27602
  return arr;
27129
27603
  }
27130
27604
 
27131
- 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, 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, 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, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag, MouseElementEvent, MousedownElementEvent, MuiltBlockLineRenderObject, 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, 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, exportDecoratorHTML, falseChar, fontMapFunc, formatEle, fromEvent, generatePatch, getCalleeName, getFocusTextSegment, inputText, insertEle, invokeTypeHandler, isDate, logUpdateEleProps, objectToString$4 as objectToString, onTableContextmenu, onceTask, parser, reactiveMap, removeEle, removeText, renderErrorTip, renderUnderWavyLine, runTextLineRender, setChildrenModifyFlag, setDataElementProps, setNotifyChangedCallback, setTraceTrackingFlag, suppressTracking, targetMaps, textLineRenderMode, toRawType, toTypeString, trueChar, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
27605
+ 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, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag, MouseElementEvent, MousedownElementEvent, MuiltBlockLineRenderObject, 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, exportDecoratorHTML, falseChar, fontMapFunc, formatEle, fromEvent, generatePatch, getCalleeName, getFocusTextSegment, inputText, insertEle, invokeTypeHandler, isDate, logUpdateEleProps, objectToString$4 as objectToString, onTableContextmenu, onceTask, parser, reactiveMap, removeEle, removeText, renderErrorTip, renderUnderWavyLine, runTextLineRender, setChildrenModifyFlag, setNotifyChangedCallback, setTraceTrackingFlag, suppressTracking, targetMaps, textLineRenderMode, toRawType, toTypeString, trueChar, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
27132
27606
  //# sourceMappingURL=index.js.map