@hufe921/canvas-editor 0.9.33 → 0.9.35

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.
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
  var index = "";
26
- const version = "0.9.33";
26
+ const version = "0.9.35";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -3432,8 +3432,10 @@ function formatElementList(elementList, options) {
3432
3432
  const titleOptions = editorOptions.title;
3433
3433
  for (let v = 0; v < valueList.length; v++) {
3434
3434
  const value = valueList[v];
3435
- value.titleId = titleId;
3436
- value.level = el.level;
3435
+ if (el.level) {
3436
+ value.titleId = titleId;
3437
+ value.level = el.level;
3438
+ }
3437
3439
  if (isTextLikeElement(value)) {
3438
3440
  if (!value.size) {
3439
3441
  value.size = titleOptions[titleSizeMapping[value.level]];
@@ -3762,6 +3764,9 @@ function zipElementList(payload) {
3762
3764
  if (td.verticalAlign) {
3763
3765
  zipTd.verticalAlign = td.verticalAlign;
3764
3766
  }
3767
+ if (td.backgroundColor) {
3768
+ zipTd.backgroundColor = td.backgroundColor;
3769
+ }
3765
3770
  tr.tdList[d] = zipTd;
3766
3771
  }
3767
3772
  }
@@ -3834,7 +3839,7 @@ function zipElementList(payload) {
3834
3839
  element = controlElement;
3835
3840
  }
3836
3841
  const pickElement = pickElementAttr(element);
3837
- if (!element.type || element.type === ElementType.TEXT) {
3842
+ if (!element.type || element.type === ElementType.TEXT || element.type === ElementType.SUBSCRIPT || element.type === ElementType.SUPERSCRIPT) {
3838
3843
  while (e < elementList.length) {
3839
3844
  const nextElement = elementList[e + 1];
3840
3845
  e++;
@@ -3879,12 +3884,15 @@ function getAnchorElement(elementList, anchorIndex) {
3879
3884
  const anchorNextElement = elementList[anchorIndex + 1];
3880
3885
  return !anchorElement.listId && anchorElement.value === ZERO && anchorNextElement && anchorNextElement.value !== ZERO ? anchorNextElement : anchorElement;
3881
3886
  }
3882
- function formatElementContext(sourceElementList, formatElementList2, anchorIndex) {
3887
+ function formatElementContext(sourceElementList, formatElementList2, anchorIndex, options) {
3883
3888
  const copyElement = getAnchorElement(sourceElementList, anchorIndex);
3884
3889
  if (!copyElement)
3885
3890
  return;
3891
+ const { isBreakWhenWrap = false } = options || {};
3886
3892
  for (let e = 0; e < formatElementList2.length; e++) {
3887
3893
  const targetElement = formatElementList2[e];
3894
+ if (isBreakWhenWrap && !copyElement.listId && /^\n/.test(targetElement.value))
3895
+ break;
3888
3896
  if (!copyElement.listId && targetElement.type === ElementType.LIST)
3889
3897
  continue;
3890
3898
  if (targetElement.valueList && targetElement.valueList.length) {
@@ -3927,8 +3935,15 @@ function writeClipboardItem(text, html) {
3927
3935
  }
3928
3936
  }
3929
3937
  function convertElementToDom(element, options) {
3930
- const isBlock = element.rowFlex === RowFlex.CENTER || element.rowFlex === RowFlex.RIGHT;
3931
- const dom = document.createElement(isBlock ? "p" : "span");
3938
+ let tagName = "span";
3939
+ if (element.type === ElementType.SUPERSCRIPT) {
3940
+ tagName = "sup";
3941
+ } else if (element.type === ElementType.SUBSCRIPT) {
3942
+ tagName = "sub";
3943
+ } else if (element.rowFlex === RowFlex.CENTER || element.rowFlex === RowFlex.RIGHT) {
3944
+ tagName = "p";
3945
+ }
3946
+ const dom = document.createElement(tagName);
3932
3947
  dom.style.fontFamily = element.font || options.defaultFont;
3933
3948
  if (element.rowFlex) {
3934
3949
  const isAlignment = element.rowFlex === RowFlex.ALIGNMENT;
@@ -3970,6 +3985,9 @@ function writeElementList(elementList, options) {
3970
3985
  tdDom.rowSpan = td.rowspan;
3971
3986
  const childDom = buildDomFromElementList(zipElementList(td.value));
3972
3987
  tdDom.innerHTML = childDom.innerHTML;
3988
+ if (td.backgroundColor) {
3989
+ tdDom.style.backgroundColor = td.backgroundColor;
3990
+ }
3973
3991
  trDom.append(tdDom);
3974
3992
  }
3975
3993
  tableDom.append(trDom);
@@ -4071,28 +4089,41 @@ function writeElementList(elementList, options) {
4071
4089
  return;
4072
4090
  writeClipboardItem(text, html);
4073
4091
  }
4092
+ function convertTextNodeToElement(textNode) {
4093
+ if (!textNode || textNode.nodeType !== 3)
4094
+ return null;
4095
+ const parentNode = textNode.parentNode;
4096
+ const rowFlex = getElementRowFlex(parentNode);
4097
+ const value = textNode.textContent;
4098
+ const style = window.getComputedStyle(parentNode);
4099
+ if (!value || parentNode.nodeName === "STYLE")
4100
+ return null;
4101
+ const element = {
4102
+ value,
4103
+ color: style.color,
4104
+ bold: Number(style.fontWeight) > 500,
4105
+ italic: style.fontStyle.includes("italic"),
4106
+ size: Math.floor(parseFloat(style.fontSize))
4107
+ };
4108
+ if (parentNode.nodeName === "SUB") {
4109
+ element.type = ElementType.SUBSCRIPT;
4110
+ } else if (parentNode.nodeName === "SUP") {
4111
+ element.type = ElementType.SUPERSCRIPT;
4112
+ }
4113
+ if (rowFlex !== RowFlex.LEFT) {
4114
+ element.rowFlex = rowFlex;
4115
+ }
4116
+ if (style.backgroundColor !== "rgba(0, 0, 0, 0)") {
4117
+ element.highlight = style.backgroundColor;
4118
+ }
4119
+ return element;
4120
+ }
4074
4121
  function getElementListByHTML(htmlText, options) {
4075
4122
  const elementList = [];
4076
4123
  function findTextNode(dom) {
4077
4124
  if (dom.nodeType === 3) {
4078
- const parentNode = dom.parentNode;
4079
- const rowFlex = getElementRowFlex(parentNode);
4080
- const value = dom.textContent;
4081
- const style = window.getComputedStyle(parentNode);
4082
- if (value && parentNode.nodeName !== "STYLE") {
4083
- const element = {
4084
- value,
4085
- color: style.color,
4086
- bold: Number(style.fontWeight) > 500,
4087
- italic: style.fontStyle.includes("italic"),
4088
- size: Math.floor(Number(style.fontSize.replace("px", "")))
4089
- };
4090
- if (rowFlex !== RowFlex.LEFT) {
4091
- element.rowFlex = rowFlex;
4092
- }
4093
- if (style.backgroundColor !== "rgba(0, 0, 0, 0)") {
4094
- element.highlight = style.backgroundColor;
4095
- }
4125
+ const element = convertTextNodeToElement(dom);
4126
+ if (element) {
4096
4127
  elementList.push(element);
4097
4128
  }
4098
4129
  } else if (dom.nodeType === 1) {
@@ -4193,6 +4224,9 @@ function getElementListByHTML(htmlText, options) {
4193
4224
  rowspan: tableCell.rowSpan,
4194
4225
  value: valueList
4195
4226
  };
4227
+ if (tableCell.style.backgroundColor) {
4228
+ td.backgroundColor = tableCell.style.backgroundColor;
4229
+ }
4196
4230
  tr.tdList.push(td);
4197
4231
  });
4198
4232
  if (tr.tdList.length) {
@@ -4312,6 +4346,8 @@ class CursorAgent {
4312
4346
  let start = 0;
4313
4347
  while (start < pasteElementList.length) {
4314
4348
  const pasteElement = pasteElementList[start];
4349
+ if (anchorElement.titleId && /^\n/.test(pasteElement.value))
4350
+ break;
4315
4351
  if (VIRTUAL_ELEMENT_TYPE.includes(pasteElement.type)) {
4316
4352
  pasteElementList.splice(start, 1);
4317
4353
  if (pasteElement.valueList) {
@@ -4328,7 +4364,9 @@ class CursorAgent {
4328
4364
  start++;
4329
4365
  }
4330
4366
  }
4331
- formatElementContext(elementList, pasteElementList, startIndex);
4367
+ formatElementContext(elementList, pasteElementList, startIndex, {
4368
+ isBreakWhenWrap: true
4369
+ });
4332
4370
  }
4333
4371
  this.draw.insertElementList(pasteElementList);
4334
4372
  });
@@ -4371,12 +4409,14 @@ class CursorAgent {
4371
4409
  }
4372
4410
  class Cursor {
4373
4411
  constructor(draw, canvasEvent) {
4412
+ __publicField(this, "ANIMATION_CLASS", `${EDITOR_PREFIX}-cursor--animation`);
4374
4413
  __publicField(this, "draw");
4375
4414
  __publicField(this, "container");
4376
4415
  __publicField(this, "options");
4377
4416
  __publicField(this, "position");
4378
4417
  __publicField(this, "cursorDom");
4379
4418
  __publicField(this, "cursorAgent");
4419
+ __publicField(this, "blinkTimeout");
4380
4420
  this.draw = draw;
4381
4421
  this.container = draw.getContainer();
4382
4422
  this.position = draw.getPosition();
@@ -4385,6 +4425,7 @@ class Cursor {
4385
4425
  this.cursorDom.classList.add(`${EDITOR_PREFIX}-cursor`);
4386
4426
  this.container.append(this.cursorDom);
4387
4427
  this.cursorAgent = new CursorAgent(draw, canvasEvent);
4428
+ this.blinkTimeout = null;
4388
4429
  }
4389
4430
  getCursorDom() {
4390
4431
  return this.cursorDom;
@@ -4398,6 +4439,25 @@ class Cursor {
4398
4439
  clearAgentDomValue() {
4399
4440
  return this.getAgentDom().value = "";
4400
4441
  }
4442
+ _blinkStart() {
4443
+ this.cursorDom.classList.add(this.ANIMATION_CLASS);
4444
+ }
4445
+ _blinkStop() {
4446
+ this.cursorDom.classList.remove(this.ANIMATION_CLASS);
4447
+ }
4448
+ _setBlinkTimeout() {
4449
+ this._clearBlinkTimeout();
4450
+ this.blinkTimeout = window.setTimeout(() => {
4451
+ this._blinkStart();
4452
+ }, 500);
4453
+ }
4454
+ _clearBlinkTimeout() {
4455
+ if (this.blinkTimeout) {
4456
+ this._blinkStop();
4457
+ window.clearTimeout(this.blinkTimeout);
4458
+ this.blinkTimeout = null;
4459
+ }
4460
+ }
4401
4461
  drawCursor(payload) {
4402
4462
  const cursorPosition = this.position.getCursorPosition();
4403
4463
  if (!cursorPosition)
@@ -4431,18 +4491,15 @@ class Cursor {
4431
4491
  this.cursorDom.style.top = `${cursorTop}px`;
4432
4492
  this.cursorDom.style.display = isReadonly ? "none" : "block";
4433
4493
  this.cursorDom.style.height = `${cursorHeight}px`;
4434
- const animationClassName = `${EDITOR_PREFIX}-cursor--animation`;
4435
4494
  if (isBlink) {
4436
- setTimeout(() => {
4437
- this.cursorDom.classList.add(animationClassName);
4438
- }, 200);
4495
+ this._setBlinkTimeout();
4439
4496
  } else {
4440
- this.cursorDom.classList.remove(animationClassName);
4497
+ this._clearBlinkTimeout();
4441
4498
  }
4442
4499
  }
4443
4500
  recoveryCursor() {
4444
4501
  this.cursorDom.style.display = "none";
4445
- this.cursorDom.classList.remove(`${EDITOR_PREFIX}-cursor--animation`);
4502
+ this._clearBlinkTimeout();
4446
4503
  }
4447
4504
  }
4448
4505
  var MouseEventButton;
@@ -5798,6 +5855,7 @@ var EditorComponent;
5798
5855
  EditorComponent2["FOOTER"] = "footer";
5799
5856
  EditorComponent2["CONTEXTMENU"] = "contextmenu";
5800
5857
  EditorComponent2["POPUP"] = "popup";
5858
+ EditorComponent2["CATALOG"] = "catalog";
5801
5859
  })(EditorComponent || (EditorComponent = {}));
5802
5860
  var EditorContext;
5803
5861
  (function(EditorContext2) {
@@ -6987,7 +7045,9 @@ const defaultPageNumberOption = {
6987
7045
  rowFlex: RowFlex.CENTER,
6988
7046
  format: FORMAT_PLACEHOLDER.PAGE_NO,
6989
7047
  numberType: NumberType.ARABIC,
6990
- disabled: false
7048
+ disabled: false,
7049
+ startPageNo: 1,
7050
+ fromPageNo: 0
6991
7051
  };
6992
7052
  class PageNumber {
6993
7053
  constructor(draw) {
@@ -6997,17 +7057,19 @@ class PageNumber {
6997
7057
  this.options = draw.getOptions();
6998
7058
  }
6999
7059
  render(ctx, pageNo) {
7000
- const { pageNumber: { size, font, color, rowFlex, numberType, format }, scale, pageMode } = this.options;
7060
+ const { scale, pageMode, pageNumber: { size, font, color, rowFlex, numberType, format, startPageNo, fromPageNo } } = this.options;
7061
+ if (pageNo < fromPageNo)
7062
+ return;
7001
7063
  let text = format;
7002
7064
  const pageNoReg = new RegExp(FORMAT_PLACEHOLDER.PAGE_NO);
7003
7065
  if (pageNoReg.test(text)) {
7004
- const realPageNo = pageNo + 1;
7066
+ const realPageNo = pageNo + startPageNo - fromPageNo;
7005
7067
  const pageNoText = numberType === NumberType.CHINESE ? convertNumberToChinese(realPageNo) : `${realPageNo}`;
7006
7068
  text = text.replace(pageNoReg, pageNoText);
7007
7069
  }
7008
7070
  const pageCountReg = new RegExp(FORMAT_PLACEHOLDER.PAGE_COUNT);
7009
7071
  if (pageCountReg.test(text)) {
7010
- const pageCount = this.draw.getPageCount();
7072
+ const pageCount = this.draw.getPageCount() - fromPageNo;
7011
7073
  const pageCountText = numberType === NumberType.CHINESE ? convertNumberToChinese(pageCount) : `${pageCount}`;
7012
7074
  text = text.replace(pageCountReg, pageCountText);
7013
7075
  }
@@ -7170,8 +7232,10 @@ class SelectionObserver {
7170
7232
  }
7171
7233
  class TableParticle {
7172
7234
  constructor(draw) {
7235
+ __publicField(this, "draw");
7173
7236
  __publicField(this, "range");
7174
7237
  __publicField(this, "options");
7238
+ this.draw = draw;
7175
7239
  this.range = draw.getRange();
7176
7240
  this.options = draw.getOptions();
7177
7241
  }
@@ -7191,7 +7255,45 @@ class TableParticle {
7191
7255
  }
7192
7256
  return trList;
7193
7257
  }
7194
- _drawBorder(payload) {
7258
+ getRangeRowCol() {
7259
+ const { isTable, index: index2, trIndex, tdIndex } = this.draw.getPosition().getPositionContext();
7260
+ if (!isTable)
7261
+ return null;
7262
+ const { isCrossRowCol, startTdIndex, endTdIndex, startTrIndex, endTrIndex } = this.range.getRange();
7263
+ const originalElementList = this.draw.getOriginalElementList();
7264
+ const element = originalElementList[index2];
7265
+ const curTrList = element.trList;
7266
+ if (!isCrossRowCol) {
7267
+ return [[curTrList[trIndex].tdList[tdIndex]]];
7268
+ }
7269
+ let startTd = curTrList[startTrIndex].tdList[startTdIndex];
7270
+ let endTd = curTrList[endTrIndex].tdList[endTdIndex];
7271
+ if (startTd.x > endTd.x || startTd.y > endTd.y) {
7272
+ [startTd, endTd] = [endTd, startTd];
7273
+ }
7274
+ const startColIndex = startTd.colIndex;
7275
+ const endColIndex = endTd.colIndex + (endTd.colspan - 1);
7276
+ const startRowIndex = startTd.rowIndex;
7277
+ const endRowIndex = endTd.rowIndex + (endTd.rowspan - 1);
7278
+ const rowCol = [];
7279
+ for (let t = 0; t < curTrList.length; t++) {
7280
+ const tr = curTrList[t];
7281
+ const tdList = [];
7282
+ for (let d = 0; d < tr.tdList.length; d++) {
7283
+ const td = tr.tdList[d];
7284
+ const tdColIndex = td.colIndex;
7285
+ const tdRowIndex = td.rowIndex;
7286
+ if (tdColIndex >= startColIndex && tdColIndex <= endColIndex && tdRowIndex >= startRowIndex && tdRowIndex <= endRowIndex) {
7287
+ tdList.push(td);
7288
+ }
7289
+ }
7290
+ if (tdList.length) {
7291
+ rowCol.push(tdList);
7292
+ }
7293
+ }
7294
+ return rowCol.length ? rowCol : null;
7295
+ }
7296
+ _drawOuterBorder(payload) {
7195
7297
  const { ctx, startX, startY, width, height, isDrawFullBorder } = payload;
7196
7298
  ctx.beginPath();
7197
7299
  const x = Math.round(startX);
@@ -7207,6 +7309,66 @@ class TableParticle {
7207
7309
  ctx.stroke();
7208
7310
  ctx.translate(-0.5, -0.5);
7209
7311
  }
7312
+ _drawBorder(ctx, element, startX, startY) {
7313
+ const { colgroup, trList, borderType } = element;
7314
+ if (!colgroup || !trList || borderType === TableBorder.EMPTY)
7315
+ return;
7316
+ const { scale } = this.options;
7317
+ const tableWidth = element.width * scale;
7318
+ const tableHeight = element.height * scale;
7319
+ const isExternalBorderType = borderType === TableBorder.EXTERNAL;
7320
+ ctx.save();
7321
+ this._drawOuterBorder({
7322
+ ctx,
7323
+ startX,
7324
+ startY,
7325
+ width: tableWidth,
7326
+ height: tableHeight,
7327
+ isDrawFullBorder: isExternalBorderType
7328
+ });
7329
+ if (!isExternalBorderType) {
7330
+ for (let t = 0; t < trList.length; t++) {
7331
+ const tr = trList[t];
7332
+ for (let d = 0; d < tr.tdList.length; d++) {
7333
+ const td = tr.tdList[d];
7334
+ const width = td.width * scale;
7335
+ const height = td.height * scale;
7336
+ const x = Math.round(td.x * scale + startX + width);
7337
+ const y = Math.round(td.y * scale + startY);
7338
+ ctx.translate(0.5, 0.5);
7339
+ ctx.beginPath();
7340
+ ctx.moveTo(x, y);
7341
+ ctx.lineTo(x, y + height);
7342
+ ctx.lineTo(x - width, y + height);
7343
+ ctx.stroke();
7344
+ ctx.translate(-0.5, -0.5);
7345
+ }
7346
+ }
7347
+ }
7348
+ ctx.restore();
7349
+ }
7350
+ _drawBackgroundColor(ctx, element, startX, startY) {
7351
+ const { trList } = element;
7352
+ if (!trList)
7353
+ return;
7354
+ const { scale } = this.options;
7355
+ for (let t = 0; t < trList.length; t++) {
7356
+ const tr = trList[t];
7357
+ for (let d = 0; d < tr.tdList.length; d++) {
7358
+ const td = tr.tdList[d];
7359
+ if (!td.backgroundColor)
7360
+ continue;
7361
+ ctx.save();
7362
+ const width = td.width * scale;
7363
+ const height = td.height * scale;
7364
+ const x = Math.round(td.x * scale + startX);
7365
+ const y = Math.round(td.y * scale + startY);
7366
+ ctx.fillStyle = td.backgroundColor;
7367
+ ctx.fillRect(x, y, width, height);
7368
+ ctx.restore();
7369
+ }
7370
+ }
7371
+ }
7210
7372
  computeRowColInfo(element) {
7211
7373
  const { colgroup, trList } = element;
7212
7374
  if (!colgroup || !trList)
@@ -7325,42 +7487,8 @@ class TableParticle {
7325
7487
  ctx.restore();
7326
7488
  }
7327
7489
  render(ctx, element, startX, startY) {
7328
- const { colgroup, trList, borderType } = element;
7329
- if (!colgroup || !trList || borderType === TableBorder.EMPTY)
7330
- return;
7331
- const { scale } = this.options;
7332
- const tableWidth = element.width * scale;
7333
- const tableHeight = element.height * scale;
7334
- const isExternalBorderType = borderType === TableBorder.EXTERNAL;
7335
- ctx.save();
7336
- this._drawBorder({
7337
- ctx,
7338
- startX,
7339
- startY,
7340
- width: tableWidth,
7341
- height: tableHeight,
7342
- isDrawFullBorder: isExternalBorderType
7343
- });
7344
- if (!isExternalBorderType) {
7345
- for (let t = 0; t < trList.length; t++) {
7346
- const tr = trList[t];
7347
- for (let d = 0; d < tr.tdList.length; d++) {
7348
- const td = tr.tdList[d];
7349
- const width = td.width * scale;
7350
- const height = td.height * scale;
7351
- const x = Math.round(td.x * scale + startX + width);
7352
- const y = Math.round(td.y * scale + startY);
7353
- ctx.translate(0.5, 0.5);
7354
- ctx.beginPath();
7355
- ctx.moveTo(x, y);
7356
- ctx.lineTo(x, y + height);
7357
- ctx.lineTo(x - width, y + height);
7358
- ctx.stroke();
7359
- ctx.translate(-0.5, -0.5);
7360
- }
7361
- }
7362
- }
7363
- ctx.restore();
7490
+ this._drawBackgroundColor(ctx, element, startX, startY);
7491
+ this._drawBorder(ctx, element, startX, startY);
7364
7492
  }
7365
7493
  }
7366
7494
  var TableOrder;
@@ -8559,7 +8687,17 @@ class CheckboxParticle {
8559
8687
  ctx.restore();
8560
8688
  }
8561
8689
  }
8562
- const encodedJs = "KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBjOyhmdW5jdGlvbih0KXt0LlRFWFQ9InRleHQiLHQuVEFCTEU9InRhYmxlIix0LkhZUEVSTElOSz0iaHlwZXJsaW5rIix0LkNPTlRST0w9ImNvbnRyb2wifSkoY3x8KGM9e30pKTt2YXIgdTsoZnVuY3Rpb24odCl7dC5WQUxVRT0idmFsdWUifSkodXx8KHU9e30pKTtjb25zdCBoPSJcdTIwMEIiLGc9YApgO2Z1bmN0aW9uIHAodCl7bGV0IGw9IiIsbz0wO2Zvcig7bzx0Lmxlbmd0aDspe2NvbnN0IG49dFtvXTtpZihuLnR5cGU9PT1jLlRBQkxFKXtpZihuLnRyTGlzdClmb3IobGV0IGk9MDtpPG4udHJMaXN0Lmxlbmd0aDtpKyspe2NvbnN0IHM9bi50ckxpc3RbaV07Zm9yKGxldCBlPTA7ZTxzLnRkTGlzdC5sZW5ndGg7ZSsrKXtjb25zdCByPXMudGRMaXN0W2VdO2wrPXAoci52YWx1ZSl9fX1lbHNlIGlmKG4udHlwZT09PWMuSFlQRVJMSU5LKXtjb25zdCBpPW4uaHlwZXJsaW5rSWQscz1bXTtmb3IoO288dC5sZW5ndGg7KXtjb25zdCBlPXRbb107aWYoaSE9PWUuaHlwZXJsaW5rSWQpe28tLTticmVha31kZWxldGUgZS50eXBlLHMucHVzaChlKSxvKyt9bCs9cChzKX1lbHNlIGlmKG4udHlwZT09PWMuQ09OVFJPTCl7Y29uc3QgaT1uLmNvbnRyb2xJZCxzPVtdO2Zvcig7bzx0Lmxlbmd0aDspe2NvbnN0IGU9dFtvXTt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obCkucmVwbGFjZShuZXcgUmVnRXhwKGBeJHtofWApLCIiKS5yZXBsYWNlKG5ldyBSZWdFeHAoaCwiZyIpLGcpLGk9ZChuKTtwb3N0TWVzc2FnZShpLmxlbmd0aCl9fSkoKTt9KSgpOwo=";
8691
+ const blob$1 = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs$1)], { type: "text/javascript;charset=utf-8" });
8692
+ function WorkerWrapper$1() {
8693
+ const objURL = blob$1 && (window.URL || window.webkitURL).createObjectURL(blob$1);
8694
+ try {
8695
+ return objURL ? new Worker(objURL) : new Worker("data:application/javascript;base64," + encodedJs$1, { type: "module" });
8696
+ } finally {
8697
+ objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
8698
+ }
8699
+ }
8700
+ const encodedJs = "KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBnOyhmdW5jdGlvbihlKXtlLlRJVExFPSJ0aXRsZSJ9KShnfHwoZz17fSkpO3ZhciBvOyhmdW5jdGlvbihlKXtlLkZJUlNUPSJmaXJzdCIsZS5TRUNPTkQ9InNlY29uZCIsZS5USElSRD0idGhpcmQiLGUuRk9VUlRIPSJmb3VydGgiLGUuRklGVEg9ImZpZnRoIixlLlNJWFRIPSJzaXh0aCJ9KShvfHwobz17fSkpO2NvbnN0IHU9e1tvLkZJUlNUXToxLFtvLlNFQ09ORF06Mixbby5USElSRF06Myxbby5GT1VSVEhdOjQsW28uRklGVEhdOjUsW28uU0lYVEhdOjZ9LEk9Ilx1MjAwQiI7ZnVuY3Rpb24gZihlKXtjb25zdCBhPVtdO2xldCBzPTA7Zm9yKDtzPGUubGVuZ3RoOyl7Y29uc3QgdD1lW3NdO2lmKHQudGl0bGVJZCl7Y29uc3Qgbj10LnRpdGxlSWQsbD10LmxldmVsLGM9e3R5cGU6Zy5USVRMRSx2YWx1ZToiIixsZXZlbDpsLHRpdGxlSWQ6bn0saT1bXTtmb3IoO3M8ZS5sZW5ndGg7KXtjb25zdCB2PWVbc107aWYobiE9PXYudGl0bGVJZCl7cy0tO2JyZWFrfWkucHVzaCh2KSxzKyt9Yy52YWx1ZT1pLm1hcCh2PT52LnZhbHVlKS5qb2luKCIiKS5yZXBsYWNlKG5ldyBSZWdFeHAoSSwiZyIpLCIiKSxhLnB1c2goYyl9cysrfWlmKCFhLmxlbmd0aClyZXR1cm4gbnVsbDtjb25zdCBoPSh0LG4pPT57Y29uc3QgbD1uLnN1YkNhdGFsb2dbbi5zdWJDYXRhbG9nLmxlbmd0aC0xXSxjPXVbbD09bnVsbD92b2lkIDA6bC5sZXZlbF0saT11W3QubGV2ZWxdO2wmJmk+Yz9oKHQsbCk6bi5zdWJDYXRhbG9nLnB1c2goe2lkOnQudGl0bGVJZCxuYW1lOnQudmFsdWUsbGV2ZWw6dC5sZXZlbCxzdWJDYXRhbG9nOltdfSl9LHI9W107Zm9yKGxldCB0PTA7dDxhLmxlbmd0aDt0Kyspe2NvbnN0IG49YVt0XSxsPXJbci5sZW5ndGgtMV0sYz11W2w9PW51bGw/dm9pZCAwOmwubGV2ZWxdLGk9dVtuLmxldmVsXTtsJiZpPmM/aChuLGwpOnIucHVzaCh7aWQ6bi50aXRsZUlkLG5hbWU6bi52YWx1ZSxsZXZlbDpuLmxldmVsLHN1YkNhdGFsb2c6W119KX1yZXR1cm4gcn1vbm1lc3NhZ2U9ZT0+e2NvbnN0IGE9ZS5kYXRhLHM9ZihhKTtwb3N0TWVzc2FnZShzKX19KSgpO30pKCk7Cg==";
8563
8701
  const blob = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs)], { type: "text/javascript;charset=utf-8" });
8564
8702
  function WorkerWrapper() {
8565
8703
  const objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
@@ -8573,8 +8711,10 @@ class WorkerManager {
8573
8711
  constructor(draw) {
8574
8712
  __publicField(this, "draw");
8575
8713
  __publicField(this, "wordCountWorker");
8714
+ __publicField(this, "catalogWorker");
8576
8715
  this.draw = draw;
8577
- this.wordCountWorker = new WorkerWrapper();
8716
+ this.wordCountWorker = new WorkerWrapper$1();
8717
+ this.catalogWorker = new WorkerWrapper();
8578
8718
  }
8579
8719
  getWordCount() {
8580
8720
  return new Promise((resolve, reject) => {
@@ -8588,6 +8728,18 @@ class WorkerManager {
8588
8728
  this.wordCountWorker.postMessage(elementList);
8589
8729
  });
8590
8730
  }
8731
+ getCatalog() {
8732
+ return new Promise((resolve, reject) => {
8733
+ this.catalogWorker.onmessage = (evt) => {
8734
+ resolve(evt.data);
8735
+ };
8736
+ this.catalogWorker.onerror = (evt) => {
8737
+ reject(evt);
8738
+ };
8739
+ const elementList = this.draw.getOriginalMainElementList();
8740
+ this.catalogWorker.postMessage(elementList);
8741
+ });
8742
+ }
8591
8743
  }
8592
8744
  class Previewer {
8593
8745
  constructor(draw) {
@@ -10064,9 +10216,7 @@ class ListParticle {
10064
10216
  return;
10065
10217
  let text = "";
10066
10218
  if (startElement.listType === ListType.UL) {
10067
- if (startElement.listStyle) {
10068
- text = ulStyleMapping[startElement.listStyle] || ulStyleMapping[UlStyle.DISC];
10069
- }
10219
+ text = ulStyleMapping[startElement.listStyle] || ulStyleMapping[UlStyle.DISC];
10070
10220
  } else {
10071
10221
  text = `${listIndex + 1}${KeyMap.PERIOD}`;
10072
10222
  }
@@ -10464,6 +10614,9 @@ class Draw {
10464
10614
  getTableTool() {
10465
10615
  return this.tableTool;
10466
10616
  }
10617
+ getTableParticle() {
10618
+ return this.tableParticle;
10619
+ }
10467
10620
  getHeader() {
10468
10621
  return this.header;
10469
10622
  }
@@ -11372,6 +11525,7 @@ const _Command = class {
11372
11525
  _Command.cancelMergeTableCell = adapt.cancelMergeTableCell.bind(adapt);
11373
11526
  _Command.tableTdVerticalAlign = adapt.tableTdVerticalAlign.bind(adapt);
11374
11527
  _Command.tableBorderType = adapt.tableBorderType.bind(adapt);
11528
+ _Command.tableTdBackgroundColor = adapt.tableTdBackgroundColor.bind(adapt);
11375
11529
  _Command.image = adapt.image.bind(adapt);
11376
11530
  _Command.hyperlink = adapt.hyperlink.bind(adapt);
11377
11531
  _Command.deleteHyperlink = adapt.deleteHyperlink.bind(adapt);
@@ -11405,6 +11559,8 @@ const _Command = class {
11405
11559
  _Command.insertElementList = adapt.insertElementList.bind(adapt);
11406
11560
  _Command.removeControl = adapt.removeControl.bind(adapt);
11407
11561
  _Command.setLocale = adapt.setLocale.bind(adapt);
11562
+ _Command.getCatalog = adapt.getCatalog.bind(adapt);
11563
+ _Command.locationCatalog = adapt.locationCatalog.bind(adapt);
11408
11564
  }
11409
11565
  executeMode(payload) {
11410
11566
  return _Command.mode(payload);
@@ -11535,6 +11691,9 @@ const _Command = class {
11535
11691
  executeTableBorderType(payload) {
11536
11692
  return _Command.tableBorderType(payload);
11537
11693
  }
11694
+ executeTableTdBackgroundColor(payload) {
11695
+ return _Command.tableTdBackgroundColor(payload);
11696
+ }
11538
11697
  executeHyperlink(payload) {
11539
11698
  return _Command.hyperlink(payload);
11540
11699
  }
@@ -11634,6 +11793,12 @@ const _Command = class {
11634
11793
  executeSetLocale(payload) {
11635
11794
  return _Command.setLocale(payload);
11636
11795
  }
11796
+ getCatalog() {
11797
+ return _Command.getCatalog();
11798
+ }
11799
+ executeLocationCatalog(titleId) {
11800
+ return _Command.locationCatalog(titleId);
11801
+ }
11637
11802
  };
11638
11803
  let Command = _Command;
11639
11804
  __publicField(Command, "mode");
@@ -11679,6 +11844,7 @@ __publicField(Command, "mergeTableCell");
11679
11844
  __publicField(Command, "cancelMergeTableCell");
11680
11845
  __publicField(Command, "tableTdVerticalAlign");
11681
11846
  __publicField(Command, "tableBorderType");
11847
+ __publicField(Command, "tableTdBackgroundColor");
11682
11848
  __publicField(Command, "image");
11683
11849
  __publicField(Command, "hyperlink");
11684
11850
  __publicField(Command, "deleteHyperlink");
@@ -11712,6 +11878,8 @@ __publicField(Command, "setPaperMargin");
11712
11878
  __publicField(Command, "insertElementList");
11713
11879
  __publicField(Command, "removeControl");
11714
11880
  __publicField(Command, "setLocale");
11881
+ __publicField(Command, "getCatalog");
11882
+ __publicField(Command, "locationCatalog");
11715
11883
  const defaultWatermarkOption = {
11716
11884
  data: "",
11717
11885
  color: "#AEB5C0",
@@ -12844,6 +13012,26 @@ class CommandAdapt {
12844
13012
  curIndex: endIndex
12845
13013
  });
12846
13014
  }
13015
+ tableTdBackgroundColor(payload) {
13016
+ const isReadonly = this.draw.isReadonly();
13017
+ if (isReadonly)
13018
+ return;
13019
+ const rowCol = this.draw.getTableParticle().getRangeRowCol();
13020
+ if (!rowCol)
13021
+ return;
13022
+ for (let r = 0; r < rowCol.length; r++) {
13023
+ const row = rowCol[r];
13024
+ for (let c = 0; c < row.length; c++) {
13025
+ const col = row[c];
13026
+ col.backgroundColor = payload;
13027
+ }
13028
+ }
13029
+ const { endIndex } = this.range.getRange();
13030
+ this.range.setRange(endIndex, endIndex);
13031
+ this.draw.render({
13032
+ isCompute: false
13033
+ });
13034
+ }
12847
13035
  hyperlink(payload) {
12848
13036
  const isReadonly = this.draw.isReadonly();
12849
13037
  if (isReadonly)
@@ -13309,6 +13497,29 @@ class CommandAdapt {
13309
13497
  setLocale(payload) {
13310
13498
  this.i18n.setLocale(payload);
13311
13499
  }
13500
+ getCatalog() {
13501
+ return this.workerManager.getCatalog();
13502
+ }
13503
+ locationCatalog(titleId) {
13504
+ var _a;
13505
+ const elementList = this.draw.getMainElementList();
13506
+ let newIndex = -1;
13507
+ for (let e = 0; e < elementList.length; e++) {
13508
+ const element = elementList[e];
13509
+ if (element.titleId === titleId && ((_a = elementList[e + 1]) == null ? void 0 : _a.titleId) !== titleId) {
13510
+ newIndex = e;
13511
+ break;
13512
+ }
13513
+ }
13514
+ if (!~newIndex)
13515
+ return;
13516
+ this.range.setRange(newIndex, newIndex);
13517
+ this.draw.render({
13518
+ curIndex: newIndex,
13519
+ isCompute: false,
13520
+ isSubmitHistory: false
13521
+ });
13522
+ }
13312
13523
  }
13313
13524
  class Listener {
13314
13525
  constructor() {