@hufe921/canvas-editor 0.9.34 → 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.
- package/CHANGELOG.md +26 -0
- package/README.md +5 -5
- package/dist/canvas-editor.es.js +204 -70
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +13 -13
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +2 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +1 -0
- package/dist/src/editor/core/draw/Draw.d.ts +2 -0
- package/dist/src/editor/core/draw/particle/table/TableParticle.d.ts +5 -0
- package/dist/src/editor/interface/PageNumber.d.ts +2 -0
- package/dist/src/editor/interface/table/Td.d.ts +1 -0
- package/dist/src/editor/utils/clipboard.d.ts +1 -0
- package/dist/src/editor/utils/element.d.ts +4 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## [0.9.35](https://github.com/Hufe921/canvas-editor/compare/v0.9.34...v0.9.35) (2023-05-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Chores
|
|
5
|
+
|
|
6
|
+
* add CRDT CSpell word ([ef31552](https://github.com/Hufe921/canvas-editor/commit/ef315526be244c210b2a2a220dd3bed986660d75))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Documentation
|
|
10
|
+
|
|
11
|
+
* starting page number option ([618cb47](https://github.com/Hufe921/canvas-editor/commit/618cb47f77f2aed05d4ca72135ea5312b6d26b00))
|
|
12
|
+
* table cell background color ([9225bef](https://github.com/Hufe921/canvas-editor/commit/9225bef99192d8c4848536d973bb2467ea205f27))
|
|
13
|
+
* update next features ([c6ea0a6](https://github.com/Hufe921/canvas-editor/commit/c6ea0a655c997645cda6df7ced4377707973680f))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* copy and paste sub and sup elements ([a500402](https://github.com/Hufe921/canvas-editor/commit/a500402dd401c6eac55222a366f5fc596c27d7c3))
|
|
19
|
+
* copy and paste table cell background color ([c97c6ef](https://github.com/Hufe921/canvas-editor/commit/c97c6eff4047a91e68079cc9b228f41e02bef1ab))
|
|
20
|
+
* optimize paste title ([bf52e25](https://github.com/Hufe921/canvas-editor/commit/bf52e2588b3af426382334d45d16d1a33510fde1))
|
|
21
|
+
* starting page number option ([bfc61a8](https://github.com/Hufe921/canvas-editor/commit/bfc61a8a06b6c2c09fd968767f2a6ccbe280fe55))
|
|
22
|
+
* table cell background color ([dbcab3b](https://github.com/Hufe921/canvas-editor/commit/dbcab3b48557f5a4ba77b9e6ec40b7ac8d36cc40))
|
|
23
|
+
* unordered list default style ([c8b2a7e](https://github.com/Hufe921/canvas-editor/commit/c8b2a7e59fdd97ac268b0a38e80bac98dfd797ce))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
1
27
|
## [0.9.34](https://github.com/Hufe921/canvas-editor/compare/v0.9.33...v0.9.34) (2023-05-16)
|
|
2
28
|
|
|
3
29
|
|
package/README.md
CHANGED
|
@@ -28,11 +28,11 @@ new Editor(document.querySelector(".canvas-editor"), [
|
|
|
28
28
|
|
|
29
29
|
## next features
|
|
30
30
|
|
|
31
|
-
1. improve
|
|
32
|
-
2. improve
|
|
33
|
-
3.
|
|
34
|
-
4.
|
|
35
|
-
5.
|
|
31
|
+
1. improve list and title
|
|
32
|
+
2. improve performance
|
|
33
|
+
3. control rules
|
|
34
|
+
4. table paging
|
|
35
|
+
5. [CRDT](https://github.com/Hufe921/canvas-editor/tree/feature/CRDT)
|
|
36
36
|
|
|
37
37
|
## snapshot
|
|
38
38
|
|
package/dist/canvas-editor.es.js
CHANGED
|
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23
23
|
return value;
|
|
24
24
|
};
|
|
25
25
|
var index = "";
|
|
26
|
-
const version = "0.9.
|
|
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
|
-
|
|
3436
|
-
|
|
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
|
-
|
|
3931
|
-
|
|
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
|
|
4079
|
-
|
|
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
|
});
|
|
@@ -7007,7 +7045,9 @@ const defaultPageNumberOption = {
|
|
|
7007
7045
|
rowFlex: RowFlex.CENTER,
|
|
7008
7046
|
format: FORMAT_PLACEHOLDER.PAGE_NO,
|
|
7009
7047
|
numberType: NumberType.ARABIC,
|
|
7010
|
-
disabled: false
|
|
7048
|
+
disabled: false,
|
|
7049
|
+
startPageNo: 1,
|
|
7050
|
+
fromPageNo: 0
|
|
7011
7051
|
};
|
|
7012
7052
|
class PageNumber {
|
|
7013
7053
|
constructor(draw) {
|
|
@@ -7017,17 +7057,19 @@ class PageNumber {
|
|
|
7017
7057
|
this.options = draw.getOptions();
|
|
7018
7058
|
}
|
|
7019
7059
|
render(ctx, pageNo) {
|
|
7020
|
-
const { pageNumber: { size, font, color, rowFlex, numberType, format
|
|
7060
|
+
const { scale, pageMode, pageNumber: { size, font, color, rowFlex, numberType, format, startPageNo, fromPageNo } } = this.options;
|
|
7061
|
+
if (pageNo < fromPageNo)
|
|
7062
|
+
return;
|
|
7021
7063
|
let text = format;
|
|
7022
7064
|
const pageNoReg = new RegExp(FORMAT_PLACEHOLDER.PAGE_NO);
|
|
7023
7065
|
if (pageNoReg.test(text)) {
|
|
7024
|
-
const realPageNo = pageNo +
|
|
7066
|
+
const realPageNo = pageNo + startPageNo - fromPageNo;
|
|
7025
7067
|
const pageNoText = numberType === NumberType.CHINESE ? convertNumberToChinese(realPageNo) : `${realPageNo}`;
|
|
7026
7068
|
text = text.replace(pageNoReg, pageNoText);
|
|
7027
7069
|
}
|
|
7028
7070
|
const pageCountReg = new RegExp(FORMAT_PLACEHOLDER.PAGE_COUNT);
|
|
7029
7071
|
if (pageCountReg.test(text)) {
|
|
7030
|
-
const pageCount = this.draw.getPageCount();
|
|
7072
|
+
const pageCount = this.draw.getPageCount() - fromPageNo;
|
|
7031
7073
|
const pageCountText = numberType === NumberType.CHINESE ? convertNumberToChinese(pageCount) : `${pageCount}`;
|
|
7032
7074
|
text = text.replace(pageCountReg, pageCountText);
|
|
7033
7075
|
}
|
|
@@ -7190,8 +7232,10 @@ class SelectionObserver {
|
|
|
7190
7232
|
}
|
|
7191
7233
|
class TableParticle {
|
|
7192
7234
|
constructor(draw) {
|
|
7235
|
+
__publicField(this, "draw");
|
|
7193
7236
|
__publicField(this, "range");
|
|
7194
7237
|
__publicField(this, "options");
|
|
7238
|
+
this.draw = draw;
|
|
7195
7239
|
this.range = draw.getRange();
|
|
7196
7240
|
this.options = draw.getOptions();
|
|
7197
7241
|
}
|
|
@@ -7211,7 +7255,45 @@ class TableParticle {
|
|
|
7211
7255
|
}
|
|
7212
7256
|
return trList;
|
|
7213
7257
|
}
|
|
7214
|
-
|
|
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) {
|
|
7215
7297
|
const { ctx, startX, startY, width, height, isDrawFullBorder } = payload;
|
|
7216
7298
|
ctx.beginPath();
|
|
7217
7299
|
const x = Math.round(startX);
|
|
@@ -7227,6 +7309,66 @@ class TableParticle {
|
|
|
7227
7309
|
ctx.stroke();
|
|
7228
7310
|
ctx.translate(-0.5, -0.5);
|
|
7229
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
|
+
}
|
|
7230
7372
|
computeRowColInfo(element) {
|
|
7231
7373
|
const { colgroup, trList } = element;
|
|
7232
7374
|
if (!colgroup || !trList)
|
|
@@ -7345,42 +7487,8 @@ class TableParticle {
|
|
|
7345
7487
|
ctx.restore();
|
|
7346
7488
|
}
|
|
7347
7489
|
render(ctx, element, startX, startY) {
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
return;
|
|
7351
|
-
const { scale } = this.options;
|
|
7352
|
-
const tableWidth = element.width * scale;
|
|
7353
|
-
const tableHeight = element.height * scale;
|
|
7354
|
-
const isExternalBorderType = borderType === TableBorder.EXTERNAL;
|
|
7355
|
-
ctx.save();
|
|
7356
|
-
this._drawBorder({
|
|
7357
|
-
ctx,
|
|
7358
|
-
startX,
|
|
7359
|
-
startY,
|
|
7360
|
-
width: tableWidth,
|
|
7361
|
-
height: tableHeight,
|
|
7362
|
-
isDrawFullBorder: isExternalBorderType
|
|
7363
|
-
});
|
|
7364
|
-
if (!isExternalBorderType) {
|
|
7365
|
-
for (let t = 0; t < trList.length; t++) {
|
|
7366
|
-
const tr = trList[t];
|
|
7367
|
-
for (let d = 0; d < tr.tdList.length; d++) {
|
|
7368
|
-
const td = tr.tdList[d];
|
|
7369
|
-
const width = td.width * scale;
|
|
7370
|
-
const height = td.height * scale;
|
|
7371
|
-
const x = Math.round(td.x * scale + startX + width);
|
|
7372
|
-
const y = Math.round(td.y * scale + startY);
|
|
7373
|
-
ctx.translate(0.5, 0.5);
|
|
7374
|
-
ctx.beginPath();
|
|
7375
|
-
ctx.moveTo(x, y);
|
|
7376
|
-
ctx.lineTo(x, y + height);
|
|
7377
|
-
ctx.lineTo(x - width, y + height);
|
|
7378
|
-
ctx.stroke();
|
|
7379
|
-
ctx.translate(-0.5, -0.5);
|
|
7380
|
-
}
|
|
7381
|
-
}
|
|
7382
|
-
}
|
|
7383
|
-
ctx.restore();
|
|
7490
|
+
this._drawBackgroundColor(ctx, element, startX, startY);
|
|
7491
|
+
this._drawBorder(ctx, element, startX, startY);
|
|
7384
7492
|
}
|
|
7385
7493
|
}
|
|
7386
7494
|
var TableOrder;
|
|
@@ -10108,9 +10216,7 @@ class ListParticle {
|
|
|
10108
10216
|
return;
|
|
10109
10217
|
let text = "";
|
|
10110
10218
|
if (startElement.listType === ListType.UL) {
|
|
10111
|
-
|
|
10112
|
-
text = ulStyleMapping[startElement.listStyle] || ulStyleMapping[UlStyle.DISC];
|
|
10113
|
-
}
|
|
10219
|
+
text = ulStyleMapping[startElement.listStyle] || ulStyleMapping[UlStyle.DISC];
|
|
10114
10220
|
} else {
|
|
10115
10221
|
text = `${listIndex + 1}${KeyMap.PERIOD}`;
|
|
10116
10222
|
}
|
|
@@ -10508,6 +10614,9 @@ class Draw {
|
|
|
10508
10614
|
getTableTool() {
|
|
10509
10615
|
return this.tableTool;
|
|
10510
10616
|
}
|
|
10617
|
+
getTableParticle() {
|
|
10618
|
+
return this.tableParticle;
|
|
10619
|
+
}
|
|
10511
10620
|
getHeader() {
|
|
10512
10621
|
return this.header;
|
|
10513
10622
|
}
|
|
@@ -11416,6 +11525,7 @@ const _Command = class {
|
|
|
11416
11525
|
_Command.cancelMergeTableCell = adapt.cancelMergeTableCell.bind(adapt);
|
|
11417
11526
|
_Command.tableTdVerticalAlign = adapt.tableTdVerticalAlign.bind(adapt);
|
|
11418
11527
|
_Command.tableBorderType = adapt.tableBorderType.bind(adapt);
|
|
11528
|
+
_Command.tableTdBackgroundColor = adapt.tableTdBackgroundColor.bind(adapt);
|
|
11419
11529
|
_Command.image = adapt.image.bind(adapt);
|
|
11420
11530
|
_Command.hyperlink = adapt.hyperlink.bind(adapt);
|
|
11421
11531
|
_Command.deleteHyperlink = adapt.deleteHyperlink.bind(adapt);
|
|
@@ -11581,6 +11691,9 @@ const _Command = class {
|
|
|
11581
11691
|
executeTableBorderType(payload) {
|
|
11582
11692
|
return _Command.tableBorderType(payload);
|
|
11583
11693
|
}
|
|
11694
|
+
executeTableTdBackgroundColor(payload) {
|
|
11695
|
+
return _Command.tableTdBackgroundColor(payload);
|
|
11696
|
+
}
|
|
11584
11697
|
executeHyperlink(payload) {
|
|
11585
11698
|
return _Command.hyperlink(payload);
|
|
11586
11699
|
}
|
|
@@ -11731,6 +11844,7 @@ __publicField(Command, "mergeTableCell");
|
|
|
11731
11844
|
__publicField(Command, "cancelMergeTableCell");
|
|
11732
11845
|
__publicField(Command, "tableTdVerticalAlign");
|
|
11733
11846
|
__publicField(Command, "tableBorderType");
|
|
11847
|
+
__publicField(Command, "tableTdBackgroundColor");
|
|
11734
11848
|
__publicField(Command, "image");
|
|
11735
11849
|
__publicField(Command, "hyperlink");
|
|
11736
11850
|
__publicField(Command, "deleteHyperlink");
|
|
@@ -12898,6 +13012,26 @@ class CommandAdapt {
|
|
|
12898
13012
|
curIndex: endIndex
|
|
12899
13013
|
});
|
|
12900
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
|
+
}
|
|
12901
13035
|
hyperlink(payload) {
|
|
12902
13036
|
const isReadonly = this.draw.isReadonly();
|
|
12903
13037
|
if (isReadonly)
|