@hailin-zheng/editor-core 2.0.10 → 2.0.11
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 +71 -19
- package/index-cjs.js.map +1 -1
- package/index.js +71 -19
- package/index.js.map +1 -1
- package/med_editor/framework/element-util.d.ts +2 -0
- package/med_editor/framework/impl/table/table-cell-impl.d.ts +5 -0
- package/package.json +1 -1
package/index-cjs.js
CHANGED
@@ -4433,6 +4433,27 @@ class TableCellRenderObject extends InlineMuiltBlockLineRenderObject {
|
|
4433
4433
|
}]);
|
4434
4434
|
}
|
4435
4435
|
}
|
4436
|
+
/**
|
4437
|
+
* 绘制对角线
|
4438
|
+
* @private
|
4439
|
+
*/
|
4440
|
+
renderDiagonalHTML(event, diagonal, children) {
|
4441
|
+
if (!diagonal) {
|
4442
|
+
return;
|
4443
|
+
}
|
4444
|
+
if (diagonal === 'all') {
|
4445
|
+
this.renderDiagonalHTML(event, 'main', children);
|
4446
|
+
this.renderDiagonalHTML(event, 'sub', children);
|
4447
|
+
return;
|
4448
|
+
}
|
4449
|
+
if (diagonal && this.rect.width && this.rect.height) {
|
4450
|
+
let diagonalStartX = diagonal === 'main' ? 0 : this.rect.width;
|
4451
|
+
let diagonalStartY = 0;
|
4452
|
+
let diagonalEndX = diagonal === 'main' ? this.rect.width : 0;
|
4453
|
+
let diagonalEndY = this.rect.height;
|
4454
|
+
children.push(ElementUtil.createLine(diagonalStartX, diagonalStartY, diagonalEndX, diagonalEndY, '#000', 1));
|
4455
|
+
}
|
4456
|
+
}
|
4436
4457
|
clone() {
|
4437
4458
|
const cloneRender = new TableCellRenderObject(this.element);
|
4438
4459
|
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
@@ -4449,27 +4470,16 @@ class TableCellRenderObject extends InlineMuiltBlockLineRenderObject {
|
|
4449
4470
|
const clipId = `CP_${counter}`;
|
4450
4471
|
t.children = [...CommonUtil.toArray(event.getChildNodes(this)), ElementUtil.createClipPath(clipId, this.rect.width, this.rect.height)];
|
4451
4472
|
if (this.element.props.backgroundColor) {
|
4452
|
-
//t.data.attrs.fill = this.element.props.backgroundColor;
|
4453
4473
|
t.children.splice(0, 0, this.createBgRect());
|
4454
4474
|
}
|
4455
4475
|
t.data.attrs['clip-path'] = `url(#${clipId})`;
|
4476
|
+
this.renderDiagonalHTML(event, this.element.props.diagonal, t.children);
|
4456
4477
|
t.isCompleted = true;
|
4457
4478
|
return t;
|
4458
4479
|
}
|
4459
4480
|
createBgRect() {
|
4460
4481
|
if (this.element.props.backgroundColor) {
|
4461
|
-
return
|
4462
|
-
sel: 'rect',
|
4463
|
-
data: {
|
4464
|
-
ns: 'http://www.w3.org/2000/svg',
|
4465
|
-
attrs: {
|
4466
|
-
fill: this.element.props.backgroundColor,
|
4467
|
-
stroke: 'none',
|
4468
|
-
width: this.rect.width,
|
4469
|
-
height: this.rect.height,
|
4470
|
-
}
|
4471
|
-
}
|
4472
|
-
};
|
4482
|
+
return ElementUtil.getFillSvgRect(0, 0, this.rect.width, this.rect.height, this.element.props.backgroundColor);
|
4473
4483
|
}
|
4474
4484
|
return null;
|
4475
4485
|
}
|
@@ -8608,6 +8618,26 @@ class ElementUtil {
|
|
8608
8618
|
}
|
8609
8619
|
};
|
8610
8620
|
}
|
8621
|
+
static createLine(x1, y1, x2, y2, stroke, width) {
|
8622
|
+
return {
|
8623
|
+
sel: 'line',
|
8624
|
+
data: {
|
8625
|
+
ns: "http://www.w3.org/2000/svg",
|
8626
|
+
attrs: {
|
8627
|
+
x1,
|
8628
|
+
y1,
|
8629
|
+
x2,
|
8630
|
+
y2,
|
8631
|
+
stroke,
|
8632
|
+
'stroke-width': width,
|
8633
|
+
fill: 'none'
|
8634
|
+
}
|
8635
|
+
}
|
8636
|
+
};
|
8637
|
+
}
|
8638
|
+
static getRectPath(x, y, width, height) {
|
8639
|
+
return `M${x} ${y} L${x + width} ${y} L${x + width} ${y + height} L${x} ${y + height} Z`;
|
8640
|
+
}
|
8611
8641
|
static getFillSvgPath(pathPoints, fill, width) {
|
8612
8642
|
const d = typeof pathPoints === 'string' ? pathPoints : pathPoints.map((p, i) => (i === 0 ? 'M' : 'L') + `${p.x} ${p.y}`).join(' ');
|
8613
8643
|
return {
|
@@ -11601,7 +11631,17 @@ class DocumentBodyPartRenderObject extends MuiltBlockLineRenderObject {
|
|
11601
11631
|
exportHTML(event) {
|
11602
11632
|
const t = super.exportHTML(event);
|
11603
11633
|
if (this.element.isFocused) {
|
11604
|
-
|
11634
|
+
// const bgRect=ElementUtil.getStrokeSvgPath(ElementUtil.getRectPath(0,0,this.rect.width,this.rect.height),'black',1);
|
11635
|
+
// bgRect.data.attrs.rx=5;
|
11636
|
+
// bgRect.data.attrs.ry=5;
|
11637
|
+
// bgRect.data.attrs['stroke-dasharray']='5,5';
|
11638
|
+
const bgRect = ElementUtil.getFillSvgRect(event.relativePagePos.x, event.relativePagePos.y, this.rect.width, this.rect.height, '#f0f0f0');
|
11639
|
+
bgRect.data.attrs['stroke'] = 'black';
|
11640
|
+
bgRect.data.attrs['stroke-width'] = 0.5;
|
11641
|
+
bgRect.data.attrs.rx = 5;
|
11642
|
+
bgRect.data.attrs.ry = 5;
|
11643
|
+
//t.children = [bgRect];
|
11644
|
+
event.highlights.push(bgRect);
|
11605
11645
|
}
|
11606
11646
|
return t;
|
11607
11647
|
}
|
@@ -18121,9 +18161,6 @@ class DocumentChange {
|
|
18121
18161
|
}
|
18122
18162
|
newInput(data) {
|
18123
18163
|
const { startControl, startOffset, collapsed, enableTrackChanges } = this.selectionState;
|
18124
|
-
if (!startControl) {
|
18125
|
-
debugger;
|
18126
|
-
}
|
18127
18164
|
if (!collapsed) {
|
18128
18165
|
this.onInputBySelectRange(data);
|
18129
18166
|
return;
|
@@ -19012,9 +19049,13 @@ class DocumentChange {
|
|
19012
19049
|
}
|
19013
19050
|
}
|
19014
19051
|
else {
|
19052
|
+
let insertTarget = targetElement;
|
19053
|
+
let insertTargetOffset = targetOffset;
|
19015
19054
|
for (let i = 0; i < destEleArray.length; i++) {
|
19016
19055
|
lastEle = destEleArray[i];
|
19017
|
-
|
19056
|
+
insertTarget.parent.addChild(lastEle, insertTarget.getIndex() + insertTargetOffset);
|
19057
|
+
insertTarget = lastEle;
|
19058
|
+
insertTargetOffset = 1;
|
19018
19059
|
}
|
19019
19060
|
}
|
19020
19061
|
return lastEle;
|
@@ -25704,6 +25745,7 @@ class EditorCalendarVNode {
|
|
25704
25745
|
this.currMonth.value = moment__default["default"](dataValue).month();
|
25705
25746
|
this.selectedDate.value = moment__default["default"](dataValue).format('YYYY-MM-DD');
|
25706
25747
|
this.currentDate = dataValue;
|
25748
|
+
this.currTime.value = moment__default["default"](dataValue).format('HH:mm:ss');
|
25707
25749
|
}
|
25708
25750
|
if (!this.currentDate) {
|
25709
25751
|
this.currentDate = moment__default["default"]().format('YYYY-MM-DD');
|
@@ -26917,7 +26959,7 @@ class DocEditor {
|
|
26917
26959
|
*/
|
26918
26960
|
getCurrentDataElement() {
|
26919
26961
|
const selectionState = this.documentSelection.selectionState;
|
26920
|
-
const { startControl, startOffset, collapsed } = selectionState;
|
26962
|
+
const { startControl, startOffset, collapsed, ancestorCommonControl } = selectionState;
|
26921
26963
|
if (startControl && collapsed) {
|
26922
26964
|
if (!ElementUtil.verifyHitable(startControl)) {
|
26923
26965
|
return null;
|
@@ -26930,6 +26972,10 @@ class DocEditor {
|
|
26930
26972
|
return null;
|
26931
26973
|
}
|
26932
26974
|
}
|
26975
|
+
else if (!collapsed && ancestorCommonControl) {
|
26976
|
+
const dataEle = ElementUtil.getParent(startControl, validateDataEle);
|
26977
|
+
return dataEle;
|
26978
|
+
}
|
26933
26979
|
return null;
|
26934
26980
|
}
|
26935
26981
|
/**
|
@@ -27641,6 +27687,9 @@ class DocEditor {
|
|
27641
27687
|
const editor = this;
|
27642
27688
|
return {
|
27643
27689
|
render() {
|
27690
|
+
if (editor.viewOptions.docMode === exports.DocMode.View) {
|
27691
|
+
return null;
|
27692
|
+
}
|
27644
27693
|
const dataEle = editor.getCurrentDataElement();
|
27645
27694
|
if (dataEle && dataEle instanceof DataElementList && dataEle.props.editable) {
|
27646
27695
|
const position = editor.getDataElementPosition(dataEle.startDecorate);
|
@@ -27751,6 +27800,9 @@ class DocEditor {
|
|
27751
27800
|
});
|
27752
27801
|
return {
|
27753
27802
|
render() {
|
27803
|
+
if (editor.viewOptions.docMode === exports.DocMode.View) {
|
27804
|
+
return null;
|
27805
|
+
}
|
27754
27806
|
const dataEle = editor.getCurrentDataElement();
|
27755
27807
|
if (dataEle && dataEle instanceof DataElementDate && dataEle.props.editable) {
|
27756
27808
|
const position = editor.getDataElementPosition(dataEle.startDecorate);
|