@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-cjs.js CHANGED
@@ -1937,6 +1937,7 @@ class DocumentProps extends INotifyPropertyChanged {
1937
1937
  createUserName;
1938
1938
  createDate;
1939
1939
  scripts;
1940
+ columns = 1;
1940
1941
  clone(dest) {
1941
1942
  const clone = dest ?? new DocumentProps();
1942
1943
  super.cloneAttachedProperty(clone);
@@ -1950,6 +1951,7 @@ class DocumentProps extends INotifyPropertyChanged {
1950
1951
  clone.createUserName = this.createUserName;
1951
1952
  clone.createDate = this.createDate;
1952
1953
  clone.orient = this.orient;
1954
+ clone.columns = this.columns;
1953
1955
  return clone;
1954
1956
  }
1955
1957
  getSerializeProps() {
@@ -1969,6 +1971,9 @@ class DocumentProps extends INotifyPropertyChanged {
1969
1971
  if (this.orient && this.orient !== 'portrait') {
1970
1972
  props['orient'] = this.orient;
1971
1973
  }
1974
+ if (this.columns !== 1) {
1975
+ props.columns = this.columns;
1976
+ }
1972
1977
  return props;
1973
1978
  }
1974
1979
  }
@@ -3498,6 +3503,7 @@ class DocumentFactory extends ElementFactory {
3498
3503
  docProps.createUserName = props.createUserName;
3499
3504
  docProps.createDate = props.createDate;
3500
3505
  docProps.orient = props.orient ?? 'portrait';
3506
+ docProps.columns = props.columns ?? 1;
3501
3507
  return documentElement;
3502
3508
  }
3503
3509
  }
@@ -4229,10 +4235,10 @@ class DocumentHeaderRenderObject extends BlockContainerRenderObject {
4229
4235
  }
4230
4236
  exportHTML(event) {
4231
4237
  //判断页眉是否为输入内容
4232
- const isHeaderEmpty = ElementUtil.checkEmptyRenderContent(this);
4238
+ ElementUtil.checkEmptyRenderContent(this);
4233
4239
  let headerLine;
4234
4240
  //存在输入内容时,绘制页眉-页体分割线
4235
- if (!isHeaderEmpty || !this.element.disableClick || event.mode === 'print') {
4241
+ if (event.options.printHeaderFooterLine) {
4236
4242
  headerLine = {
4237
4243
  sel: 'path',
4238
4244
  data: {
@@ -5038,6 +5044,7 @@ class SelectionState {
5038
5044
  this.clear();
5039
5045
  }
5040
5046
  clear() {
5047
+ this.rangeDirty = true;
5041
5048
  this.range = null;
5042
5049
  this.startOffset = -1;
5043
5050
  this.endOffset = -1;
@@ -8343,6 +8350,7 @@ class DataElementCheck extends DataElementLeaf {
8343
8350
  }
8344
8351
  //如果当前是单选框并且当前已经被选中,则不作处理
8345
8352
  if (this.props.groupName && !this.props.multiSelect && this.props.checked) {
8353
+ this.props.checked = !this.props.checked;
8346
8354
  return;
8347
8355
  }
8348
8356
  this.props.checked = !this.props.checked;
@@ -14425,17 +14433,22 @@ class DocumentArrange {
14425
14433
  docRender.padding.top = bodyMarginTop;
14426
14434
  docRender.padding.bottom = bodyMarginBottom;
14427
14435
  const bodyLimitRect = this.getDocInnerRect(docRender);
14436
+ const docColumns = doc.props.columns ?? 1;
14437
+ bodyLimitRect.width = bodyLimitRect.width / docColumns;
14428
14438
  const bodyRender = doc.bodyElement.createRenderObject();
14429
14439
  const bodyArray = [];
14430
14440
  let { emptyBody: pageBodyRender, innerRect: bodyInnerLimitRect } = this.createEmptyBodyRender(bodyRender, bodyLimitRect);
14431
14441
  bodyArray.push(pageBodyRender);
14442
+ //文档分栏
14432
14443
  const createBodyHolder = () => {
14433
- const { emptyBody, innerRect } = this.createEmptyBodyRender(bodyRender, bodyLimitRect);
14444
+ let { emptyBody, innerRect } = this.createEmptyBodyRender(bodyRender, bodyLimitRect);
14434
14445
  pageBodyRender = emptyBody;
14435
14446
  bodyInnerLimitRect = innerRect;
14436
14447
  bodyArray.push(pageBodyRender);
14437
14448
  };
14438
14449
  const appendToBody = (item) => {
14450
+ //处理分栏
14451
+ //item.rect.x = bodyInnerLimitRect.width *currColumn / docColumns;
14439
14452
  item.rect.y = bodyInnerLimitRect.height + item.margin.top;
14440
14453
  pageBodyRender.addChild(item);
14441
14454
  bodyInnerLimitRect.height += item.rect.height + item.margin.top + item.margin.bottom;
@@ -14476,30 +14489,35 @@ class DocumentArrange {
14476
14489
  }
14477
14490
  const docPages = [];
14478
14491
  let pageY = this.options.docSpace;
14492
+ //当前分栏
14493
+ let currColumn = 0;
14494
+ let prevDocRender = null;
14479
14495
  for (let i = 0; i < bodyArray.length; i++) {
14480
14496
  const body = bodyArray[i];
14481
- const documentRender = doc.createRenderObject();
14482
- docPages.push(documentRender);
14483
- documentRender.rect.y = pageY;
14497
+ if (!prevDocRender) {
14498
+ prevDocRender = doc.createRenderObject();
14499
+ prevDocRender.rect.y = pageY;
14500
+ docPages.push(prevDocRender);
14501
+ }
14502
+ const documentRender = prevDocRender;
14484
14503
  const limitRect = documentRender.getInnerRect();
14485
14504
  const cloneHeaderRender = headerRender.clone();
14486
14505
  cloneHeaderRender.rect.x = limitRect.x;
14487
14506
  cloneHeaderRender.rect.y = headerLine;
14488
- documentRender.addChild(cloneHeaderRender);
14489
- body.rect.x = limitRect.x;
14507
+ currColumn === 0 && documentRender.addChild(cloneHeaderRender);
14508
+ body.rect.x = limitRect.x + bodyLimitRect.width * currColumn;
14490
14509
  body.rect.y = bodyMarginTop;
14491
- if (!this.options.fullPageView) {
14510
+ if (!this.options.fullPageView || docColumns > 1) {
14492
14511
  body.rect.height = bodyInnerLimitRect.maxHeight;
14493
14512
  }
14494
14513
  else {
14495
14514
  documentRender.rect.height = body.rect.height + body.rect.y + bodyMarginBottom;
14496
14515
  }
14497
14516
  documentRender.addChild(body);
14498
- pageY += documentRender.rect.height + this.options.docSpace;
14499
14517
  const cloneFooterRender = footerRender.clone();
14500
14518
  cloneFooterRender.rect.x = limitRect.x;
14501
14519
  cloneFooterRender.rect.y = documentRender.rect.height - bodyMarginBottom;
14502
- documentRender.addChild(cloneFooterRender);
14520
+ currColumn === 0 && documentRender.addChild(cloneFooterRender);
14503
14521
  //审阅模式,添加审阅窗口
14504
14522
  if (this.options.showReviewWindow && commentsRender) {
14505
14523
  const commentsContainer = this.createRenderObject(commentsRender.element);
@@ -14509,6 +14527,12 @@ class DocumentArrange {
14509
14527
  commentsContainer.rect.x = documentRender.rect.x + documentRender.rect.width;
14510
14528
  documentRender.rect.width += this.options.reviewWindowWidth;
14511
14529
  }
14530
+ currColumn++;
14531
+ if (currColumn === docColumns) {
14532
+ currColumn = 0;
14533
+ prevDocRender = null;
14534
+ pageY += documentRender.rect.height + this.options.docSpace;
14535
+ }
14512
14536
  }
14513
14537
  return docPages;
14514
14538
  }
@@ -14705,7 +14729,12 @@ class DocumentArrange {
14705
14729
  if (cutRow) {
14706
14730
  cloneTbRender.addChild(cutRow);
14707
14731
  sumHeight += cutRow.rect.height;
14708
- cutRows.push(currRow);
14732
+ if (currRow.getItems().every(item => item.length !== 0)) {
14733
+ cutRows.push(currRow);
14734
+ }
14735
+ else {
14736
+ tbRender.removeChild(currRow);
14737
+ }
14709
14738
  if (currRow === joinRow) {
14710
14739
  break;
14711
14740
  }
@@ -16847,6 +16876,7 @@ class DocumentEvent {
16847
16876
  hitInfoChanged = new Subject$1();
16848
16877
  clickEvent = new Subject$1();
16849
16878
  dblClickEvent = new Subject$1();
16879
+ tripleClickEvent = new Subject$1();
16850
16880
  changeCursor = new Subject$1();
16851
16881
  contextMenu = new Subject$1();
16852
16882
  trackTipsChanged = new Subject$1();
@@ -18123,6 +18153,35 @@ class DocumentEvent {
18123
18153
  };
18124
18154
  return cancelToken;
18125
18155
  }
18156
+ clicks = 0;
18157
+ timeout;
18158
+ /**
18159
+ * 处理三击事件
18160
+ */
18161
+ handleTripleClick() {
18162
+ this.clicks++;
18163
+ let curr = this;
18164
+ if (this.clicks === 1) {
18165
+ // 设置延时,等待第二次点击
18166
+ this.timeout = setTimeout(function () {
18167
+ curr.clicks = 0;
18168
+ }, 300);
18169
+ }
18170
+ else if (this.clicks === 2) {
18171
+ // 第二次点击后,清除延时
18172
+ clearTimeout(curr.timeout);
18173
+ // 设置延时,等待第三次点击
18174
+ curr.timeout = setTimeout(function () {
18175
+ curr.clicks = 0;
18176
+ }, 300);
18177
+ }
18178
+ else if (curr.clicks === 3) {
18179
+ // 第三次点击后,处理三击事件并清除延时
18180
+ clearTimeout(curr.timeout);
18181
+ this.tripleClickEvent.next();
18182
+ this.clicks = 0;
18183
+ }
18184
+ }
18126
18185
  }
18127
18186
 
18128
18187
  /**
@@ -27220,7 +27279,7 @@ class DocEditor {
27220
27279
  }
27221
27280
  }
27222
27281
  else if (!collapsed && ancestorCommonControl) {
27223
- return ElementUtil.getParent(startControl, validateDataEle);
27282
+ return ElementUtil.getParent(ancestorCommonControl, validateDataEle);
27224
27283
  }
27225
27284
  return null;
27226
27285
  }