@hailin-zheng/editor-core 2.0.10 → 2.0.12
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 +76 -22
- package/index-cjs.js.map +1 -1
- package/index.js +76 -22
- 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.js
CHANGED
@@ -4403,6 +4403,27 @@ class TableCellRenderObject extends InlineMuiltBlockLineRenderObject {
|
|
4403
4403
|
}]);
|
4404
4404
|
}
|
4405
4405
|
}
|
4406
|
+
/**
|
4407
|
+
* 绘制对角线
|
4408
|
+
* @private
|
4409
|
+
*/
|
4410
|
+
renderDiagonalHTML(event, diagonal, children) {
|
4411
|
+
if (!diagonal) {
|
4412
|
+
return;
|
4413
|
+
}
|
4414
|
+
if (diagonal === 'all') {
|
4415
|
+
this.renderDiagonalHTML(event, 'main', children);
|
4416
|
+
this.renderDiagonalHTML(event, 'sub', children);
|
4417
|
+
return;
|
4418
|
+
}
|
4419
|
+
if (diagonal && this.rect.width && this.rect.height) {
|
4420
|
+
let diagonalStartX = diagonal === 'main' ? 0 : this.rect.width;
|
4421
|
+
let diagonalStartY = 0;
|
4422
|
+
let diagonalEndX = diagonal === 'main' ? this.rect.width : 0;
|
4423
|
+
let diagonalEndY = this.rect.height;
|
4424
|
+
children.push(ElementUtil.createLine(diagonalStartX, diagonalStartY, diagonalEndX, diagonalEndY, '#000', 1));
|
4425
|
+
}
|
4426
|
+
}
|
4406
4427
|
clone() {
|
4407
4428
|
const cloneRender = new TableCellRenderObject(this.element);
|
4408
4429
|
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
@@ -4419,27 +4440,16 @@ class TableCellRenderObject extends InlineMuiltBlockLineRenderObject {
|
|
4419
4440
|
const clipId = `CP_${counter}`;
|
4420
4441
|
t.children = [...CommonUtil.toArray(event.getChildNodes(this)), ElementUtil.createClipPath(clipId, this.rect.width, this.rect.height)];
|
4421
4442
|
if (this.element.props.backgroundColor) {
|
4422
|
-
//t.data.attrs.fill = this.element.props.backgroundColor;
|
4423
4443
|
t.children.splice(0, 0, this.createBgRect());
|
4424
4444
|
}
|
4425
4445
|
t.data.attrs['clip-path'] = `url(#${clipId})`;
|
4446
|
+
this.renderDiagonalHTML(event, this.element.props.diagonal, t.children);
|
4426
4447
|
t.isCompleted = true;
|
4427
4448
|
return t;
|
4428
4449
|
}
|
4429
4450
|
createBgRect() {
|
4430
4451
|
if (this.element.props.backgroundColor) {
|
4431
|
-
return
|
4432
|
-
sel: 'rect',
|
4433
|
-
data: {
|
4434
|
-
ns: 'http://www.w3.org/2000/svg',
|
4435
|
-
attrs: {
|
4436
|
-
fill: this.element.props.backgroundColor,
|
4437
|
-
stroke: 'none',
|
4438
|
-
width: this.rect.width,
|
4439
|
-
height: this.rect.height,
|
4440
|
-
}
|
4441
|
-
}
|
4442
|
-
};
|
4452
|
+
return ElementUtil.getFillSvgRect(0, 0, this.rect.width, this.rect.height, this.element.props.backgroundColor);
|
4443
4453
|
}
|
4444
4454
|
return null;
|
4445
4455
|
}
|
@@ -8578,6 +8588,26 @@ class ElementUtil {
|
|
8578
8588
|
}
|
8579
8589
|
};
|
8580
8590
|
}
|
8591
|
+
static createLine(x1, y1, x2, y2, stroke, width) {
|
8592
|
+
return {
|
8593
|
+
sel: 'line',
|
8594
|
+
data: {
|
8595
|
+
ns: "http://www.w3.org/2000/svg",
|
8596
|
+
attrs: {
|
8597
|
+
x1,
|
8598
|
+
y1,
|
8599
|
+
x2,
|
8600
|
+
y2,
|
8601
|
+
stroke,
|
8602
|
+
'stroke-width': width,
|
8603
|
+
fill: 'none'
|
8604
|
+
}
|
8605
|
+
}
|
8606
|
+
};
|
8607
|
+
}
|
8608
|
+
static getRectPath(x, y, width, height) {
|
8609
|
+
return `M${x} ${y} L${x + width} ${y} L${x + width} ${y + height} L${x} ${y + height} Z`;
|
8610
|
+
}
|
8581
8611
|
static getFillSvgPath(pathPoints, fill, width) {
|
8582
8612
|
const d = typeof pathPoints === 'string' ? pathPoints : pathPoints.map((p, i) => (i === 0 ? 'M' : 'L') + `${p.x} ${p.y}`).join(' ');
|
8583
8613
|
return {
|
@@ -11571,7 +11601,17 @@ class DocumentBodyPartRenderObject extends MuiltBlockLineRenderObject {
|
|
11571
11601
|
exportHTML(event) {
|
11572
11602
|
const t = super.exportHTML(event);
|
11573
11603
|
if (this.element.isFocused) {
|
11574
|
-
|
11604
|
+
// const bgRect=ElementUtil.getStrokeSvgPath(ElementUtil.getRectPath(0,0,this.rect.width,this.rect.height),'black',1);
|
11605
|
+
// bgRect.data.attrs.rx=5;
|
11606
|
+
// bgRect.data.attrs.ry=5;
|
11607
|
+
// bgRect.data.attrs['stroke-dasharray']='5,5';
|
11608
|
+
const bgRect = ElementUtil.getFillSvgRect(event.relativePagePos.x, event.relativePagePos.y, this.rect.width, this.rect.height, '#f0f0f0');
|
11609
|
+
bgRect.data.attrs['stroke'] = 'black';
|
11610
|
+
bgRect.data.attrs['stroke-width'] = 0.5;
|
11611
|
+
bgRect.data.attrs.rx = 5;
|
11612
|
+
bgRect.data.attrs.ry = 5;
|
11613
|
+
//t.children = [bgRect];
|
11614
|
+
event.highlights.push(bgRect);
|
11575
11615
|
}
|
11576
11616
|
return t;
|
11577
11617
|
}
|
@@ -18091,9 +18131,6 @@ class DocumentChange {
|
|
18091
18131
|
}
|
18092
18132
|
newInput(data) {
|
18093
18133
|
const { startControl, startOffset, collapsed, enableTrackChanges } = this.selectionState;
|
18094
|
-
if (!startControl) {
|
18095
|
-
debugger;
|
18096
|
-
}
|
18097
18134
|
if (!collapsed) {
|
18098
18135
|
this.onInputBySelectRange(data);
|
18099
18136
|
return;
|
@@ -18982,9 +19019,13 @@ class DocumentChange {
|
|
18982
19019
|
}
|
18983
19020
|
}
|
18984
19021
|
else {
|
19022
|
+
let insertTarget = targetElement;
|
19023
|
+
let insertTargetOffset = targetOffset;
|
18985
19024
|
for (let i = 0; i < destEleArray.length; i++) {
|
18986
19025
|
lastEle = destEleArray[i];
|
18987
|
-
|
19026
|
+
insertTarget.parent.addChild(lastEle, insertTarget.getIndex() + insertTargetOffset);
|
19027
|
+
insertTarget = lastEle;
|
19028
|
+
insertTargetOffset = 1;
|
18988
19029
|
}
|
18989
19030
|
}
|
18990
19031
|
return lastEle;
|
@@ -25670,10 +25711,13 @@ class EditorCalendarVNode {
|
|
25670
25711
|
}
|
25671
25712
|
render(position, dataValue) {
|
25672
25713
|
if (!this.currentDate && dataValue) {
|
25673
|
-
|
25674
|
-
this.
|
25675
|
-
this.
|
25714
|
+
const currDataValue = moment(dataValue);
|
25715
|
+
this.currYear.value = currDataValue.year();
|
25716
|
+
this.currMonth.value = currDataValue.month();
|
25717
|
+
this.selectedDate.value = currDataValue.format('YYYY-MM-DD');
|
25676
25718
|
this.currentDate = dataValue;
|
25719
|
+
this.currTime.value = currDataValue.format('HH:mm:ss');
|
25720
|
+
this.selectedTime.value = this.currTime.value;
|
25677
25721
|
}
|
25678
25722
|
if (!this.currentDate) {
|
25679
25723
|
this.currentDate = moment().format('YYYY-MM-DD');
|
@@ -26887,7 +26931,7 @@ class DocEditor {
|
|
26887
26931
|
*/
|
26888
26932
|
getCurrentDataElement() {
|
26889
26933
|
const selectionState = this.documentSelection.selectionState;
|
26890
|
-
const { startControl, startOffset, collapsed } = selectionState;
|
26934
|
+
const { startControl, startOffset, collapsed, ancestorCommonControl } = selectionState;
|
26891
26935
|
if (startControl && collapsed) {
|
26892
26936
|
if (!ElementUtil.verifyHitable(startControl)) {
|
26893
26937
|
return null;
|
@@ -26900,6 +26944,10 @@ class DocEditor {
|
|
26900
26944
|
return null;
|
26901
26945
|
}
|
26902
26946
|
}
|
26947
|
+
else if (!collapsed && ancestorCommonControl) {
|
26948
|
+
const dataEle = ElementUtil.getParent(startControl, validateDataEle);
|
26949
|
+
return dataEle;
|
26950
|
+
}
|
26903
26951
|
return null;
|
26904
26952
|
}
|
26905
26953
|
/**
|
@@ -27611,6 +27659,9 @@ class DocEditor {
|
|
27611
27659
|
const editor = this;
|
27612
27660
|
return {
|
27613
27661
|
render() {
|
27662
|
+
if (editor.viewOptions.docMode === DocMode.View) {
|
27663
|
+
return null;
|
27664
|
+
}
|
27614
27665
|
const dataEle = editor.getCurrentDataElement();
|
27615
27666
|
if (dataEle && dataEle instanceof DataElementList && dataEle.props.editable) {
|
27616
27667
|
const position = editor.getDataElementPosition(dataEle.startDecorate);
|
@@ -27721,6 +27772,9 @@ class DocEditor {
|
|
27721
27772
|
});
|
27722
27773
|
return {
|
27723
27774
|
render() {
|
27775
|
+
if (editor.viewOptions.docMode === DocMode.View) {
|
27776
|
+
return null;
|
27777
|
+
}
|
27724
27778
|
const dataEle = editor.getCurrentDataElement();
|
27725
27779
|
if (dataEle && dataEle instanceof DataElementDate && dataEle.props.editable) {
|
27726
27780
|
const position = editor.getDataElementPosition(dataEle.startDecorate);
|