@hailin-zheng/editor-core 2.2.16 → 2.2.18
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 +326 -136
- package/index-cjs.js.map +1 -1
- package/index.js +325 -137
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +25 -0
- package/med_editor/framework/document-change.d.ts +7 -0
- package/med_editor/framework/element-define.d.ts +7 -1
- package/med_editor/framework/element-serialize.d.ts +1 -1
- package/med_editor/framework/impl/data-element/data-element-base-impl.d.ts +8 -1
- package/package.json +1 -1
package/index-cjs.js
CHANGED
@@ -1749,18 +1749,26 @@ class ViewOptions {
|
|
1749
1749
|
dataEleEmptyBgColor = '';
|
1750
1750
|
//数据元鼠标悬浮颜色
|
1751
1751
|
dataEleMouseEnterBgColor = '#d9d9d9';
|
1752
|
+
dataEleMouseEnterDecoratorMode = 'background';
|
1752
1753
|
//数据元只读背景颜色
|
1753
1754
|
dataEleReadOnlyBgColor = '#d9d9d9';
|
1754
1755
|
//数据元焦点背景颜色
|
1755
1756
|
dataEleFocusedBgColor = '#d9d9d9';
|
1757
|
+
dataEleFocusedDecoratorMode = 'background';
|
1756
1758
|
//数据元正常背景颜色
|
1757
1759
|
dataEleNormalBgColor = '#fafafa';
|
1760
|
+
//数据元外部框线颜色
|
1761
|
+
dataEleOutlineColor = '#0050b3';
|
1762
|
+
//数据组外部框线颜色
|
1763
|
+
dataGroupOutlineColor = '#0050b3';
|
1758
1764
|
//数据元错误背景颜色
|
1759
1765
|
dataEleErrorBgColor = '#ff4d4f';
|
1760
1766
|
//数据组修饰符号颜色
|
1761
1767
|
dataGroupDecoratorNormalColor = '#0050b3';
|
1762
1768
|
dataGroupDecoratorMouseEnterColor = '#0050b3';
|
1769
|
+
dataGroupMouseEnterDecoratorMode = 'outline';
|
1763
1770
|
dataGroupDecoratorFocusedColor = '#0050b3';
|
1771
|
+
dataGroupFocusedDecoratorMode = 'outline';
|
1764
1772
|
//数据组正常背景颜色
|
1765
1773
|
dataGroupNormalBgColor = '#fafafa';
|
1766
1774
|
//数据元没有输入值时背景颜色
|
@@ -1781,8 +1789,6 @@ class ViewOptions {
|
|
1781
1789
|
trackDelColor = '#000';
|
1782
1790
|
showLineRect;
|
1783
1791
|
showCharRect;
|
1784
|
-
//数据元交互修饰模式
|
1785
|
-
dataEleDecoratorMode = 'outline';
|
1786
1792
|
showTabChar;
|
1787
1793
|
showSpaceChar;
|
1788
1794
|
showLineBreak;
|
@@ -3759,7 +3765,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3759
3765
|
},
|
3760
3766
|
},
|
3761
3767
|
children: [
|
3762
|
-
pageCorner, highlight, ...CommonUtil.toArray(event.getChildNodes(this)), pageNum,
|
3768
|
+
pageCorner, highlight, selection, ...CommonUtil.toArray(event.getChildNodes(this)), pageNum, copyright
|
3763
3769
|
]
|
3764
3770
|
};
|
3765
3771
|
}
|
@@ -3875,17 +3881,18 @@ class InlineGroupInputElement extends InlineGroupElement {
|
|
3875
3881
|
endDecorate;
|
3876
3882
|
constructor(type) {
|
3877
3883
|
super(type);
|
3878
|
-
//行内块不允许换行
|
3879
|
-
this.addEvent('ElementKeyDown', (evt) => {
|
3880
|
-
|
3881
|
-
|
3882
|
-
|
3883
|
-
|
3884
|
-
|
3885
|
-
|
3886
|
-
|
3887
|
-
|
3888
|
-
}
|
3884
|
+
// //行内块不允许换行
|
3885
|
+
// this.addEvent<KeyboradElementEvent>('ElementKeyDown', (evt) => {
|
3886
|
+
// const { selectionState, sourceEvent, source } = evt;
|
3887
|
+
// const { startControl, startOffset } = selectionState;
|
3888
|
+
// if (IsInSideInlineGroupInputElement(startControl as LeafElement, startOffset)) {
|
3889
|
+
// if (sourceEvent.shiftKey && sourceEvent.keyCode === 13) {
|
3890
|
+
// //this.removeNullText();
|
3891
|
+
// } else if (!sourceEvent.shiftKey && sourceEvent.keyCode === 13) {
|
3892
|
+
// evt.isCancel = true;
|
3893
|
+
// }
|
3894
|
+
// }
|
3895
|
+
// }, true);
|
3889
3896
|
this.addEvent('GotCursor', (evt) => {
|
3890
3897
|
const { startControl, startOffset } = evt.selectionState;
|
3891
3898
|
if (IsInSideInlineGroupInputElement(startControl, startOffset)) {
|
@@ -4085,7 +4092,11 @@ class DataElementInlineGroup extends InlineGroupInputElement {
|
|
4085
4092
|
}
|
4086
4093
|
});
|
4087
4094
|
}
|
4088
|
-
this.parserExpress = {
|
4095
|
+
this.parserExpress = {
|
4096
|
+
compliedCode,
|
4097
|
+
func: new Function(`with(this){ ${compliedCode} }`),
|
4098
|
+
depItems: depEleMap
|
4099
|
+
};
|
4089
4100
|
}
|
4090
4101
|
catch (e) {
|
4091
4102
|
console.error('解析表达式出错,parseEleExpression', this.props.expression);
|
@@ -4202,6 +4213,7 @@ function exportDataEleDecoratorSVG$1(event, r) {
|
|
4202
4213
|
return;
|
4203
4214
|
}
|
4204
4215
|
const options = event.options;
|
4216
|
+
let mode = 'background';
|
4205
4217
|
let color = options.dataEleNormalBgColor;
|
4206
4218
|
//空数据元填充颜色
|
4207
4219
|
if (r.element.length === 2 && options.dataEleEmptyBgColor) {
|
@@ -4209,17 +4221,69 @@ function exportDataEleDecoratorSVG$1(event, r) {
|
|
4209
4221
|
}
|
4210
4222
|
if (r.element.isMouseenter && options.dataEleMouseEnterBgColor) {
|
4211
4223
|
color = options.dataEleMouseEnterBgColor;
|
4224
|
+
mode = options.dataEleMouseEnterDecoratorMode;
|
4212
4225
|
}
|
4213
4226
|
if (r.element.isFocused && options.dataEleFocusedBgColor) {
|
4214
4227
|
color = options.dataEleFocusedBgColor;
|
4228
|
+
mode = options.dataEleFocusedDecoratorMode;
|
4215
4229
|
}
|
4216
4230
|
if (!color) {
|
4217
4231
|
return;
|
4218
4232
|
}
|
4219
4233
|
//绘制背景
|
4220
|
-
|
4221
|
-
|
4222
|
-
|
4234
|
+
if (['all', 'background'].includes(mode)) {
|
4235
|
+
const bgX = event.relativePagePos.x;
|
4236
|
+
const bgY = event.relativePagePos.y;
|
4237
|
+
event.highlights.push(ElementUtil.getFillSvgRect(bgX, bgY, r.rect.width, r.rect.height, color));
|
4238
|
+
}
|
4239
|
+
if (['all', 'outline'].includes(mode)) {
|
4240
|
+
color = event.options.dataEleOutlineColor;
|
4241
|
+
const verOffset = 0;
|
4242
|
+
const renderPosMap = getCurrentParaGroupRenders(r).map(item => ({ pos: getRenderPosToDoc(item), render: item }));
|
4243
|
+
if (renderPosMap.length > 1) {
|
4244
|
+
const secondGroupRenderPos = renderPosMap[1].pos;
|
4245
|
+
if (secondGroupRenderPos.x + renderPosMap[1].render.rect.width > event.relativePagePos.x) {
|
4246
|
+
const leftPoints = [];
|
4247
|
+
const rightPoints = [];
|
4248
|
+
for (let i = 0; i < renderPosMap.length; i++) {
|
4249
|
+
const groupRender = renderPosMap[i].render;
|
4250
|
+
const groupRenderPos = renderPosMap[i].pos;
|
4251
|
+
leftPoints.push({ x: groupRenderPos.x, y: groupRenderPos.y - verOffset });
|
4252
|
+
rightPoints.push({
|
4253
|
+
x: groupRenderPos.x + groupRender.rect.width,
|
4254
|
+
y: groupRenderPos.y - verOffset
|
4255
|
+
});
|
4256
|
+
leftPoints.push({
|
4257
|
+
x: groupRenderPos.x,
|
4258
|
+
y: groupRenderPos.y + groupRender.rect.height + verOffset * 2
|
4259
|
+
});
|
4260
|
+
rightPoints.push({
|
4261
|
+
x: groupRenderPos.x + groupRender.rect.width,
|
4262
|
+
y: groupRenderPos.y + groupRender.rect.height + verOffset * 2
|
4263
|
+
});
|
4264
|
+
}
|
4265
|
+
const sharpPoints1 = CommonUtil.resharpPoints(rightPoints);
|
4266
|
+
const sharpPoints = CommonUtil.resharpPoints([...leftPoints.reverse()]);
|
4267
|
+
const path = [...sharpPoints, ...sharpPoints1, sharpPoints[0]].map((item, index) => ((index === 0) ? 'M' : "L") + item.x + " " + item.y).join(" ");
|
4268
|
+
event.highlights.push(ElementUtil.createSvgPath({
|
4269
|
+
d: path,
|
4270
|
+
stroke: color,
|
4271
|
+
fill: 'none',
|
4272
|
+
'stroke-width': 1
|
4273
|
+
}));
|
4274
|
+
return;
|
4275
|
+
}
|
4276
|
+
}
|
4277
|
+
for (let i = 0; i < renderPosMap.length; i++) {
|
4278
|
+
const currRen = renderPosMap[i];
|
4279
|
+
event.highlights.push(ElementUtil.createSvgPath({
|
4280
|
+
d: `M${currRen.pos.x} ${currRen.pos.y} L${currRen.pos.x + currRen.render.rect.width} ${currRen.pos.y} L${currRen.pos.x + currRen.render.rect.width} ${currRen.pos.y + currRen.render.rect.height} L${currRen.pos.x} ${currRen.pos.y + currRen.render.rect.height} Z`,
|
4281
|
+
stroke: color,
|
4282
|
+
fill: 'none',
|
4283
|
+
'stroke-width': 1
|
4284
|
+
}));
|
4285
|
+
}
|
4286
|
+
}
|
4223
4287
|
// const canPaint = r.element.isMouseenter || r.element.isFocused;
|
4224
4288
|
// if (!canPaint) {
|
4225
4289
|
// return;
|
@@ -4234,51 +4298,6 @@ function exportDataEleDecoratorSVG$1(event, r) {
|
|
4234
4298
|
// event.highlights.push(ElementUtil.getFillSvgRect(bgX, bgY, r.rect.width, r.rect.height, color));
|
4235
4299
|
// return;
|
4236
4300
|
// } else if (mode === 'outline') {
|
4237
|
-
// const verOffset = 0;
|
4238
|
-
// const renderPosMap = getCurrentParaGroupRenders(r).map(item => ({ pos: getRenderPosToDoc(item), render: item }));
|
4239
|
-
// if (renderPosMap.length > 1) {
|
4240
|
-
// const secondGroupRenderPos = renderPosMap[1].pos;
|
4241
|
-
// if (secondGroupRenderPos.x + renderPosMap[1].render.rect.width > event.relativePagePos.x) {
|
4242
|
-
// const leftPoints: Array<Position> = [];
|
4243
|
-
// const rightPoints: Array<Position> = [];
|
4244
|
-
// for (let i = 0; i < renderPosMap.length; i++) {
|
4245
|
-
// const groupRender = renderPosMap[i].render;
|
4246
|
-
// const groupRenderPos = renderPosMap[i].pos;
|
4247
|
-
// leftPoints.push({ x: groupRenderPos.x, y: groupRenderPos.y - verOffset });
|
4248
|
-
// rightPoints.push({
|
4249
|
-
// x: groupRenderPos.x + groupRender.rect.width,
|
4250
|
-
// y: groupRenderPos.y - verOffset
|
4251
|
-
// });
|
4252
|
-
// leftPoints.push({
|
4253
|
-
// x: groupRenderPos.x,
|
4254
|
-
// y: groupRenderPos.y + groupRender.rect.height + verOffset * 2
|
4255
|
-
// });
|
4256
|
-
// rightPoints.push({
|
4257
|
-
// x: groupRenderPos.x + groupRender.rect.width,
|
4258
|
-
// y: groupRenderPos.y + groupRender.rect.height + verOffset * 2
|
4259
|
-
// });
|
4260
|
-
// }
|
4261
|
-
// const sharpPoints1 = CommonUtil.resharpPoints(rightPoints);
|
4262
|
-
// const sharpPoints = CommonUtil.resharpPoints([...leftPoints.reverse()]);
|
4263
|
-
// const path = [...sharpPoints, ...sharpPoints1, sharpPoints[0]].map((item, index) => ((index === 0) ? 'M' : "L") + item.x + " " + item.y).join(" ")
|
4264
|
-
// event.highlights.push(ElementUtil.createSvgPath({
|
4265
|
-
// d: path,
|
4266
|
-
// stroke: color,
|
4267
|
-
// fill: 'none',
|
4268
|
-
// 'stroke-width': 1
|
4269
|
-
// }));
|
4270
|
-
// return;
|
4271
|
-
// }
|
4272
|
-
// }
|
4273
|
-
// for (let i = 0; i < renderPosMap.length; i++) {
|
4274
|
-
// const currRen = renderPosMap[i];
|
4275
|
-
// event.highlights.push(ElementUtil.createSvgPath({
|
4276
|
-
// d: `M${currRen.pos.x} ${currRen.pos.y} L${currRen.pos.x + currRen.render.rect.width} ${currRen.pos.y} L${currRen.pos.x + currRen.render.rect.width} ${currRen.pos.y + currRen.render.rect.height} L${currRen.pos.x} ${currRen.pos.y + currRen.render.rect.height} Z`,
|
4277
|
-
// stroke: '#0050b3',
|
4278
|
-
// fill: 'none',
|
4279
|
-
// 'stroke-width': 1
|
4280
|
-
// }));
|
4281
|
-
// }
|
4282
4301
|
// }
|
4283
4302
|
}
|
4284
4303
|
/**
|
@@ -4385,6 +4404,30 @@ function renderUnderWavyLine(event, r, color) {
|
|
4385
4404
|
const path = ElementUtil.createSvgPath({ d, fill: 'none', stroke: color });
|
4386
4405
|
event.highlights.push(path);
|
4387
4406
|
}
|
4407
|
+
/**
|
4408
|
+
* 获取渲染元素相对稳当的位置
|
4409
|
+
* @param render
|
4410
|
+
* @param refPos
|
4411
|
+
*/
|
4412
|
+
function getRenderPosToDoc(render, refPos = null) {
|
4413
|
+
refPos = refPos ?? { x: 0, y: 0 };
|
4414
|
+
if (render instanceof DocumentRenderObject) {
|
4415
|
+
return refPos;
|
4416
|
+
}
|
4417
|
+
const currPos = { x: render.rect.x + refPos.x, y: render.rect.y + refPos.y };
|
4418
|
+
return getRenderPosToDoc(render.parent, currPos);
|
4419
|
+
}
|
4420
|
+
function getCurrentParaGroupRenders(r) {
|
4421
|
+
const renders = [];
|
4422
|
+
const currParaRender = ElementUtil.getParentRender(r, ParagraphRenderObject);
|
4423
|
+
for (let i = 0; i < r.element.paintRenders.length; i++) {
|
4424
|
+
const paraRender = ElementUtil.getParentRender(r.element.paintRenders[i], ParagraphRenderObject);
|
4425
|
+
if (paraRender === currParaRender) {
|
4426
|
+
renders.push(r.element.paintRenders[i]);
|
4427
|
+
}
|
4428
|
+
}
|
4429
|
+
return renders;
|
4430
|
+
}
|
4388
4431
|
function renderUnderline(event, render) {
|
4389
4432
|
const { x, y } = event.relativePagePos;
|
4390
4433
|
event.highlights.push({
|
@@ -4481,7 +4524,7 @@ class PSymbolElement extends LeafElement {
|
|
4481
4524
|
}
|
4482
4525
|
createRenderObject() {
|
4483
4526
|
const symbol = new PSymbolRenderObject(this);
|
4484
|
-
symbol.rect.height = this.defaultHeight;
|
4527
|
+
symbol.rect.height = Math.ceil(this.defaultHeight * TEXT_HEIGHT_FACTOR);
|
4485
4528
|
symbol.rect.width = 1;
|
4486
4529
|
return symbol;
|
4487
4530
|
}
|
@@ -4503,12 +4546,20 @@ class PSymbolRenderObject extends LeafRenderObject {
|
|
4503
4546
|
if (!event.options.showEnterSymbol || event.mode === 'print') {
|
4504
4547
|
return null;
|
4505
4548
|
}
|
4506
|
-
|
4507
|
-
|
4508
|
-
|
4549
|
+
const font = `14px 宋体`;
|
4550
|
+
const actualFontBoundingBoxAscent = event.renderCtx.mainContext.getActualFontBoundingBoxAscent(font);
|
4551
|
+
let y = this.rect.y;
|
4552
|
+
//基线处理
|
4553
|
+
y += actualFontBoundingBoxAscent ?? 0;
|
4554
|
+
//行高处理
|
4555
|
+
y += (this.rect.height - 14) / 2;
|
4556
|
+
return ElementUtil.createSvgText('↵', {
|
4557
|
+
'font-family': '宋体',
|
4558
|
+
'font-size': 14,
|
4509
4559
|
x: this.rect.x,
|
4510
|
-
y:
|
4511
|
-
fill: 'green'
|
4560
|
+
y: y,
|
4561
|
+
fill: 'green'
|
4562
|
+
});
|
4512
4563
|
}
|
4513
4564
|
//绘制段落符号
|
4514
4565
|
clone() {
|
@@ -8727,7 +8778,7 @@ class BreakElement extends LeafElement {
|
|
8727
8778
|
}
|
8728
8779
|
createRenderObject() {
|
8729
8780
|
const symbol = new BreakRenderObject(this);
|
8730
|
-
symbol.rect.height = 14;
|
8781
|
+
symbol.rect.height = Math.ceil(14 * TEXT_HEIGHT_FACTOR);
|
8731
8782
|
symbol.rect.width = 7;
|
8732
8783
|
return symbol;
|
8733
8784
|
}
|
@@ -8748,12 +8799,26 @@ class BreakRenderObject extends LeafRenderObject {
|
|
8748
8799
|
if (!event.options.showEnterSymbol || event.mode === 'print') {
|
8749
8800
|
return null;
|
8750
8801
|
}
|
8751
|
-
return ElementUtil.createSvgText('↓',
|
8752
|
-
|
8753
|
-
|
8754
|
-
|
8755
|
-
|
8756
|
-
|
8802
|
+
// return ElementUtil.createSvgText( '↓',{ 'dominant-baseline': 'hanging',
|
8803
|
+
// 'font-family': 'Courier',
|
8804
|
+
// 'font-size': this.rect.height,
|
8805
|
+
// x: this.rect.x + 4,
|
8806
|
+
// y: this.rect.y,
|
8807
|
+
// fill: 'green'});
|
8808
|
+
const font = `14px 宋体`;
|
8809
|
+
const actualFontBoundingBoxAscent = event.renderCtx.mainContext.getActualFontBoundingBoxAscent(font);
|
8810
|
+
let y = 0;
|
8811
|
+
//基线处理
|
8812
|
+
y += actualFontBoundingBoxAscent ?? 0;
|
8813
|
+
//行高处理
|
8814
|
+
y += (this.parent.rect.height - 14) / 2;
|
8815
|
+
return ElementUtil.createSvgText('↓', {
|
8816
|
+
'font-family': '宋体',
|
8817
|
+
'font-size': 14,
|
8818
|
+
x: this.rect.x,
|
8819
|
+
y: y,
|
8820
|
+
fill: 'green'
|
8821
|
+
});
|
8757
8822
|
}
|
8758
8823
|
clone() {
|
8759
8824
|
const render = new BreakRenderObject(this.element);
|
@@ -8905,23 +8970,76 @@ function exportDataEleDecoratorSVG(event, r) {
|
|
8905
8970
|
}
|
8906
8971
|
const options = event.options;
|
8907
8972
|
let color = options.dataGroupNormalBgColor;
|
8973
|
+
let mode = 'background';
|
8908
8974
|
//空数据元填充颜色
|
8909
8975
|
if (r.element.length === 2 && options.dataGroupEmptyBgColor) {
|
8910
8976
|
color = options.dataGroupEmptyBgColor;
|
8911
8977
|
}
|
8912
8978
|
if (r.element.isMouseenter && options.dataGroupMouseEnterBgColor) {
|
8913
8979
|
color = options.dataGroupMouseEnterBgColor;
|
8980
|
+
mode = options.dataGroupMouseEnterDecoratorMode;
|
8914
8981
|
}
|
8915
8982
|
if (r.element.isFocused && options.dataGroupFocusedBgColor) {
|
8916
8983
|
color = options.dataGroupFocusedBgColor;
|
8984
|
+
mode = options.dataGroupFocusedDecoratorMode;
|
8917
8985
|
}
|
8918
8986
|
if (!color) {
|
8919
8987
|
return;
|
8920
8988
|
}
|
8921
8989
|
//绘制背景
|
8922
|
-
|
8923
|
-
|
8924
|
-
|
8990
|
+
if (['all', 'background'].includes(mode)) {
|
8991
|
+
const bgX = event.relativePagePos.x;
|
8992
|
+
const bgY = event.relativePagePos.y;
|
8993
|
+
event.highlights.push(ElementUtil.getFillSvgRect(bgX, bgY, r.rect.width, r.rect.height, color));
|
8994
|
+
}
|
8995
|
+
if (['all', 'outline'].includes(mode)) {
|
8996
|
+
color = event.options.dataGroupOutlineColor;
|
8997
|
+
const verOffset = 0;
|
8998
|
+
const renderPosMap = getCurrentParaGroupRenders(r).map(item => ({ pos: getRenderPosToDoc(item), render: item }));
|
8999
|
+
if (renderPosMap.length > 1) {
|
9000
|
+
const secondGroupRenderPos = renderPosMap[1].pos;
|
9001
|
+
if (secondGroupRenderPos.x + renderPosMap[1].render.rect.width > event.relativePagePos.x) {
|
9002
|
+
const leftPoints = [];
|
9003
|
+
const rightPoints = [];
|
9004
|
+
for (let i = 0; i < renderPosMap.length; i++) {
|
9005
|
+
const groupRender = renderPosMap[i].render;
|
9006
|
+
const groupRenderPos = renderPosMap[i].pos;
|
9007
|
+
leftPoints.push({ x: groupRenderPos.x, y: groupRenderPos.y - verOffset });
|
9008
|
+
rightPoints.push({
|
9009
|
+
x: groupRenderPos.x + groupRender.rect.width,
|
9010
|
+
y: groupRenderPos.y - verOffset
|
9011
|
+
});
|
9012
|
+
leftPoints.push({
|
9013
|
+
x: groupRenderPos.x,
|
9014
|
+
y: groupRenderPos.y + groupRender.rect.height + verOffset * 2
|
9015
|
+
});
|
9016
|
+
rightPoints.push({
|
9017
|
+
x: groupRenderPos.x + groupRender.rect.width,
|
9018
|
+
y: groupRenderPos.y + groupRender.rect.height + verOffset * 2
|
9019
|
+
});
|
9020
|
+
}
|
9021
|
+
const sharpPoints1 = CommonUtil.resharpPoints(rightPoints);
|
9022
|
+
const sharpPoints = CommonUtil.resharpPoints([...leftPoints.reverse()]);
|
9023
|
+
const path = [...sharpPoints, ...sharpPoints1, sharpPoints[0]].map((item, index) => ((index === 0) ? 'M' : "L") + item.x + " " + item.y).join(" ");
|
9024
|
+
event.highlights.push(ElementUtil.createSvgPath({
|
9025
|
+
d: path,
|
9026
|
+
stroke: color,
|
9027
|
+
fill: 'none',
|
9028
|
+
'stroke-width': 1
|
9029
|
+
}));
|
9030
|
+
return;
|
9031
|
+
}
|
9032
|
+
}
|
9033
|
+
for (let i = 0; i < renderPosMap.length; i++) {
|
9034
|
+
const currRen = renderPosMap[i];
|
9035
|
+
event.highlights.push(ElementUtil.createSvgPath({
|
9036
|
+
d: `M${currRen.pos.x} ${currRen.pos.y} L${currRen.pos.x + currRen.render.rect.width} ${currRen.pos.y} L${currRen.pos.x + currRen.render.rect.width} ${currRen.pos.y + currRen.render.rect.height} L${currRen.pos.x} ${currRen.pos.y + currRen.render.rect.height} Z`,
|
9037
|
+
stroke: color,
|
9038
|
+
fill: 'none',
|
9039
|
+
'stroke-width': 1
|
9040
|
+
}));
|
9041
|
+
}
|
9042
|
+
}
|
8925
9043
|
}
|
8926
9044
|
|
8927
9045
|
class DataElementImage extends DataElementLeaf {
|
@@ -10888,9 +11006,22 @@ class ElementSerialize {
|
|
10888
11006
|
const { startCol, endCol } = tbRegion;
|
10889
11007
|
const cloneTb = ElementUtil.cloneRange(range, false, 'copy');
|
10890
11008
|
cloneTb.props.cols = cloneTb.props.cols.slice(startCol, endCol + 1);
|
10891
|
-
return cloneTb;
|
11009
|
+
return [cloneTb];
|
10892
11010
|
}
|
10893
|
-
|
11011
|
+
//元素全选的情况下
|
11012
|
+
// if (range.isFullSelected) {
|
11013
|
+
// const ele = ElementUtil.cloneRange(range, false, 'copy');
|
11014
|
+
// return ele ? [ele] : null;
|
11015
|
+
// }
|
11016
|
+
//元素部分选中的情况下,只获取选中的部分元素
|
11017
|
+
const selectedEle = range.selectedChildren.map(item => ElementUtil.cloneRange(item, false, 'copy'));
|
11018
|
+
const list = [];
|
11019
|
+
selectedEle.forEach(item => {
|
11020
|
+
if (item) {
|
11021
|
+
list.push(item);
|
11022
|
+
}
|
11023
|
+
});
|
11024
|
+
return list;
|
10894
11025
|
}
|
10895
11026
|
/**
|
10896
11027
|
* 选中的文本
|
@@ -10898,18 +11029,19 @@ class ElementSerialize {
|
|
10898
11029
|
* @param viewOptions
|
10899
11030
|
*/
|
10900
11031
|
static getSelectedText(ss, viewOptions) {
|
10901
|
-
const
|
10902
|
-
if (
|
10903
|
-
return this.serializeString(
|
11032
|
+
const selectedStructs = this.getSelectedStruct(ss, viewOptions);
|
11033
|
+
if (selectedStructs) {
|
11034
|
+
return selectedStructs.map(item => this.serializeString(item)).join('');
|
10904
11035
|
}
|
10905
11036
|
else {
|
10906
11037
|
return '';
|
10907
11038
|
}
|
10908
11039
|
}
|
10909
11040
|
static getSelectedJSON(ss, viewOptions) {
|
10910
|
-
const
|
10911
|
-
if (
|
10912
|
-
return JSON.stringify(this.serialize(
|
11041
|
+
const selectedStructs = this.getSelectedStruct(ss, viewOptions);
|
11042
|
+
if (selectedStructs) {
|
11043
|
+
//return JSON.stringify(this.serialize(selectedStructs, viewOptions));
|
11044
|
+
return JSON.stringify(selectedStructs.map(item => this.serialize(item, viewOptions)).filter(item => item));
|
10913
11045
|
}
|
10914
11046
|
else {
|
10915
11047
|
return '';
|
@@ -14220,6 +14352,11 @@ class ParagraphMeasure {
|
|
14220
14352
|
parent: parentLine,
|
14221
14353
|
isCloseToBody: parentLine.isCloseToBody,
|
14222
14354
|
applyNewLine() {
|
14355
|
+
//申请新行前,需要将当前内联元素的宽度扩充到可用最大宽度
|
14356
|
+
const space = parentLine.limitWidth - parentLine.lineWidth();
|
14357
|
+
if (space > 0) {
|
14358
|
+
render.rect.width += space;
|
14359
|
+
}
|
14223
14360
|
parentLine.applyNewLine();
|
14224
14361
|
render = ele.createRenderObject({ options, renderCtx, execute });
|
14225
14362
|
parentLine.add(render);
|
@@ -16826,7 +16963,7 @@ class DocumentEvent {
|
|
16826
16963
|
this.moveCursorToRightHandle(nextEle, ElementUtil.fixedOffset(nextEle, -1));
|
16827
16964
|
return;
|
16828
16965
|
}
|
16829
|
-
this.selectionState.resetRange(nextEle,
|
16966
|
+
this.selectionState.resetRange(nextEle, 0);
|
16830
16967
|
return;
|
16831
16968
|
}
|
16832
16969
|
}
|
@@ -18024,6 +18161,9 @@ class DocumentChange {
|
|
18024
18161
|
const { startControl } = this.selectionState;
|
18025
18162
|
const paragraph = ElementUtil.getParentByType(startControl, ParagraphElement);
|
18026
18163
|
const breakPara = this.splitCurrentParagraph();
|
18164
|
+
if (!breakPara) {
|
18165
|
+
return;
|
18166
|
+
}
|
18027
18167
|
//选中的是一个元素
|
18028
18168
|
if (breakPara === paragraph) {
|
18029
18169
|
const clonePara = paragraph.clone(false);
|
@@ -18045,6 +18185,9 @@ class DocumentChange {
|
|
18045
18185
|
*/
|
18046
18186
|
insertLayoutContainer(ele) {
|
18047
18187
|
const breakPara = this.splitCurrentParagraph();
|
18188
|
+
if (!breakPara) {
|
18189
|
+
return;
|
18190
|
+
}
|
18048
18191
|
breakPara.parent.addChild(ele, breakPara.getIndex());
|
18049
18192
|
this.selectionState.resetRange(ele, 0);
|
18050
18193
|
}
|
@@ -18054,6 +18197,11 @@ class DocumentChange {
|
|
18054
18197
|
*/
|
18055
18198
|
splitCurrentParagraph() {
|
18056
18199
|
const { startControl, startOffset } = this.selectionState;
|
18200
|
+
//内联数据块不能拆分两部分
|
18201
|
+
if (!this.allowSplitParagraph()) {
|
18202
|
+
console.warn("内联数据块不能拆分!");
|
18203
|
+
return null;
|
18204
|
+
}
|
18057
18205
|
const paragraph = ElementUtil.getParentByType(startControl, ParagraphElement);
|
18058
18206
|
const paraContainer = paragraph.parent;
|
18059
18207
|
//如果选中的是段落第一个元素
|
@@ -18474,67 +18622,53 @@ class DocumentChange {
|
|
18474
18622
|
}
|
18475
18623
|
return;
|
18476
18624
|
}
|
18477
|
-
|
18478
|
-
|
18479
|
-
|
18625
|
+
let data = JSON.parse(pasteData.doc);
|
18626
|
+
const pasteEles = [];
|
18627
|
+
data = Array.isArray(data) ? data : [data];
|
18628
|
+
data.forEach(item => {
|
18629
|
+
const ele = this.eleReader.readElement(item);
|
18630
|
+
if (ele) {
|
18631
|
+
pasteEles.push(ele);
|
18632
|
+
}
|
18633
|
+
else {
|
18634
|
+
console.log('粘贴反序列化数据失败', item);
|
18635
|
+
}
|
18636
|
+
});
|
18637
|
+
if (!pasteEles.length) {
|
18480
18638
|
return;
|
18481
18639
|
}
|
18482
18640
|
//表单模式:如果复制的是单格式的文本,需要序列化为纯文本处理
|
18483
18641
|
if (this.viewOptions.docMode === exports.DocMode.FormEdit) {
|
18484
|
-
const pasteString = ElementSerialize.serializeString(
|
18642
|
+
const pasteString = pasteEles.map(item => ElementSerialize.serializeString(item, { all: false })).join('');
|
18485
18643
|
if (pasteString) {
|
18486
18644
|
this.pastePlainText(pasteString);
|
18487
18645
|
}
|
18488
18646
|
return;
|
18489
18647
|
}
|
18490
|
-
|
18491
|
-
|
18492
|
-
|
18493
|
-
children.push(...ElementUtil.getChildrenElements(pasteElement));
|
18494
|
-
}
|
18495
|
-
else if (pasteElement instanceof InlineGroupElement) {
|
18496
|
-
//当前粘贴的元素为数据元,并且在数据元内部粘贴
|
18497
|
-
if (IsInSideDataElement(startControl, startOffset) && pasteElement instanceof DataElementInlineGroup) {
|
18498
|
-
const pasteChildren = pasteElement.getInnerItems().map(item => item.clone(true));
|
18499
|
-
children.push(...pasteChildren);
|
18500
|
-
}
|
18501
|
-
else {
|
18502
|
-
children.push(pasteElement);
|
18503
|
-
}
|
18504
|
-
}
|
18505
|
-
if (!children.length) {
|
18506
|
-
throw new Error('段落子元素为空');
|
18507
|
-
}
|
18508
|
-
const lastEle = this.insertElement(startControl, startOffset, children);
|
18509
|
-
this.selectionState.resetRange(lastEle, -1);
|
18510
|
-
return;
|
18648
|
+
//复制的内容为表格,且操作位于单元格内
|
18649
|
+
if (pasteEles[0] instanceof TableElement && ElementUtil.getParentByType(startControl, TableCellElement) && pasteEles.length === 1) {
|
18650
|
+
this.pasteTableToCell(pasteEles[0]);
|
18511
18651
|
}
|
18512
|
-
|
18652
|
+
//复制的为表格或者段落
|
18653
|
+
else if (pasteEles[0] instanceof BlockContainerElement || pasteEles[0] instanceof ParagraphElement) {
|
18513
18654
|
const children = [];
|
18514
|
-
|
18515
|
-
children.push(pasteElement);
|
18516
|
-
if (ElementUtil.getParentByType(startControl, TableCellElement)) {
|
18517
|
-
this.pasteTableToCell(pasteElement);
|
18518
|
-
return;
|
18519
|
-
}
|
18520
|
-
}
|
18521
|
-
else {
|
18522
|
-
children.push(...ElementUtil.getChildrenElements(pasteElement));
|
18523
|
-
}
|
18524
|
-
//复制的内容全部为段落,执行黏贴操作
|
18525
|
-
// if (children.every(item => item instanceof ParagraphElement)) {
|
18526
|
-
// const targetParagraph = this.splitCurrentParagraph();
|
18527
|
-
// children.forEach((item, i) => {
|
18528
|
-
// targetParagraph.parent.addChild(item, targetParagraph.getIndex());
|
18529
|
-
// });
|
18530
|
-
// this.selectionState.resetRange(children[children.length - 1], -1);
|
18531
|
-
// }
|
18655
|
+
children.push(...pasteEles);
|
18532
18656
|
const targetParagraph = this.splitCurrentParagraph();
|
18657
|
+
if (!targetParagraph) {
|
18658
|
+
return;
|
18659
|
+
}
|
18533
18660
|
children.forEach((item, i) => {
|
18534
18661
|
targetParagraph.parent.addChild(item, targetParagraph.getIndex());
|
18535
18662
|
});
|
18536
18663
|
this.selectionState.resetRange(children[children.length - 1], -1);
|
18537
18664
|
}
|
18665
|
+
//符合段落内的元素约定
|
18666
|
+
else {
|
18667
|
+
const children = [];
|
18668
|
+
children.push(...pasteEles);
|
18669
|
+
const lastEle = this.insertElement(startControl, startOffset, children);
|
18670
|
+
this.selectionState.resetRange(lastEle, -1);
|
18671
|
+
}
|
18538
18672
|
}
|
18539
18673
|
/**
|
18540
18674
|
* 复制单元格向另一个单元格粘贴
|
@@ -18630,6 +18764,9 @@ class DocumentChange {
|
|
18630
18764
|
}
|
18631
18765
|
else {
|
18632
18766
|
const breakPara = this.splitCurrentParagraph();
|
18767
|
+
if (!breakPara) {
|
18768
|
+
return;
|
18769
|
+
}
|
18633
18770
|
for (let i = 0; i < textItems.length; i++) {
|
18634
18771
|
const newPara = breakPara.clone(false);
|
18635
18772
|
const inputTextProps = this.getDefaultTextPropsByOptions();
|
@@ -18641,6 +18778,20 @@ class DocumentChange {
|
|
18641
18778
|
this.selectionState.resetRange(breakPara, 0);
|
18642
18779
|
}
|
18643
18780
|
}
|
18781
|
+
/**
|
18782
|
+
* 当前光标位置是否允许分割生成两个段落
|
18783
|
+
*/
|
18784
|
+
allowSplitParagraph(target) {
|
18785
|
+
if (!target) {
|
18786
|
+
target = this.selectionState;
|
18787
|
+
}
|
18788
|
+
const { startControl, startOffset } = target;
|
18789
|
+
//内联数据块不能拆分两部分
|
18790
|
+
if (IsInSideInlineGroupInputElement(startControl, startOffset)) {
|
18791
|
+
return false;
|
18792
|
+
}
|
18793
|
+
return true;
|
18794
|
+
}
|
18644
18795
|
/**
|
18645
18796
|
* 向当前光标追加文本
|
18646
18797
|
* @param appendStr
|
@@ -19701,7 +19852,6 @@ class DocumentSvg {
|
|
19701
19852
|
fill: item.color ?? this.viewOptions.selectionColor,
|
19702
19853
|
'paint-order': 'stroke fill markers',
|
19703
19854
|
d: `M${item.x} ${item.y} L${item.x + item.width} ${item.y} L${item.x + item.width} ${item.y + item.height} L${item.x} ${item.y + item.height} Z`,
|
19704
|
-
'fill-opacity': '0.5'
|
19705
19855
|
}
|
19706
19856
|
}
|
19707
19857
|
}));
|
@@ -21686,8 +21836,13 @@ class DocEditor {
|
|
21686
21836
|
return ElementSerialize.getSelectedJSON(this.selectionState, this.viewOptions);
|
21687
21837
|
}
|
21688
21838
|
getSelectedText() {
|
21689
|
-
const
|
21690
|
-
|
21839
|
+
const selectedEles = ElementSerialize.getSelectedStruct(this.selectionState, this.viewOptions);
|
21840
|
+
if (!selectedEles) {
|
21841
|
+
return '';
|
21842
|
+
}
|
21843
|
+
return selectedEles.map(ele => {
|
21844
|
+
return ElementSerialize.serializeString(ele);
|
21845
|
+
}).join('');
|
21691
21846
|
}
|
21692
21847
|
/**
|
21693
21848
|
* 执行编辑器内部复制事件
|
@@ -22318,7 +22473,7 @@ class DocEditor {
|
|
22318
22473
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
22319
22474
|
}
|
22320
22475
|
version() {
|
22321
|
-
return "2.2.
|
22476
|
+
return "2.2.18";
|
22322
22477
|
}
|
22323
22478
|
switchPageHeaderEditor() {
|
22324
22479
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|
@@ -22632,6 +22787,39 @@ class DocEditor {
|
|
22632
22787
|
}
|
22633
22788
|
return res;
|
22634
22789
|
}
|
22790
|
+
/**
|
22791
|
+
* 返回当前光标处是否允许截断段落生成新的段落
|
22792
|
+
* @returns
|
22793
|
+
*/
|
22794
|
+
allowSplitParagraph() {
|
22795
|
+
return this.documentChange.allowSplitParagraph();
|
22796
|
+
}
|
22797
|
+
/**
|
22798
|
+
* 设置元素属性(attribute)
|
22799
|
+
* @param ele
|
22800
|
+
* @param attr
|
22801
|
+
* @param value
|
22802
|
+
*/
|
22803
|
+
setEleAttribute(ele, attr, value) {
|
22804
|
+
ElementUtil.setEleAttribute(ele, attr, value);
|
22805
|
+
}
|
22806
|
+
/**
|
22807
|
+
* 获取元素属性(attribute)
|
22808
|
+
* @param ele
|
22809
|
+
* @param attr
|
22810
|
+
* @returns
|
22811
|
+
*/
|
22812
|
+
getEleAttribute(ele, attr) {
|
22813
|
+
return ElementUtil.getEleAttribute(ele, attr);
|
22814
|
+
}
|
22815
|
+
/**
|
22816
|
+
* 删除元素属性(attribute)
|
22817
|
+
* @param ele
|
22818
|
+
* @param attr
|
22819
|
+
*/
|
22820
|
+
removeEleAttribute(ele, attr) {
|
22821
|
+
ElementUtil.removeEleAttribute(ele, attr);
|
22822
|
+
}
|
22635
22823
|
}
|
22636
22824
|
|
22637
22825
|
/**
|
@@ -28277,7 +28465,9 @@ exports.formatEle = formatEle;
|
|
28277
28465
|
exports.fromEvent = fromEvent;
|
28278
28466
|
exports.generatePatch = generatePatch;
|
28279
28467
|
exports.getCalleeName = getCalleeName;
|
28468
|
+
exports.getCurrentParaGroupRenders = getCurrentParaGroupRenders;
|
28280
28469
|
exports.getFocusTextSegment = getFocusTextSegment;
|
28470
|
+
exports.getRenderPosToDoc = getRenderPosToDoc;
|
28281
28471
|
exports.inputText = inputText;
|
28282
28472
|
exports.insertEle = insertEle;
|
28283
28473
|
exports.invokeTypeHandler = invokeTypeHandler;
|