@hailin-zheng/editor-core 2.2.7 → 2.2.8
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/editor.css +348 -348
- package/index-cjs.js +208 -254
- package/index-cjs.js.map +1 -1
- package/index.js +208 -254
- package/index.js.map +1 -1
- package/med_editor/framework/element-define.d.ts +8 -5
- package/med_editor/framework/element-serialize.d.ts +1 -1
- package/med_editor/framework/impl/data-element/data-container-impl.d.ts +8 -8
- package/med_editor/framework/impl/document/doc-body-impl.d.ts +2 -2
- package/med_editor/framework/impl/document/doc-body-part-impl.d.ts +2 -2
- package/med_editor/framework/impl/paragraph/p-impl.d.ts +2 -2
- package/med_editor/framework/impl/table/table-impl.d.ts +2 -2
- package/med_editor/framework/impl/table/table-row-impl.d.ts +2 -2
- package/med_editor/framework/render-define.d.ts +5 -6
- package/package.json +2 -2
package/index-cjs.js
CHANGED
@@ -417,7 +417,6 @@ class BlockContentRenderObject extends BranchRenderObject {
|
|
417
417
|
}
|
418
418
|
}
|
419
419
|
class InlineGroupRenderObject extends BranchRenderObject {
|
420
|
-
paintPos;
|
421
420
|
}
|
422
421
|
/**
|
423
422
|
* 包含块级渲染元素的容器元素,例如body、table-cell等
|
@@ -431,18 +430,18 @@ class BlockContainerRenderObject extends BranchRenderObject {
|
|
431
430
|
/**
|
432
431
|
* 多级 ‘BlockLineRectRenderObject’ 包裹元素,例如 p、table
|
433
432
|
*/
|
434
|
-
class
|
433
|
+
class MultiBlockLineRenderObject extends BlockContentRenderObject {
|
435
434
|
}
|
436
435
|
/**
|
437
436
|
* 容器-子内容为多个行内块级元素,例如table-row
|
438
437
|
*/
|
439
|
-
class InlineBlockContainer extends
|
438
|
+
class InlineBlockContainer extends MultiBlockLineRenderObject {
|
440
439
|
}
|
441
440
|
/**
|
442
441
|
* 服务于table-cell
|
443
442
|
* 可被多级拆分的元素
|
444
443
|
*/
|
445
|
-
class InlineMuiltBlockLineRenderObject extends
|
444
|
+
class InlineMuiltBlockLineRenderObject extends MultiBlockLineRenderObject {
|
446
445
|
}
|
447
446
|
/**
|
448
447
|
* 最小不可分割单位的块级行框,例如 p-line
|
@@ -1726,12 +1725,22 @@ class ViewOptions {
|
|
1726
1725
|
defaultColor = "#000000";
|
1727
1726
|
currentFontSize = 14;
|
1728
1727
|
currentFontName = '宋体';
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1728
|
+
//选区颜色
|
1729
|
+
selectionColor = 'rgb(131,175,155,0.5)';
|
1730
|
+
dataDecoratorNormalColor = '#0050b3';
|
1731
|
+
dataDecoratorMouseEnterColor = '#0050b3';
|
1732
|
+
dataDecoratorFocusedColor = '#0050b3';
|
1733
|
+
//数据元没有输入值时背景颜色
|
1734
|
+
dataEleEmptyBgColor = '';
|
1735
|
+
//数据元鼠标悬浮颜色
|
1736
|
+
dataEleMouseEnterBgColor = '#d9d9d9';
|
1737
|
+
//数据元只读背景颜色
|
1738
|
+
dataEleReadOnlyBgColor = '#d9d9d9';
|
1739
|
+
//数据元焦点背景颜色
|
1740
|
+
dataEleFocusedBgColor = '#d9d9d9';
|
1741
|
+
//数据元正常背景颜色
|
1742
|
+
dataEleNormalBgColor = '#fafafa';
|
1732
1743
|
dataEleErrorBgColor = '#ff4d4f';
|
1733
|
-
dataEleReadOnlyOverlayColor = '#d9d9d9';
|
1734
|
-
dataEleOutlineColor = 'rgb(131,175,155,0.7)';
|
1735
1744
|
viewBackcolor = 'rgb(230,230,230)';
|
1736
1745
|
paraSymbolColor = 'rgb(128,128,128)';
|
1737
1746
|
dataGroupColor = 'rgb(0,80,179)';
|
@@ -1746,7 +1755,6 @@ class ViewOptions {
|
|
1746
1755
|
showCharRect;
|
1747
1756
|
//数据元交互修饰模式
|
1748
1757
|
dataEleDecoratorMode = 'outline';
|
1749
|
-
dataEleDecoratorColor = '#ddd';
|
1750
1758
|
showTabChar;
|
1751
1759
|
showSpaceChar;
|
1752
1760
|
showLineBreak;
|
@@ -2929,7 +2937,7 @@ class DataDecorateElement extends LeafElement {
|
|
2929
2937
|
const render = new DataDecorateRenderObject(this);
|
2930
2938
|
//render.rect.width = this.dProps.size / 2;
|
2931
2939
|
render.rect.width = 1;
|
2932
|
-
render.rect.height = 14;
|
2940
|
+
render.rect.height = Math.ceil(14 * TEXT_HEIGHT_FACTOR);
|
2933
2941
|
return render;
|
2934
2942
|
}
|
2935
2943
|
serialize() {
|
@@ -2955,6 +2963,14 @@ class DataDecorateRenderObject extends LeafRenderObject {
|
|
2955
2963
|
// if(this.element.parent.parent.type==='data-group'){
|
2956
2964
|
// return null;
|
2957
2965
|
// }
|
2966
|
+
const options = event.options;
|
2967
|
+
let color = options.dataDecoratorNormalColor;
|
2968
|
+
if (this.element.dataEle.isMouseenter && options.dataDecoratorMouseEnterColor) {
|
2969
|
+
color = options.dataDecoratorMouseEnterColor;
|
2970
|
+
}
|
2971
|
+
if (this.element.dataEle.isFocused && options.dataDecoratorFocusedColor) {
|
2972
|
+
color = options.dataDecoratorFocusedColor;
|
2973
|
+
}
|
2958
2974
|
const element = this.element;
|
2959
2975
|
const lineWidth = 3;
|
2960
2976
|
let path = '';
|
@@ -2968,7 +2984,7 @@ class DataDecorateRenderObject extends LeafRenderObject {
|
|
2968
2984
|
path = `M ${x - lineWidth} 2 L ${x} 2 L ${x} ${height} L ${x - lineWidth} ${height}`;
|
2969
2985
|
}
|
2970
2986
|
return ElementUtil.createSvgPath({
|
2971
|
-
stroke:
|
2987
|
+
stroke: color,
|
2972
2988
|
fill: "none",
|
2973
2989
|
'stroke-width': 1,
|
2974
2990
|
d: path
|
@@ -3134,7 +3150,7 @@ class ParagraphElement extends BlockContentElement {
|
|
3134
3150
|
return new ParagraphElement();
|
3135
3151
|
}
|
3136
3152
|
}
|
3137
|
-
class ParagraphRenderObject extends
|
3153
|
+
class ParagraphRenderObject extends MultiBlockLineRenderObject {
|
3138
3154
|
/**
|
3139
3155
|
* 绘制项目符号
|
3140
3156
|
*/
|
@@ -3683,7 +3699,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3683
3699
|
},
|
3684
3700
|
},
|
3685
3701
|
children: [
|
3686
|
-
pageCorner,
|
3702
|
+
pageCorner, highlight, ...CommonUtil.toArray(event.getChildNodes(this)), pageNum, selection, copyright
|
3687
3703
|
]
|
3688
3704
|
};
|
3689
3705
|
}
|
@@ -3721,11 +3737,10 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3721
3737
|
}
|
3722
3738
|
const str = "\u6f14\u793a\u7248\u672c";
|
3723
3739
|
const textProps = new TextProps();
|
3724
|
-
textProps.color = "#
|
3725
|
-
textProps.fontName = '
|
3740
|
+
textProps.color = "#bfbfbf";
|
3741
|
+
textProps.fontName = '宋体';
|
3726
3742
|
textProps.fontSize = 80;
|
3727
3743
|
textProps.fontStyle = 'italic';
|
3728
|
-
event.renderCtx.contentContext.measureText(str, textProps);
|
3729
3744
|
const getTextRotationAngle = (width, height) => {
|
3730
3745
|
return Math.atan(height / width) * 180 / Math.PI;
|
3731
3746
|
};
|
@@ -3744,6 +3759,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3744
3759
|
'font-size': textProps.fontSize,
|
3745
3760
|
"stroke": textProps.color,
|
3746
3761
|
'fill': '#fff',
|
3762
|
+
'opacity': '0.5',
|
3747
3763
|
x: this.rect.width / 2,
|
3748
3764
|
y: this.rect.height / 2,
|
3749
3765
|
}
|
@@ -4131,68 +4147,85 @@ class DataElementBaseFactory extends ElementFactory {
|
|
4131
4147
|
* @param r
|
4132
4148
|
*/
|
4133
4149
|
function exportDecoratorHTML(event, r) {
|
4134
|
-
|
4135
|
-
if (!canPaint) {
|
4150
|
+
if (event.mode === 'print') {
|
4136
4151
|
return;
|
4137
4152
|
}
|
4138
|
-
const
|
4139
|
-
|
4140
|
-
|
4141
|
-
|
4153
|
+
const options = event.options;
|
4154
|
+
let color = options.dataEleNormalBgColor;
|
4155
|
+
//空数据元填充颜色
|
4156
|
+
if (r.element.length === 2 && options.dataEleEmptyBgColor) {
|
4157
|
+
color = options.dataEleEmptyBgColor;
|
4142
4158
|
}
|
4143
|
-
if (
|
4144
|
-
|
4145
|
-
const bgY = event.relativePagePos.y;
|
4146
|
-
event.highlights.push(ElementUtil.getFillSvgRect(bgX, bgY, r.rect.width, r.rect.height, color));
|
4147
|
-
return;
|
4159
|
+
if (r.element.isMouseenter && options.dataEleMouseEnterBgColor) {
|
4160
|
+
color = options.dataEleMouseEnterBgColor;
|
4148
4161
|
}
|
4149
|
-
|
4150
|
-
|
4151
|
-
const renderPosMap = getCurrentParaGroupRenders(r).map(item => ({ pos: getRenderPosToDoc(item), render: item }));
|
4152
|
-
if (renderPosMap.length > 1) {
|
4153
|
-
const secondGroupRenderPos = renderPosMap[1].pos;
|
4154
|
-
if (secondGroupRenderPos.x + renderPosMap[1].render.rect.width > event.relativePagePos.x) {
|
4155
|
-
const leftPoints = [];
|
4156
|
-
const rightPoints = [];
|
4157
|
-
for (let i = 0; i < renderPosMap.length; i++) {
|
4158
|
-
const groupRender = renderPosMap[i].render;
|
4159
|
-
const groupRenderPos = renderPosMap[i].pos;
|
4160
|
-
leftPoints.push({ x: groupRenderPos.x, y: groupRenderPos.y - verOffset });
|
4161
|
-
rightPoints.push({
|
4162
|
-
x: groupRenderPos.x + groupRender.rect.width,
|
4163
|
-
y: groupRenderPos.y - verOffset
|
4164
|
-
});
|
4165
|
-
leftPoints.push({
|
4166
|
-
x: groupRenderPos.x,
|
4167
|
-
y: groupRenderPos.y + groupRender.rect.height + verOffset * 2
|
4168
|
-
});
|
4169
|
-
rightPoints.push({
|
4170
|
-
x: groupRenderPos.x + groupRender.rect.width,
|
4171
|
-
y: groupRenderPos.y + groupRender.rect.height + verOffset * 2
|
4172
|
-
});
|
4173
|
-
}
|
4174
|
-
const sharpPoints1 = CommonUtil.resharpPoints(rightPoints);
|
4175
|
-
const sharpPoints = CommonUtil.resharpPoints([...leftPoints.reverse()]);
|
4176
|
-
const path = [...sharpPoints, ...sharpPoints1, sharpPoints[0]].map((item, index) => ((index === 0) ? 'M' : "L") + item.x + " " + item.y).join(" ");
|
4177
|
-
event.highlights.push(ElementUtil.createSvgPath({
|
4178
|
-
d: path,
|
4179
|
-
stroke: color,
|
4180
|
-
fill: 'none',
|
4181
|
-
'stroke-width': 1
|
4182
|
-
}));
|
4183
|
-
return;
|
4184
|
-
}
|
4185
|
-
}
|
4186
|
-
for (let i = 0; i < renderPosMap.length; i++) {
|
4187
|
-
const currRen = renderPosMap[i];
|
4188
|
-
event.highlights.push(ElementUtil.createSvgPath({
|
4189
|
-
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`,
|
4190
|
-
stroke: '#0050b3',
|
4191
|
-
fill: 'none',
|
4192
|
-
'stroke-width': 1
|
4193
|
-
}));
|
4194
|
-
}
|
4162
|
+
if (r.element.isFocused && options.dataEleFocusedBgColor) {
|
4163
|
+
color = options.dataEleFocusedBgColor;
|
4195
4164
|
}
|
4165
|
+
//绘制背景
|
4166
|
+
const bgX = event.relativePagePos.x;
|
4167
|
+
const bgY = event.relativePagePos.y;
|
4168
|
+
event.highlights.push(ElementUtil.getFillSvgRect(bgX, bgY, r.rect.width, r.rect.height, color));
|
4169
|
+
// const canPaint = r.element.isMouseenter || r.element.isFocused;
|
4170
|
+
// if (!canPaint) {
|
4171
|
+
// return;
|
4172
|
+
// }
|
4173
|
+
// const mode = event.options.dataEleDecoratorMode;
|
4174
|
+
// if (mode === 'none') {
|
4175
|
+
// return;
|
4176
|
+
// }
|
4177
|
+
// if (mode === 'overlay') {
|
4178
|
+
// const bgX = event.relativePagePos.x;
|
4179
|
+
// const bgY = event.relativePagePos.y;
|
4180
|
+
// event.highlights.push(ElementUtil.getFillSvgRect(bgX, bgY, r.rect.width, r.rect.height, color));
|
4181
|
+
// return;
|
4182
|
+
// } else if (mode === 'outline') {
|
4183
|
+
// const verOffset = 0;
|
4184
|
+
// const renderPosMap = getCurrentParaGroupRenders(r).map(item => ({ pos: getRenderPosToDoc(item), render: item }));
|
4185
|
+
// if (renderPosMap.length > 1) {
|
4186
|
+
// const secondGroupRenderPos = renderPosMap[1].pos;
|
4187
|
+
// if (secondGroupRenderPos.x + renderPosMap[1].render.rect.width > event.relativePagePos.x) {
|
4188
|
+
// const leftPoints: Array<Position> = [];
|
4189
|
+
// const rightPoints: Array<Position> = [];
|
4190
|
+
// for (let i = 0; i < renderPosMap.length; i++) {
|
4191
|
+
// const groupRender = renderPosMap[i].render;
|
4192
|
+
// const groupRenderPos = renderPosMap[i].pos;
|
4193
|
+
// leftPoints.push({ x: groupRenderPos.x, y: groupRenderPos.y - verOffset });
|
4194
|
+
// rightPoints.push({
|
4195
|
+
// x: groupRenderPos.x + groupRender.rect.width,
|
4196
|
+
// y: groupRenderPos.y - verOffset
|
4197
|
+
// });
|
4198
|
+
// leftPoints.push({
|
4199
|
+
// x: groupRenderPos.x,
|
4200
|
+
// y: groupRenderPos.y + groupRender.rect.height + verOffset * 2
|
4201
|
+
// });
|
4202
|
+
// rightPoints.push({
|
4203
|
+
// x: groupRenderPos.x + groupRender.rect.width,
|
4204
|
+
// y: groupRenderPos.y + groupRender.rect.height + verOffset * 2
|
4205
|
+
// });
|
4206
|
+
// }
|
4207
|
+
// const sharpPoints1 = CommonUtil.resharpPoints(rightPoints);
|
4208
|
+
// const sharpPoints = CommonUtil.resharpPoints([...leftPoints.reverse()]);
|
4209
|
+
// const path = [...sharpPoints, ...sharpPoints1, sharpPoints[0]].map((item, index) => ((index === 0) ? 'M' : "L") + item.x + " " + item.y).join(" ")
|
4210
|
+
// event.highlights.push(ElementUtil.createSvgPath({
|
4211
|
+
// d: path,
|
4212
|
+
// stroke: color,
|
4213
|
+
// fill: 'none',
|
4214
|
+
// 'stroke-width': 1
|
4215
|
+
// }));
|
4216
|
+
// return;
|
4217
|
+
// }
|
4218
|
+
// }
|
4219
|
+
// for (let i = 0; i < renderPosMap.length; i++) {
|
4220
|
+
// const currRen = renderPosMap[i];
|
4221
|
+
// event.highlights.push(ElementUtil.createSvgPath({
|
4222
|
+
// 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`,
|
4223
|
+
// stroke: '#0050b3',
|
4224
|
+
// fill: 'none',
|
4225
|
+
// 'stroke-width': 1
|
4226
|
+
// }));
|
4227
|
+
// }
|
4228
|
+
// }
|
4196
4229
|
}
|
4197
4230
|
/**
|
4198
4231
|
* 渲染数据源验证错误提示框
|
@@ -4297,30 +4330,6 @@ function renderUnderWavyLine(event, r, color) {
|
|
4297
4330
|
d += Array(Math.ceil(width / 3)).fill("3,0").join(' t ');
|
4298
4331
|
const path = ElementUtil.createSvgPath({ d, fill: 'none', stroke: color });
|
4299
4332
|
event.highlights.push(path);
|
4300
|
-
}
|
4301
|
-
/**
|
4302
|
-
* 获取渲染元素相对稳当的位置
|
4303
|
-
* @param render
|
4304
|
-
* @param refPos
|
4305
|
-
*/
|
4306
|
-
function getRenderPosToDoc(render, refPos = null) {
|
4307
|
-
refPos = refPos ?? { x: 0, y: 0 };
|
4308
|
-
if (render instanceof DocumentRenderObject) {
|
4309
|
-
return refPos;
|
4310
|
-
}
|
4311
|
-
const currPos = { x: render.rect.x + refPos.x, y: render.rect.y + refPos.y };
|
4312
|
-
return getRenderPosToDoc(render.parent, currPos);
|
4313
|
-
}
|
4314
|
-
function getCurrentParaGroupRenders(r) {
|
4315
|
-
const renders = [];
|
4316
|
-
const currParaRender = ElementUtil.getParentRender(r, ParagraphRenderObject);
|
4317
|
-
for (let i = 0; i < r.element.paintRenders.length; i++) {
|
4318
|
-
const paraRender = ElementUtil.getParentRender(r.element.paintRenders[i], ParagraphRenderObject);
|
4319
|
-
if (paraRender === currParaRender) {
|
4320
|
-
renders.push(r.element.paintRenders[i]);
|
4321
|
-
}
|
4322
|
-
}
|
4323
|
-
return renders;
|
4324
4333
|
}
|
4325
4334
|
|
4326
4335
|
class DocumentBodyElement extends BlockContainerElement {
|
@@ -4362,7 +4371,7 @@ class DocumentBodyElement extends BlockContainerElement {
|
|
4362
4371
|
super.beginMeasure(data);
|
4363
4372
|
}
|
4364
4373
|
}
|
4365
|
-
class DocumentBodyRenderObject extends
|
4374
|
+
class DocumentBodyRenderObject extends MultiBlockLineRenderObject {
|
4366
4375
|
clone(cloneData = true) {
|
4367
4376
|
const cloneRender = new DocumentBodyRenderObject(this.element);
|
4368
4377
|
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
@@ -4661,7 +4670,7 @@ class TableRowElement extends BlockContainerElement {
|
|
4661
4670
|
return tr;
|
4662
4671
|
}
|
4663
4672
|
}
|
4664
|
-
class TableRowRenderObject extends
|
4673
|
+
class TableRowRenderObject extends MultiBlockLineRenderObject {
|
4665
4674
|
//被截断的行是否需要重新计算高度
|
4666
4675
|
remeasureState = true;
|
4667
4676
|
//当前行是否存在合并单元格
|
@@ -4891,9 +4900,7 @@ class TextGroupRenderObject extends LeafRenderObject {
|
|
4891
4900
|
event.highlights.push(ElementUtil.getStrokeSvgPath(path, '#000', 1));
|
4892
4901
|
}
|
4893
4902
|
//处理null-text
|
4894
|
-
if (this.element.isDecorate && this.element.disableClick && !this.element.parent)
|
4895
|
-
t.data.attrs['opacity'] = '0.58';
|
4896
|
-
}
|
4903
|
+
if (this.element.isDecorate && this.element.disableClick && !this.element.parent) ;
|
4897
4904
|
return t;
|
4898
4905
|
}
|
4899
4906
|
}
|
@@ -6160,7 +6167,7 @@ class TableElement extends BlockContainerElement {
|
|
6160
6167
|
};
|
6161
6168
|
}
|
6162
6169
|
}
|
6163
|
-
class TableRenderObject extends
|
6170
|
+
class TableRenderObject extends MultiBlockLineRenderObject {
|
6164
6171
|
setRenderWidth(maxWidth) {
|
6165
6172
|
super.setRenderWidth(maxWidth);
|
6166
6173
|
}
|
@@ -9117,33 +9124,23 @@ class DataContainerElement extends BlockContainerElement {
|
|
9117
9124
|
}
|
9118
9125
|
super.beginMeasure(data);
|
9119
9126
|
}
|
9120
|
-
serialize() {
|
9121
|
-
|
9127
|
+
serialize(viewOptions) {
|
9128
|
+
return {
|
9122
9129
|
type: this.type,
|
9123
|
-
props: {
|
9130
|
+
props: {
|
9131
|
+
...this.props.getSerializeProps(viewOptions)
|
9132
|
+
}
|
9124
9133
|
};
|
9125
|
-
if (this.props.id) {
|
9126
|
-
p['id'] = this.props.id;
|
9127
|
-
}
|
9128
|
-
if (this.props.name) {
|
9129
|
-
p['name'] = this.props.name;
|
9130
|
-
}
|
9131
|
-
if (this.props.caption) {
|
9132
|
-
p['caption'] = this.props.caption;
|
9133
|
-
}
|
9134
|
-
return p;
|
9135
9134
|
}
|
9136
9135
|
clone(data) {
|
9137
9136
|
const clone = new DataContainerElement();
|
9138
|
-
|
9139
|
-
clone.props.name = this.props.name;
|
9140
|
-
clone.props.caption = this.props.caption;
|
9137
|
+
this.props.clone(clone.props);
|
9141
9138
|
cloneElementBase(this, clone);
|
9142
9139
|
cloneChildren(this, clone, data);
|
9143
9140
|
return clone;
|
9144
9141
|
}
|
9145
9142
|
}
|
9146
|
-
class DataContainerRenderObject extends
|
9143
|
+
class DataContainerRenderObject extends MultiBlockLineRenderObject {
|
9147
9144
|
clone(cloneData = true) {
|
9148
9145
|
const cloneRender = new DataContainerRenderObject(this.element);
|
9149
9146
|
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
@@ -9168,24 +9165,21 @@ class DataContainerFactory extends ElementFactory {
|
|
9168
9165
|
return type === 'data-container';
|
9169
9166
|
}
|
9170
9167
|
createElement(data) {
|
9171
|
-
const
|
9168
|
+
const ele = new DataContainerElement();
|
9172
9169
|
const props = data.props;
|
9173
|
-
|
9174
|
-
|
9175
|
-
}
|
9176
|
-
if (props?.name) {
|
9177
|
-
element.props.name = props.name;
|
9178
|
-
}
|
9179
|
-
if (props?.caption) {
|
9180
|
-
element.props.caption = props.caption;
|
9181
|
-
}
|
9182
|
-
return element;
|
9170
|
+
ElementUtil.readEleBaseProps(ele.props, props);
|
9171
|
+
return ele;
|
9183
9172
|
}
|
9184
9173
|
}
|
9185
|
-
class DataContainerProps {
|
9186
|
-
|
9187
|
-
|
9188
|
-
|
9174
|
+
class DataContainerProps extends DataEleBaseProps {
|
9175
|
+
clone(dest) {
|
9176
|
+
const clone = dest ?? new DataContainerProps();
|
9177
|
+
super.cloneBaseProps(clone);
|
9178
|
+
}
|
9179
|
+
getSerializeProps(options) {
|
9180
|
+
const props = {};
|
9181
|
+
return this.getBaseProps(props, options);
|
9182
|
+
}
|
9189
9183
|
}
|
9190
9184
|
|
9191
9185
|
/**
|
@@ -9271,7 +9265,7 @@ class DocumentBodyPartElement extends BlockContainerElement {
|
|
9271
9265
|
return clone;
|
9272
9266
|
}
|
9273
9267
|
}
|
9274
|
-
class DocumentBodyPartRenderObject extends
|
9268
|
+
class DocumentBodyPartRenderObject extends MultiBlockLineRenderObject {
|
9275
9269
|
clone(cloneData = true) {
|
9276
9270
|
const cloneRender = new DocumentBodyPartRenderObject(this.element);
|
9277
9271
|
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
@@ -10647,10 +10641,10 @@ class ElementSerialize {
|
|
10647
10641
|
}
|
10648
10642
|
}
|
10649
10643
|
if (element.props && element.props['__attachedProperty'] && !result.props['__attachedProperty']) {
|
10650
|
-
result.props['__attachedProperty'] =
|
10644
|
+
result.props['__attachedProperty'] = this.serializeObject(element.props['__attachedProperty']);
|
10651
10645
|
}
|
10652
10646
|
if (element.attribute) {
|
10653
|
-
result['attribute'] = this.
|
10647
|
+
result['attribute'] = this.serializeObject(element.attribute);
|
10654
10648
|
}
|
10655
10649
|
return result;
|
10656
10650
|
}
|
@@ -10674,20 +10668,23 @@ class ElementSerialize {
|
|
10674
10668
|
}
|
10675
10669
|
return "";
|
10676
10670
|
}
|
10677
|
-
static
|
10678
|
-
if (
|
10679
|
-
|
10680
|
-
|
10681
|
-
|
10682
|
-
|
10671
|
+
static serializeObject(obj) {
|
10672
|
+
if (obj === null || obj === undefined) {
|
10673
|
+
return null;
|
10674
|
+
}
|
10675
|
+
const result = {};
|
10676
|
+
for (const key in obj) {
|
10677
|
+
if (obj[key] !== undefined && obj[key] !== null) {
|
10678
|
+
if (key.startsWith("__")) {
|
10679
|
+
continue;
|
10683
10680
|
}
|
10681
|
+
result[key] = obj[key];
|
10684
10682
|
}
|
10685
|
-
if (Object.keys(result).length === 0) {
|
10686
|
-
return null;
|
10687
|
-
}
|
10688
|
-
return CommonUtil.cloneValue(result);
|
10689
10683
|
}
|
10690
|
-
|
10684
|
+
if (Object.keys(result).length === 0) {
|
10685
|
+
return null;
|
10686
|
+
}
|
10687
|
+
return CommonUtil.cloneValue(result);
|
10691
10688
|
}
|
10692
10689
|
/**
|
10693
10690
|
* 获取选中的结构
|
@@ -14714,7 +14711,7 @@ class DocumentArrange {
|
|
14714
14711
|
}
|
14715
14712
|
const cloneRender = this.pMeasure.createRenderObject(render.element);
|
14716
14713
|
cloneRender.setRenderWidth(render.rect.width);
|
14717
|
-
if (render instanceof
|
14714
|
+
if (render instanceof MultiBlockLineRenderObject) {
|
14718
14715
|
let sumHeight = 0;
|
14719
14716
|
const children = [...render.getItems()];
|
14720
14717
|
let j = 0;
|
@@ -14723,7 +14720,7 @@ class DocumentArrange {
|
|
14723
14720
|
//sumHeight = ElementUtil.remeasure(cloneRender);
|
14724
14721
|
const calcBlockLineHeight = this.getBlockLineHeight(blockLine);
|
14725
14722
|
if (calcBlockLineHeight + sumHeight > limitHeight) {
|
14726
|
-
if (blockLine instanceof
|
14723
|
+
if (blockLine instanceof MultiBlockLineRenderObject) {
|
14727
14724
|
//限制的外框尺寸
|
14728
14725
|
const availHeight = limitHeight - sumHeight;
|
14729
14726
|
//限制的内框尺寸
|
@@ -15433,9 +15430,12 @@ class DocumentEvent {
|
|
15433
15430
|
},
|
15434
15431
|
mouseup: (evt) => {
|
15435
15432
|
this.mouseup(evt, ElementUtil.getMousePos(evt, scale));
|
15433
|
+
this.mouseClickHandle(evt);
|
15436
15434
|
},
|
15437
15435
|
click: (evt) => {
|
15438
|
-
|
15436
|
+
//nulltext 不触发 click 事件,暂且这么处理
|
15437
|
+
//移到 mouseup 事件中处理
|
15438
|
+
//this.mouseClickHandle(evt);
|
15439
15439
|
},
|
15440
15440
|
mousemove: (evt) => {
|
15441
15441
|
this.mousemove(evt, ElementUtil.getMousePos(evt, scale));
|
@@ -18729,103 +18729,56 @@ function getFocusTextSegment(selection) {
|
|
18729
18729
|
let { startControl: element, startOffset: offset } = selection;
|
18730
18730
|
if (!(element instanceof TextGroupElement))
|
18731
18731
|
return false;
|
18732
|
-
if (!supportSegment())
|
18733
|
-
return false;
|
18734
18732
|
const focusEle = element;
|
18735
|
-
|
18736
|
-
|
18737
|
-
|
18738
|
-
|
18739
|
-
const
|
18740
|
-
const
|
18741
|
-
|
18742
|
-
|
18743
|
-
|
18744
|
-
}
|
18745
|
-
if (curr.item === focusEle) {
|
18746
|
-
prev.index += offset;
|
18747
|
-
prev.completed = true;
|
18748
|
-
}
|
18749
|
-
else {
|
18750
|
-
prev.index += curr.item.textMeasures.length;
|
18751
|
-
}
|
18752
|
-
return prev;
|
18753
|
-
}, { completed: false, index: 0, text: '' });
|
18754
|
-
const { index: hitIndex, len: hitLen } = getHitSegment(text, index);
|
18755
|
-
const matchSegment = sortItems.filter(item => (item.index <= hitIndex && item.endIndex > hitIndex) || (item.index <= hitIndex + hitLen && item.endIndex > hitIndex + hitLen));
|
18756
|
-
const startSegment = matchSegment[0];
|
18757
|
-
const endSegment = matchSegment[matchSegment.length - 1];
|
18758
|
-
const startOffset = hitIndex - startSegment.index;
|
18759
|
-
const endOffset = hitIndex + hitLen - endSegment.index;
|
18760
|
-
const newRange = new SelectionRange();
|
18761
|
-
newRange.setStart(startSegment.item, startOffset);
|
18762
|
-
newRange.setEnd(endSegment.item, endOffset);
|
18763
|
-
selection.addRange(newRange);
|
18733
|
+
const focusText = focusEle.text;
|
18734
|
+
if (!focusText) {
|
18735
|
+
return false;
|
18736
|
+
}
|
18737
|
+
const [start, end] = tokenize(focusText, offset);
|
18738
|
+
const range = new SelectionRange();
|
18739
|
+
range.setStart(focusEle, start);
|
18740
|
+
range.setEnd(focusEle, end + 1);
|
18741
|
+
selection.addRange(range);
|
18764
18742
|
return true;
|
18765
18743
|
}
|
18766
|
-
|
18767
|
-
|
18768
|
-
|
18769
|
-
|
18770
|
-
|
18771
|
-
|
18772
|
-
|
18773
|
-
const
|
18774
|
-
|
18775
|
-
|
18776
|
-
|
18777
|
-
|
18778
|
-
|
18779
|
-
|
18780
|
-
|
18781
|
-
|
18782
|
-
|
18783
|
-
|
18784
|
-
|
18744
|
+
function tokenize(text, index) {
|
18745
|
+
if (text.length === 0) {
|
18746
|
+
return [0, 0]; // 处理空字符串的情况
|
18747
|
+
}
|
18748
|
+
const isChinese = (char) => {
|
18749
|
+
return /^[\u4e00-\u9fa5]+$/.test(char);
|
18750
|
+
};
|
18751
|
+
const isEnglish = (char) => {
|
18752
|
+
return /^[a-zA-Z]+$/.test(char);
|
18753
|
+
};
|
18754
|
+
const isNumeric = (char) => {
|
18755
|
+
return /^[0-9]+$/.test(char);
|
18756
|
+
};
|
18757
|
+
let start = index;
|
18758
|
+
let end = index;
|
18759
|
+
// 向左查找开始位置
|
18760
|
+
while (start > 0) {
|
18761
|
+
if ((isChinese(text[start]) && isChinese(text[start - 1])) ||
|
18762
|
+
(isEnglish(text[start]) && isEnglish(text[start - 1])) ||
|
18763
|
+
(isNumeric(text[start]) && isNumeric(text[start - 1]))) {
|
18764
|
+
start--;
|
18765
|
+
}
|
18766
|
+
else {
|
18767
|
+
break;
|
18785
18768
|
}
|
18786
|
-
index += currLen;
|
18787
18769
|
}
|
18788
|
-
|
18789
|
-
|
18790
|
-
|
18791
|
-
|
18792
|
-
|
18793
|
-
|
18794
|
-
|
18795
|
-
|
18796
|
-
|
18797
|
-
|
18798
|
-
let index = 0;
|
18799
|
-
const sortItems = [];
|
18800
|
-
for (let i = 0; i < texts.length; i++) {
|
18801
|
-
const item = texts[i];
|
18802
|
-
const sortData = {
|
18803
|
-
len: item.textMeasures.length,
|
18804
|
-
index,
|
18805
|
-
endIndex: index + item.textMeasures.length,
|
18806
|
-
item,
|
18807
|
-
text: item.text
|
18808
|
-
};
|
18809
|
-
sortItems.push(sortData);
|
18810
|
-
index += sortData.len;
|
18770
|
+
// 向右查找结束位置
|
18771
|
+
while (end < text.length - 1) {
|
18772
|
+
if ((isChinese(text[end]) && isChinese(text[end + 1])) ||
|
18773
|
+
(isEnglish(text[end]) && isEnglish(text[end + 1])) ||
|
18774
|
+
(isNumeric(text[end]) && isNumeric(text[end + 1]))) {
|
18775
|
+
end++;
|
18776
|
+
}
|
18777
|
+
else {
|
18778
|
+
break;
|
18779
|
+
}
|
18811
18780
|
}
|
18812
|
-
return
|
18813
|
-
}
|
18814
|
-
/**
|
18815
|
-
* 获取指定方向上连续的字符
|
18816
|
-
* @param element
|
18817
|
-
* @param prev
|
18818
|
-
*/
|
18819
|
-
function getConsecutiveTextsByDirection(element, prev = true) {
|
18820
|
-
let prevText = element;
|
18821
|
-
const prevTexts = [];
|
18822
|
-
const func = prev ? ElementUtil.getPrevSiblingElement : ElementUtil.getNextSiblingElement;
|
18823
|
-
const addItem = prev ? prevTexts.unshift : prevTexts.push;
|
18824
|
-
while ((prevText = func(prevText)) && prevText instanceof TextGroupElement) {
|
18825
|
-
//addItem(prevText);
|
18826
|
-
addItem.apply(prevTexts, [prevText]);
|
18827
|
-
}
|
18828
|
-
return prevTexts;
|
18781
|
+
return [start, end];
|
18829
18782
|
}
|
18830
18783
|
|
18831
18784
|
/**
|
@@ -19390,7 +19343,7 @@ class DocumentSvg {
|
|
19390
19343
|
ns: 'http://www.w3.org/2000/svg',
|
19391
19344
|
attrs: {
|
19392
19345
|
stroke: 'none',
|
19393
|
-
fill: item.color ??
|
19346
|
+
fill: item.color ?? this.viewOptions.selectionColor,
|
19394
19347
|
'paint-order': 'stroke fill markers',
|
19395
19348
|
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`,
|
19396
19349
|
'fill-opacity': '0.5'
|
@@ -20785,6 +20738,7 @@ class DocEditor {
|
|
20785
20738
|
ssChanged && this.documentEvent.invokeCursor(this.selectionState.startControl);
|
20786
20739
|
this.documentSelection.clearSnapshot();
|
20787
20740
|
this.documentSelection.takeSnapshot();
|
20741
|
+
return ssChanged;
|
20788
20742
|
}
|
20789
20743
|
/**
|
20790
20744
|
* 根据当前选区,更新待输入文本字体信息
|
@@ -20824,6 +20778,7 @@ class DocEditor {
|
|
20824
20778
|
this.selectionState.cursorPos = cursorRect;
|
20825
20779
|
const abPos = ElementUtil.cloneRect(cursorRect);
|
20826
20780
|
this.setCursorPosition(abPos);
|
20781
|
+
this.setCursorVisibility(true);
|
20827
20782
|
//this.documentEvent.invokeCursor(startControl);
|
20828
20783
|
return;
|
20829
20784
|
}
|
@@ -20857,7 +20812,7 @@ class DocEditor {
|
|
20857
20812
|
setCursorVisibility(visibility) {
|
20858
20813
|
if (visibility) {
|
20859
20814
|
//this.editInput.style.removeProperty('display');
|
20860
|
-
this.editInput.focus();
|
20815
|
+
this.editInput.focus({ preventScroll: true });
|
20861
20816
|
}
|
20862
20817
|
}
|
20863
20818
|
hiddenInput(reset = true, pos = null) {
|
@@ -20879,7 +20834,6 @@ class DocEditor {
|
|
20879
20834
|
this.editInput.style.height = position.height + 'px';
|
20880
20835
|
this.editInput.style.width = "1.6px";
|
20881
20836
|
this.editInput.readOnly = false;
|
20882
|
-
this.setCursorVisibility(true);
|
20883
20837
|
//判断光标位置是否被可见,如果不可见,需要将其设置到可见区域
|
20884
20838
|
//TODO:暂时不做处理
|
20885
20839
|
//this.setCursorInputStatus();
|
@@ -20915,7 +20869,7 @@ class DocEditor {
|
|
20915
20869
|
* 文档点击事件
|
20916
20870
|
*/
|
20917
20871
|
docClickHandle(evt) {
|
20918
|
-
this.hiddenInput();
|
20872
|
+
//this.hiddenInput();
|
20919
20873
|
// this.setCursor();
|
20920
20874
|
// this.updateSelection();
|
20921
20875
|
this.refreshDocument();
|
@@ -21215,20 +21169,20 @@ class DocEditor {
|
|
21215
21169
|
const startControl = this.selectionState.startControl;
|
21216
21170
|
if (startControl instanceof TextGroupElement) {
|
21217
21171
|
const selectedStyle = startControl.props.clone(null);
|
21218
|
-
const
|
21219
|
-
this.viewOptions.
|
21172
|
+
const selectionColor = this.viewOptions.selectionColor;
|
21173
|
+
this.viewOptions.selectionColor = "rgba(0,58,140,0.8)";
|
21220
21174
|
const cancelToken = {};
|
21221
21175
|
const sub = this.onClickEvent.subscribe(() => {
|
21222
21176
|
sub.unsubscribe();
|
21223
21177
|
this.setTextFormat(selectedStyle);
|
21224
|
-
this.viewOptions.
|
21178
|
+
this.viewOptions.selectionColor = selectionColor;
|
21225
21179
|
if (cancelToken.onFinish) {
|
21226
21180
|
cancelToken.onFinish(null);
|
21227
21181
|
}
|
21228
21182
|
});
|
21229
21183
|
cancelToken.cancel = () => {
|
21230
21184
|
sub.unsubscribe();
|
21231
|
-
this.viewOptions.
|
21185
|
+
this.viewOptions.selectionColor = selectionColor;
|
21232
21186
|
};
|
21233
21187
|
return cancelToken;
|
21234
21188
|
}
|
@@ -21989,7 +21943,7 @@ class DocEditor {
|
|
21989
21943
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
21990
21944
|
}
|
21991
21945
|
version() {
|
21992
|
-
return "2.2.
|
21946
|
+
return "2.2.8";
|
21993
21947
|
}
|
21994
21948
|
switchPageHeaderEditor() {
|
21995
21949
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|
@@ -27852,7 +27806,7 @@ exports.LostCursorEvent = LostCursorEvent;
|
|
27852
27806
|
exports.MarginProps = MarginProps;
|
27853
27807
|
exports.MouseElementEvent = MouseElementEvent;
|
27854
27808
|
exports.MousedownElementEvent = MousedownElementEvent;
|
27855
|
-
exports.
|
27809
|
+
exports.MultiBlockLineRenderObject = MultiBlockLineRenderObject;
|
27856
27810
|
exports.OnceSubject = OnceSubject;
|
27857
27811
|
exports.PSymbolElement = PSymbolElement;
|
27858
27812
|
exports.PSymbolRenderObject = PSymbolRenderObject;
|