@hailin-zheng/editor-core 2.0.18 → 2.0.20

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
@@ -1907,6 +1907,7 @@ class DocumentProps extends INotifyPropertyChanged {
1907
1907
  createUserName;
1908
1908
  createDate;
1909
1909
  scripts;
1910
+ columns = 1;
1910
1911
  clone(dest) {
1911
1912
  const clone = dest ?? new DocumentProps();
1912
1913
  super.cloneAttachedProperty(clone);
@@ -1920,6 +1921,7 @@ class DocumentProps extends INotifyPropertyChanged {
1920
1921
  clone.createUserName = this.createUserName;
1921
1922
  clone.createDate = this.createDate;
1922
1923
  clone.orient = this.orient;
1924
+ clone.columns = this.columns;
1923
1925
  return clone;
1924
1926
  }
1925
1927
  getSerializeProps() {
@@ -1939,6 +1941,9 @@ class DocumentProps extends INotifyPropertyChanged {
1939
1941
  if (this.orient && this.orient !== 'portrait') {
1940
1942
  props['orient'] = this.orient;
1941
1943
  }
1944
+ if (this.columns !== 1) {
1945
+ props.columns = this.columns;
1946
+ }
1942
1947
  return props;
1943
1948
  }
1944
1949
  }
@@ -3468,6 +3473,7 @@ class DocumentFactory extends ElementFactory {
3468
3473
  docProps.createUserName = props.createUserName;
3469
3474
  docProps.createDate = props.createDate;
3470
3475
  docProps.orient = props.orient ?? 'portrait';
3476
+ docProps.columns = props.columns ?? 1;
3471
3477
  return documentElement;
3472
3478
  }
3473
3479
  }
@@ -4199,10 +4205,10 @@ class DocumentHeaderRenderObject extends BlockContainerRenderObject {
4199
4205
  }
4200
4206
  exportHTML(event) {
4201
4207
  //判断页眉是否为输入内容
4202
- const isHeaderEmpty = ElementUtil.checkEmptyRenderContent(this);
4208
+ ElementUtil.checkEmptyRenderContent(this);
4203
4209
  let headerLine;
4204
4210
  //存在输入内容时,绘制页眉-页体分割线
4205
- if (!isHeaderEmpty || !this.element.disableClick || event.mode === 'print') {
4211
+ if (event.options.printHeaderFooterLine) {
4206
4212
  headerLine = {
4207
4213
  sel: 'path',
4208
4214
  data: {
@@ -5008,6 +5014,7 @@ class SelectionState {
5008
5014
  this.clear();
5009
5015
  }
5010
5016
  clear() {
5017
+ this.rangeDirty = true;
5011
5018
  this.range = null;
5012
5019
  this.startOffset = -1;
5013
5020
  this.endOffset = -1;
@@ -8313,6 +8320,7 @@ class DataElementCheck extends DataElementLeaf {
8313
8320
  }
8314
8321
  //如果当前是单选框并且当前已经被选中,则不作处理
8315
8322
  if (this.props.groupName && !this.props.multiSelect && this.props.checked) {
8323
+ this.props.checked = !this.props.checked;
8316
8324
  return;
8317
8325
  }
8318
8326
  this.props.checked = !this.props.checked;
@@ -14395,17 +14403,22 @@ class DocumentArrange {
14395
14403
  docRender.padding.top = bodyMarginTop;
14396
14404
  docRender.padding.bottom = bodyMarginBottom;
14397
14405
  const bodyLimitRect = this.getDocInnerRect(docRender);
14406
+ const docColumns = doc.props.columns ?? 1;
14407
+ bodyLimitRect.width = bodyLimitRect.width / docColumns;
14398
14408
  const bodyRender = doc.bodyElement.createRenderObject();
14399
14409
  const bodyArray = [];
14400
14410
  let { emptyBody: pageBodyRender, innerRect: bodyInnerLimitRect } = this.createEmptyBodyRender(bodyRender, bodyLimitRect);
14401
14411
  bodyArray.push(pageBodyRender);
14412
+ //文档分栏
14402
14413
  const createBodyHolder = () => {
14403
- const { emptyBody, innerRect } = this.createEmptyBodyRender(bodyRender, bodyLimitRect);
14414
+ let { emptyBody, innerRect } = this.createEmptyBodyRender(bodyRender, bodyLimitRect);
14404
14415
  pageBodyRender = emptyBody;
14405
14416
  bodyInnerLimitRect = innerRect;
14406
14417
  bodyArray.push(pageBodyRender);
14407
14418
  };
14408
14419
  const appendToBody = (item) => {
14420
+ //处理分栏
14421
+ //item.rect.x = bodyInnerLimitRect.width *currColumn / docColumns;
14409
14422
  item.rect.y = bodyInnerLimitRect.height + item.margin.top;
14410
14423
  pageBodyRender.addChild(item);
14411
14424
  bodyInnerLimitRect.height += item.rect.height + item.margin.top + item.margin.bottom;
@@ -14446,30 +14459,35 @@ class DocumentArrange {
14446
14459
  }
14447
14460
  const docPages = [];
14448
14461
  let pageY = this.options.docSpace;
14462
+ //当前分栏
14463
+ let currColumn = 0;
14464
+ let prevDocRender = null;
14449
14465
  for (let i = 0; i < bodyArray.length; i++) {
14450
14466
  const body = bodyArray[i];
14451
- const documentRender = doc.createRenderObject();
14452
- docPages.push(documentRender);
14453
- documentRender.rect.y = pageY;
14467
+ if (!prevDocRender) {
14468
+ prevDocRender = doc.createRenderObject();
14469
+ prevDocRender.rect.y = pageY;
14470
+ docPages.push(prevDocRender);
14471
+ }
14472
+ const documentRender = prevDocRender;
14454
14473
  const limitRect = documentRender.getInnerRect();
14455
14474
  const cloneHeaderRender = headerRender.clone();
14456
14475
  cloneHeaderRender.rect.x = limitRect.x;
14457
14476
  cloneHeaderRender.rect.y = headerLine;
14458
- documentRender.addChild(cloneHeaderRender);
14459
- body.rect.x = limitRect.x;
14477
+ currColumn === 0 && documentRender.addChild(cloneHeaderRender);
14478
+ body.rect.x = limitRect.x + bodyLimitRect.width * currColumn;
14460
14479
  body.rect.y = bodyMarginTop;
14461
- if (!this.options.fullPageView) {
14480
+ if (!this.options.fullPageView || docColumns > 1) {
14462
14481
  body.rect.height = bodyInnerLimitRect.maxHeight;
14463
14482
  }
14464
14483
  else {
14465
14484
  documentRender.rect.height = body.rect.height + body.rect.y + bodyMarginBottom;
14466
14485
  }
14467
14486
  documentRender.addChild(body);
14468
- pageY += documentRender.rect.height + this.options.docSpace;
14469
14487
  const cloneFooterRender = footerRender.clone();
14470
14488
  cloneFooterRender.rect.x = limitRect.x;
14471
14489
  cloneFooterRender.rect.y = documentRender.rect.height - bodyMarginBottom;
14472
- documentRender.addChild(cloneFooterRender);
14490
+ currColumn === 0 && documentRender.addChild(cloneFooterRender);
14473
14491
  //审阅模式,添加审阅窗口
14474
14492
  if (this.options.showReviewWindow && commentsRender) {
14475
14493
  const commentsContainer = this.createRenderObject(commentsRender.element);
@@ -14479,6 +14497,12 @@ class DocumentArrange {
14479
14497
  commentsContainer.rect.x = documentRender.rect.x + documentRender.rect.width;
14480
14498
  documentRender.rect.width += this.options.reviewWindowWidth;
14481
14499
  }
14500
+ currColumn++;
14501
+ if (currColumn === docColumns) {
14502
+ currColumn = 0;
14503
+ prevDocRender = null;
14504
+ pageY += documentRender.rect.height + this.options.docSpace;
14505
+ }
14482
14506
  }
14483
14507
  return docPages;
14484
14508
  }
@@ -14675,7 +14699,12 @@ class DocumentArrange {
14675
14699
  if (cutRow) {
14676
14700
  cloneTbRender.addChild(cutRow);
14677
14701
  sumHeight += cutRow.rect.height;
14678
- cutRows.push(currRow);
14702
+ if (currRow.getItems().every(item => item.length !== 0)) {
14703
+ cutRows.push(currRow);
14704
+ }
14705
+ else {
14706
+ tbRender.removeChild(currRow);
14707
+ }
14679
14708
  if (currRow === joinRow) {
14680
14709
  break;
14681
14710
  }
@@ -16817,6 +16846,7 @@ class DocumentEvent {
16817
16846
  hitInfoChanged = new Subject$1();
16818
16847
  clickEvent = new Subject$1();
16819
16848
  dblClickEvent = new Subject$1();
16849
+ tripleClickEvent = new Subject$1();
16820
16850
  changeCursor = new Subject$1();
16821
16851
  contextMenu = new Subject$1();
16822
16852
  trackTipsChanged = new Subject$1();
@@ -18093,6 +18123,35 @@ class DocumentEvent {
18093
18123
  };
18094
18124
  return cancelToken;
18095
18125
  }
18126
+ clicks = 0;
18127
+ timeout;
18128
+ /**
18129
+ * 处理三击事件
18130
+ */
18131
+ handleTripleClick() {
18132
+ this.clicks++;
18133
+ let curr = this;
18134
+ if (this.clicks === 1) {
18135
+ // 设置延时,等待第二次点击
18136
+ this.timeout = setTimeout(function () {
18137
+ curr.clicks = 0;
18138
+ }, 300);
18139
+ }
18140
+ else if (this.clicks === 2) {
18141
+ // 第二次点击后,清除延时
18142
+ clearTimeout(curr.timeout);
18143
+ // 设置延时,等待第三次点击
18144
+ curr.timeout = setTimeout(function () {
18145
+ curr.clicks = 0;
18146
+ }, 300);
18147
+ }
18148
+ else if (curr.clicks === 3) {
18149
+ // 第三次点击后,处理三击事件并清除延时
18150
+ clearTimeout(curr.timeout);
18151
+ this.tripleClickEvent.next();
18152
+ this.clicks = 0;
18153
+ }
18154
+ }
18096
18155
  }
18097
18156
 
18098
18157
  /**
@@ -27190,7 +27249,7 @@ class DocEditor {
27190
27249
  }
27191
27250
  }
27192
27251
  else if (!collapsed && ancestorCommonControl) {
27193
- return ElementUtil.getParent(startControl, validateDataEle);
27252
+ return ElementUtil.getParent(ancestorCommonControl, validateDataEle);
27194
27253
  }
27195
27254
  return null;
27196
27255
  }