@hailin-zheng/editor-core 1.1.17 → 1.1.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 +170 -94
- package/index-cjs.js.map +1 -1
- package/index.js +168 -95
- package/index.js.map +1 -1
- package/med_editor/framework/document-change.d.ts +2 -1
- package/med_editor/framework/document-event.d.ts +1 -1
- package/med_editor/framework/element-define.d.ts +4 -0
- package/med_editor/framework/element-event-define.d.ts +4 -1
- package/med_editor/framework/element-props.d.ts +10 -2
- package/med_editor/framework/impl/text/text-impl.d.ts +2 -1
- package/med_editor/framework/paragraph-arrange.d.ts +4 -1
- package/med_editor/framework/render-context.d.ts +12 -2
- package/med_editor/texteditor.d.ts +4 -5
- package/package.json +1 -1
package/index-cjs.js
CHANGED
@@ -78,6 +78,9 @@ class ContentMenuItem {
|
|
78
78
|
*/
|
79
79
|
class MouseElementEvent extends ElementEvent {
|
80
80
|
}
|
81
|
+
class InputElementEvent extends ElementEvent {
|
82
|
+
data;
|
83
|
+
}
|
81
84
|
class MousedownElementEvent extends ElementEvent {
|
82
85
|
}
|
83
86
|
class KeyboradElementEvent extends ElementEvent {
|
@@ -1466,7 +1469,7 @@ class ViewOptions {
|
|
1466
1469
|
viewBackcolor = 'rgb(230,230,230)';
|
1467
1470
|
paraSymbolColor = 'rgb(128,128,128)';
|
1468
1471
|
dataGroupColor = 'rgb(0,80,179)';
|
1469
|
-
defaultLineHeight = 1
|
1472
|
+
defaultLineHeight = 1;
|
1470
1473
|
//新增-留痕块文本颜色
|
1471
1474
|
trackInsColor = '#ff4d4f';
|
1472
1475
|
//删除-留痕块文本颜色
|
@@ -1801,7 +1804,7 @@ class ParagraphProps extends INotifyPropertyChanged {
|
|
1801
1804
|
//textProps!: TextProps;
|
1802
1805
|
indent = 0;
|
1803
1806
|
hanging = 0;
|
1804
|
-
lineHeight = 1
|
1807
|
+
lineHeight = 1;
|
1805
1808
|
textAlign = 'left';
|
1806
1809
|
numberType = exports.ParagraphNumberType.none;
|
1807
1810
|
//段前距
|
@@ -1901,6 +1904,8 @@ class CheckBoxProps extends INotifyPropertyChanged {
|
|
1901
1904
|
isChecked;
|
1902
1905
|
//用于复选框分组
|
1903
1906
|
groupName;
|
1907
|
+
trueChar = '√';
|
1908
|
+
falseChar = '×';
|
1904
1909
|
clone(dest) {
|
1905
1910
|
const clone = dest ?? new CheckBoxProps();
|
1906
1911
|
super.cloneAttachedProperty(clone);
|
@@ -2076,7 +2081,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
|
|
2076
2081
|
editable;
|
2077
2082
|
deleteable;
|
2078
2083
|
minLength;
|
2079
|
-
type;
|
2080
2084
|
underline;
|
2081
2085
|
expression;
|
2082
2086
|
hidden;
|
@@ -2095,7 +2099,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
|
|
2095
2099
|
target.secretBrowse = source.secretBrowse;
|
2096
2100
|
target.printable = source.printable;
|
2097
2101
|
target.minLength = source.minLength;
|
2098
|
-
target.type = source.type;
|
2099
2102
|
target.underline = source.underline;
|
2100
2103
|
target.expression = source.expression;
|
2101
2104
|
target.hidden = source.hidden;
|
@@ -2107,7 +2110,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
|
|
2107
2110
|
props["id"] = this.id;
|
2108
2111
|
props["name"] = this.name;
|
2109
2112
|
props["fieldName"] = this.fieldName;
|
2110
|
-
props["type"] = this.type;
|
2111
2113
|
if (this.caption) {
|
2112
2114
|
props["caption"] = this.caption;
|
2113
2115
|
}
|
@@ -2147,7 +2149,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
|
|
2147
2149
|
class DataEleBaseTextProps extends DataEleBaseProps {
|
2148
2150
|
constructor() {
|
2149
2151
|
super();
|
2150
|
-
super.type = 'text';
|
2151
2152
|
}
|
2152
2153
|
valueTextProps;
|
2153
2154
|
nullText;
|
@@ -2163,7 +2164,6 @@ class DataEleBaseTextProps extends DataEleBaseProps {
|
|
2163
2164
|
}
|
2164
2165
|
getSerializeProps(options) {
|
2165
2166
|
const props = {
|
2166
|
-
type: this.type,
|
2167
2167
|
valueTextProps: this.valueTextProps.getSerializeProps(options),
|
2168
2168
|
nullText: this.nullText,
|
2169
2169
|
nullTextProps: this.nullTextProps.getSerializeProps(options)
|
@@ -2193,7 +2193,6 @@ class DataEleBaseTextProps extends DataEleBaseProps {
|
|
2193
2193
|
class DataEleListProps extends DataEleBaseTextProps {
|
2194
2194
|
constructor() {
|
2195
2195
|
super();
|
2196
|
-
super.type = 'droplist';
|
2197
2196
|
}
|
2198
2197
|
options = [];
|
2199
2198
|
dropDownStyle;
|
@@ -2259,16 +2258,23 @@ class CommProps extends INotifyPropertyChanged {
|
|
2259
2258
|
};
|
2260
2259
|
}
|
2261
2260
|
}
|
2261
|
+
const trueChar = '✓';
|
2262
|
+
const falseChar = '×';
|
2262
2263
|
class DataEleCheckProps extends DataEleBaseProps {
|
2263
2264
|
constructor() {
|
2264
2265
|
super();
|
2265
|
-
super.type = 'check';
|
2266
2266
|
}
|
2267
|
+
border = true;
|
2267
2268
|
size;
|
2268
2269
|
checked;
|
2269
2270
|
checkedValue = '';
|
2270
2271
|
groupName;
|
2271
2272
|
multiSelect = false;
|
2273
|
+
drawStateChar = false;
|
2274
|
+
trueChar = trueChar;
|
2275
|
+
falseChar = falseChar;
|
2276
|
+
trueStateColor = '#f00000';
|
2277
|
+
falseStateColor = '#000000';
|
2272
2278
|
clone(dest) {
|
2273
2279
|
const clone = dest ?? new DataEleCheckProps();
|
2274
2280
|
super.cloneBaseProps(clone);
|
@@ -2277,6 +2283,12 @@ class DataEleCheckProps extends DataEleBaseProps {
|
|
2277
2283
|
clone.groupName = this.groupName;
|
2278
2284
|
clone.multiSelect = this.multiSelect;
|
2279
2285
|
clone.checkedValue = this.checkedValue;
|
2286
|
+
clone.drawStateChar = this.drawStateChar;
|
2287
|
+
clone.trueChar = this.trueChar;
|
2288
|
+
clone.falseChar = this.falseChar;
|
2289
|
+
clone.border = this.border;
|
2290
|
+
clone.trueStateColor = this.trueStateColor;
|
2291
|
+
clone.falseStateColor = this.falseStateColor;
|
2280
2292
|
return clone;
|
2281
2293
|
}
|
2282
2294
|
getSerializeProps(options) {
|
@@ -2285,8 +2297,26 @@ class DataEleCheckProps extends DataEleBaseProps {
|
|
2285
2297
|
size: this.size,
|
2286
2298
|
groupName: this.groupName,
|
2287
2299
|
multiSelect: this.multiSelect,
|
2288
|
-
checkedValue: this.checkedValue
|
2300
|
+
checkedValue: this.checkedValue,
|
2289
2301
|
};
|
2302
|
+
if (this.drawStateChar) {
|
2303
|
+
props.drawStateChar = this.drawStateChar;
|
2304
|
+
}
|
2305
|
+
if (this.trueChar !== trueChar) {
|
2306
|
+
props.trueChar = this.trueChar;
|
2307
|
+
}
|
2308
|
+
if (this.falseChar !== falseChar) {
|
2309
|
+
props.falseChar = this.falseChar;
|
2310
|
+
}
|
2311
|
+
if (this.border) {
|
2312
|
+
props.border = this.border;
|
2313
|
+
}
|
2314
|
+
if (this.trueStateColor !== '#f00000') {
|
2315
|
+
props.trueStateColor = this.trueStateColor;
|
2316
|
+
}
|
2317
|
+
if (this.falseStateColor !== '#000000') {
|
2318
|
+
props.falseStateColor = this.falseStateColor;
|
2319
|
+
}
|
2290
2320
|
this.getBaseProps(props, options);
|
2291
2321
|
return props;
|
2292
2322
|
}
|
@@ -2297,12 +2327,17 @@ class DataEleCheckProps extends DataEleBaseProps {
|
|
2297
2327
|
this.groupName = props.groupName;
|
2298
2328
|
this.multiSelect = props.multiSelect;
|
2299
2329
|
this.checkedValue = props.checkedValue;
|
2330
|
+
this.drawStateChar = props.drawStateChar;
|
2331
|
+
this.trueChar = props.trueChar;
|
2332
|
+
this.falseChar = props.falseChar;
|
2333
|
+
this.trueStateColor = props.trueStateColor;
|
2334
|
+
this.falseStateColor = props.falseStateColor;
|
2335
|
+
this.border = props.border;
|
2300
2336
|
}
|
2301
2337
|
}
|
2302
2338
|
class DataEleImageProps extends DataEleBaseProps {
|
2303
2339
|
constructor() {
|
2304
2340
|
super();
|
2305
|
-
super.type = 'img';
|
2306
2341
|
}
|
2307
2342
|
width;
|
2308
2343
|
height;
|
@@ -2336,10 +2371,6 @@ class DataEleImageProps extends DataEleBaseProps {
|
|
2336
2371
|
}
|
2337
2372
|
}
|
2338
2373
|
class DataEleDateProps extends DataEleBaseTextProps {
|
2339
|
-
constructor() {
|
2340
|
-
super();
|
2341
|
-
super.type = 'date';
|
2342
|
-
}
|
2343
2374
|
minValue;
|
2344
2375
|
maxValue;
|
2345
2376
|
format;
|
@@ -3166,7 +3197,7 @@ class DataElementRenderObject extends InlineGroupRenderObject {
|
|
3166
3197
|
bgColor = viewOptions.dataEleErrorBgColor;
|
3167
3198
|
}
|
3168
3199
|
if (bgColor) {
|
3169
|
-
render.overlaysContext.fillRect(position.x, position.y
|
3200
|
+
render.overlaysContext.fillRect(position.x, position.y, this.rect.width, this.rect.height, bgColor);
|
3170
3201
|
}
|
3171
3202
|
if (this.element.props.secretBrowse && viewOptions.secretBrowse) {
|
3172
3203
|
render.contentContext.ctx.filter = "blur(10px)";
|
@@ -3203,7 +3234,7 @@ class DataElementRenderObject extends InlineGroupRenderObject {
|
|
3203
3234
|
textProps.fontSize = 16;
|
3204
3235
|
textProps.fontName = viewOptions.defaultFontName;
|
3205
3236
|
textProps.color = '#fff';
|
3206
|
-
const titleWidth = render.contentContext.
|
3237
|
+
const titleWidth = render.contentContext.measureTextWidth(caption, textProps);
|
3207
3238
|
const x = position.x;
|
3208
3239
|
const y = position.y - 20;
|
3209
3240
|
render.contentContext.fillRect(x, y, titleWidth + 10, 20, 'blue');
|
@@ -4086,8 +4117,8 @@ class DocumentContainerRender extends BlockContainerRenderObject {
|
|
4086
4117
|
}
|
4087
4118
|
|
4088
4119
|
class TextGroupElement extends LeafElement {
|
4089
|
-
//props: TextProps;
|
4090
4120
|
textMeasures = [];
|
4121
|
+
fontBoundingBox;
|
4091
4122
|
isMeasure = false;
|
4092
4123
|
constructor() {
|
4093
4124
|
super('text');
|
@@ -4127,6 +4158,7 @@ class TextGroupElement extends LeafElement {
|
|
4127
4158
|
createRenderObject(data) {
|
4128
4159
|
if (!this.isMeasure || this.modifyFlag !== exports.ModifyFlag.None || !this.cacheRender) {
|
4129
4160
|
data.renderCtx.contentContext.measureTextUnits(this.textMeasures, this.props);
|
4161
|
+
this.fontBoundingBox = data.renderCtx.contentContext.measureTextMetrics(this.props.getFont());
|
4130
4162
|
this.isMeasure = true;
|
4131
4163
|
}
|
4132
4164
|
const render = new TextGroupRenderObject(this);
|
@@ -4200,10 +4232,7 @@ class TextGroupRenderObject extends LeafRenderObject {
|
|
4200
4232
|
if (this.element.props.border) {
|
4201
4233
|
render.contentContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height);
|
4202
4234
|
}
|
4203
|
-
render.contentContext.drawTextUnits(this, position.x, position.y);
|
4204
|
-
// if (this.element.isMouseenter) {
|
4205
|
-
// ctx.overlaysContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height, CommonUtil.randomColor());
|
4206
|
-
// }
|
4235
|
+
render.contentContext.drawTextUnits(this, position.x, position.y, this.element.fontBoundingBox.fontBoundingBoxAscent);
|
4207
4236
|
}
|
4208
4237
|
constructor(element) {
|
4209
4238
|
super(element);
|
@@ -4222,7 +4251,7 @@ class TextGroupRenderObject extends LeafRenderObject {
|
|
4222
4251
|
}
|
4223
4252
|
measure() {
|
4224
4253
|
this.rect.width = this.textMeasures.reduce((prev, curr) => prev + curr.actualSize, 0);
|
4225
|
-
this.rect.height = this.element.
|
4254
|
+
this.rect.height = this.element.fontBoundingBox.fontBoundingBoxAscent + this.element.fontBoundingBox.fontBoundingBoxDescent;
|
4226
4255
|
}
|
4227
4256
|
}
|
4228
4257
|
class TextGroupFactory extends ElementFactory {
|
@@ -5619,10 +5648,15 @@ class TableUtil {
|
|
5619
5648
|
}
|
5620
5649
|
const remainWidth = tbWidth - sum;
|
5621
5650
|
const ratio = remainWidth / percentSum;
|
5651
|
+
let count = 0;
|
5622
5652
|
for (let i = 0; i < percentCols.length; i++) {
|
5623
5653
|
const width = percentCols[i];
|
5624
5654
|
if (typeof width === 'string') {
|
5625
5655
|
percentCols[i] = Math.floor(Number.parseFloat(width) * ratio);
|
5656
|
+
if (i === percentCols.length - 1) {
|
5657
|
+
percentCols[i] = remainWidth - count;
|
5658
|
+
}
|
5659
|
+
count += percentCols[i];
|
5626
5660
|
}
|
5627
5661
|
}
|
5628
5662
|
return percentCols;
|
@@ -6266,7 +6300,6 @@ class ElementUtil {
|
|
6266
6300
|
dest.secretBrowse = props.secretBrowse;
|
6267
6301
|
dest.deleteable = props.deleteable;
|
6268
6302
|
dest.underline = props.underline;
|
6269
|
-
dest.type = props.type;
|
6270
6303
|
dest.expression = props.expression;
|
6271
6304
|
dest.hidden = props.hidden;
|
6272
6305
|
return dest;
|
@@ -6337,9 +6370,9 @@ class ElementUtil {
|
|
6337
6370
|
}
|
6338
6371
|
static remeasureTableRow(rowRender, foreceColIndex = -1) {
|
6339
6372
|
const rowEle = rowRender.element;
|
6340
|
-
let maxCellHeight = rowEle.props.minHeight >
|
6373
|
+
let maxCellHeight = rowEle.props.minHeight > 20 ? rowEle.props.minHeight : 20;
|
6341
6374
|
//限制行最小高度
|
6342
|
-
maxCellHeight = maxCellHeight <
|
6375
|
+
maxCellHeight = maxCellHeight < 20 ? 20 : maxCellHeight;
|
6343
6376
|
//获取行内非纵向合并单元格的最高单元格高度
|
6344
6377
|
for (let i = 0; i < rowRender.length; i++) {
|
6345
6378
|
const cellRender = rowRender.getChild(i);
|
@@ -7799,7 +7832,7 @@ class PaintContent {
|
|
7799
7832
|
this.ctx.fill();
|
7800
7833
|
this.ctx.restore();
|
7801
7834
|
}
|
7802
|
-
drawTextUnits(textGroupRender, x, y) {
|
7835
|
+
drawTextUnits(textGroupRender, x, y, baseLine) {
|
7803
7836
|
const textEle = textGroupRender.element;
|
7804
7837
|
const textProps = textEle.props;
|
7805
7838
|
const { width, height } = textGroupRender.rect;
|
@@ -7822,12 +7855,10 @@ class PaintContent {
|
|
7822
7855
|
this.drawHoriLine(x, y, width, textProps.color, 1);
|
7823
7856
|
}
|
7824
7857
|
let horX = 0;
|
7825
|
-
let vertHeight =
|
7858
|
+
let vertHeight = baseLine;
|
7826
7859
|
if (textProps.vertAlign === 'superscript') {
|
7827
7860
|
//到top
|
7828
7861
|
vertHeight -= textProps.fontSize * 2 / 5;
|
7829
|
-
//top在向上收缩 -top行间距
|
7830
|
-
//vertHeight -= textProps.fontSize * this.getParaLineHeight(textEle) / 20
|
7831
7862
|
}
|
7832
7863
|
for (let i = 0; i < textGroupRender.textMeasures.length; i++) {
|
7833
7864
|
const unit = textGroupRender.textMeasures[i];
|
@@ -7836,6 +7867,15 @@ class PaintContent {
|
|
7836
7867
|
}
|
7837
7868
|
this.ctx.restore();
|
7838
7869
|
}
|
7870
|
+
drawText2(str, font, color, x, y, width, height) {
|
7871
|
+
const textMetrics = this.measureTextMetrics(font, str);
|
7872
|
+
this.ctx.save();
|
7873
|
+
this.ctx.fillStyle = color;
|
7874
|
+
this.ctx.font = font;
|
7875
|
+
let vertHeight = textMetrics.actualBoundingBoxAscent;
|
7876
|
+
this.ctx.fillText(str, x + (width - (textMetrics.actualBoundingBoxLeft + textMetrics.actualBoundingBoxRight)) / 2 - textMetrics.actualBoundingBoxLeft, y + vertHeight + (height - (textMetrics.actualBoundingBoxAscent + textMetrics.actualBoundingBoxDescent)) / 2);
|
7877
|
+
this.ctx.restore();
|
7878
|
+
}
|
7839
7879
|
getParaLineHeight(textEle) {
|
7840
7880
|
const para = ElementUtil.getParentByType(textEle, ParagraphElement);
|
7841
7881
|
if (!para) {
|
@@ -7846,10 +7886,23 @@ class PaintContent {
|
|
7846
7886
|
measureText(text, textProps) {
|
7847
7887
|
this.ctx.fillStyle = textProps.color;
|
7848
7888
|
this.ctx.font = textProps.getFont();
|
7849
|
-
const
|
7850
|
-
return { width:
|
7889
|
+
const { width, fontBoundingBoxDescent, fontBoundingBoxAscent } = this.ctx.measureText(text);
|
7890
|
+
return { width: width, height: fontBoundingBoxAscent + fontBoundingBoxDescent };
|
7851
7891
|
}
|
7852
|
-
|
7892
|
+
measureTextMetrics(font, str = 'M') {
|
7893
|
+
this.ctx.font = font;
|
7894
|
+
const textMetrics = this.ctx.measureText(str);
|
7895
|
+
return {
|
7896
|
+
fontBoundingBoxAscent: textMetrics.fontBoundingBoxAscent,
|
7897
|
+
fontBoundingBoxDescent: textMetrics.fontBoundingBoxDescent,
|
7898
|
+
actualBoundingBoxAscent: textMetrics.actualBoundingBoxAscent,
|
7899
|
+
actualBoundingBoxDescent: textMetrics.actualBoundingBoxDescent,
|
7900
|
+
actualBoundingBoxLeft: textMetrics.actualBoundingBoxLeft,
|
7901
|
+
actualBoundingBoxRight: textMetrics.actualBoundingBoxRight,
|
7902
|
+
width: textMetrics.width
|
7903
|
+
};
|
7904
|
+
}
|
7905
|
+
measureTextWidth(text, font) {
|
7853
7906
|
this.ctx.font = font.fontSize + 'px ' + font.fontName;
|
7854
7907
|
return this.ctx.measureText(text).width;
|
7855
7908
|
}
|
@@ -8684,11 +8737,22 @@ class DataElementCheckRenderObject extends LeafRenderObject {
|
|
8684
8737
|
render(e) {
|
8685
8738
|
const { render, position } = e;
|
8686
8739
|
const element = this.element;
|
8687
|
-
if (
|
8688
|
-
|
8740
|
+
if (element.props.drawStateChar) {
|
8741
|
+
const font = `${element.props.size - 2}px 微软雅黑`;
|
8742
|
+
const str = element.props.checked ? element.props.trueChar : element.props.falseChar;
|
8743
|
+
const color = element.props.checked ? element.props.trueStateColor : element.props.falseStateColor;
|
8744
|
+
e.render.contentContext.drawText2(str, font, color, position.x, position.y, element.props.size, element.props.size);
|
8745
|
+
if (element.props.border) {
|
8746
|
+
e.render.contentContext.strokeRect(position.x + 2, position.y, element.props.size, element.props.size);
|
8747
|
+
}
|
8689
8748
|
}
|
8690
8749
|
else {
|
8691
|
-
|
8750
|
+
if (element.props.multiSelect) {
|
8751
|
+
render.contentContext.drawCheckBox(position.x + 2, position.y, element.props.size, element.props.size, element.props.checked);
|
8752
|
+
}
|
8753
|
+
else {
|
8754
|
+
render.contentContext.drawRadioBox(position.x + 2, position.y, element.props.size, element.props.size, element.props.checked);
|
8755
|
+
}
|
8692
8756
|
}
|
8693
8757
|
}
|
8694
8758
|
}
|
@@ -8705,15 +8769,15 @@ class DataElementCheckFactory extends ElementFactory {
|
|
8705
8769
|
createDataEleProps(dest, props) {
|
8706
8770
|
const dataEleProps = dest;
|
8707
8771
|
ElementUtil.readEleBaseProps(dataEleProps, props);
|
8708
|
-
//dataEleProps.id = props.id ?? nanoid(5);
|
8709
|
-
//dataEleProps.name = props.name;
|
8710
|
-
//dataEleProps.caption = props.caption;
|
8711
|
-
//dataEleProps.type = props.type;
|
8712
8772
|
dataEleProps.checked = props.checked;
|
8713
8773
|
dataEleProps.size = props.size;
|
8714
8774
|
dataEleProps.groupName = props.groupName;
|
8715
8775
|
dataEleProps.multiSelect = props.multiSelect ?? false;
|
8716
8776
|
dataEleProps.checkedValue = props.checkedValue;
|
8777
|
+
dataEleProps.drawStateChar = props.drawStateChar ?? false;
|
8778
|
+
dataEleProps.trueChar = props.trueChar ?? trueChar;
|
8779
|
+
dataEleProps.falseChar = props.falseChar ?? falseChar;
|
8780
|
+
dataEleProps.border = props.border ?? true;
|
8717
8781
|
return dataEleProps;
|
8718
8782
|
}
|
8719
8783
|
}
|
@@ -11345,6 +11409,7 @@ class ParagraphMeasure {
|
|
11345
11409
|
}
|
11346
11410
|
},
|
11347
11411
|
parent: null,
|
11412
|
+
isCloseToBody,
|
11348
11413
|
applyNewLine() {
|
11349
11414
|
createInnerLineFunc();
|
11350
11415
|
},
|
@@ -11530,6 +11595,7 @@ class ParagraphMeasure {
|
|
11530
11595
|
parentLine.updateHeight(child);
|
11531
11596
|
},
|
11532
11597
|
parent: parentLine,
|
11598
|
+
isCloseToBody: parentLine.isCloseToBody,
|
11533
11599
|
applyNewLine() {
|
11534
11600
|
parentLine.applyNewLine();
|
11535
11601
|
render = ele.createRenderObject({ options, renderCtx });
|
@@ -11591,7 +11657,7 @@ class ParagraphMeasure {
|
|
11591
11657
|
arrangeLeafRender(parentLine, render) {
|
11592
11658
|
if (parentLine.lineWidth() + render.rect.width > parentLine.limitWidth) {
|
11593
11659
|
if (render instanceof TextGroupRenderObject) {
|
11594
|
-
const { firstItem, lastItem } = this.cutTextRender(render, parentLine.limitWidth - parentLine.lineWidth(), parentLine.lineWidth() === 0);
|
11660
|
+
const { firstItem, lastItem } = this.cutTextRender(render, parentLine.limitWidth - parentLine.lineWidth(), parentLine.lineWidth() === 0, parentLine.isCloseToBody);
|
11595
11661
|
if (firstItem) {
|
11596
11662
|
parentLine.add(firstItem);
|
11597
11663
|
}
|
@@ -11599,6 +11665,10 @@ class ParagraphMeasure {
|
|
11599
11665
|
parentLine.applyNewLine();
|
11600
11666
|
this.arrangeLeafRender(parentLine, lastItem);
|
11601
11667
|
}
|
11668
|
+
if (!firstItem && !lastItem) {
|
11669
|
+
parentLine.applyNewLine();
|
11670
|
+
this.arrangeLeafRender(parentLine, render);
|
11671
|
+
}
|
11602
11672
|
}
|
11603
11673
|
else if (render instanceof FillNullSpaceRenderObject) {
|
11604
11674
|
const { firstItem, lastItem } = this.cutFillNullRender(render, parentLine.limitWidth - parentLine.lineWidth());
|
@@ -11638,7 +11708,7 @@ class ParagraphMeasure {
|
|
11638
11708
|
}
|
11639
11709
|
}
|
11640
11710
|
}
|
11641
|
-
cutTextRender(render, limitWidth, lineEmpty) {
|
11711
|
+
cutTextRender(render, limitWidth, lineEmpty, isCloseToBody) {
|
11642
11712
|
let sumWidth = 0;
|
11643
11713
|
const cutRender = render.clone();
|
11644
11714
|
cutRender.textMeasures.length = 0;
|
@@ -11652,13 +11722,13 @@ class ParagraphMeasure {
|
|
11652
11722
|
break;
|
11653
11723
|
}
|
11654
11724
|
}
|
11655
|
-
|
11656
|
-
|
11657
|
-
|
11658
|
-
|
11659
|
-
|
11660
|
-
|
11661
|
-
|
11725
|
+
//后置标点处理
|
11726
|
+
i = this.patchHandlePostPunctuation(render, i, isCloseToBody, lineEmpty);
|
11727
|
+
//前置标点处理
|
11728
|
+
i = this.patchHandleLeadingPunctuation(render, i, lineEmpty);
|
11729
|
+
if (i <= 0) {
|
11730
|
+
return { firstItem: null, lastItem: null };
|
11731
|
+
}
|
11662
11732
|
cutRender.textMeasures = render.textMeasures.splice(0, i);
|
11663
11733
|
render.measure();
|
11664
11734
|
cutRender.measure();
|
@@ -11668,6 +11738,7 @@ class ParagraphMeasure {
|
|
11668
11738
|
* 处理前置标点,前置标点不能出现在末尾
|
11669
11739
|
* @param render
|
11670
11740
|
* @param i
|
11741
|
+
* @param lineEmpty
|
11671
11742
|
*/
|
11672
11743
|
patchHandleLeadingPunctuation(render, i, lineEmpty) {
|
11673
11744
|
if (i === 1 && lineEmpty) {
|
@@ -11682,15 +11753,10 @@ class ParagraphMeasure {
|
|
11682
11753
|
* 处理后置标点,后置标点不能出现在行首
|
11683
11754
|
* @param render
|
11684
11755
|
* @param i
|
11756
|
+
* @param inCloseBody
|
11685
11757
|
* @param lineEmpty
|
11686
11758
|
*/
|
11687
|
-
patchHandlePostPunctuation(render,
|
11688
|
-
if (i === render.textMeasures.length - 1) {
|
11689
|
-
//紧跟着的字符包含后置标点
|
11690
|
-
if (this.containerStartSymbolInTextStart(nextRender)) {
|
11691
|
-
i--;
|
11692
|
-
}
|
11693
|
-
}
|
11759
|
+
patchHandlePostPunctuation(render, i, inCloseBody, lineEmpty) {
|
11694
11760
|
if (inCloseBody && this.containPostPunctuation(render.textMeasures[i]?.char)) {
|
11695
11761
|
if (this.containPostPunctuation(render.textMeasures[i + 1]?.char)) {
|
11696
11762
|
i--;
|
@@ -13904,7 +13970,7 @@ class DocumentEvent {
|
|
13904
13970
|
}
|
13905
13971
|
const event = new GetTrackTipsEvent(this.docCtx);
|
13906
13972
|
event.source = element;
|
13907
|
-
DocumentEvent.invokeEvent('GetTrackTips', element, event, 'Bubbling'
|
13973
|
+
DocumentEvent.invokeEvent('GetTrackTips', element, event, 'Bubbling');
|
13908
13974
|
if (event.trackTips) {
|
13909
13975
|
this.trackTipsChanged.next({ pos: { ...this.currentPos }, tips: event.trackTips });
|
13910
13976
|
this.prevTrackInfo = true;
|
@@ -13956,7 +14022,7 @@ class DocumentEvent {
|
|
13956
14022
|
this.endHitInfo = this.startHitInfo;
|
13957
14023
|
const mousedownEvent = new MousedownElementEvent(this.docCtx);
|
13958
14024
|
mousedownEvent.source = startElement;
|
13959
|
-
DocumentEvent.invokeEvent('ElementMousedown', startElement, mousedownEvent, 'All'
|
14025
|
+
DocumentEvent.invokeEvent('ElementMousedown', startElement, mousedownEvent, 'All');
|
13960
14026
|
}
|
13961
14027
|
else {
|
13962
14028
|
this.clearHitInfo();
|
@@ -14089,7 +14155,7 @@ class DocumentEvent {
|
|
14089
14155
|
//const { render: { renderPosition: { x: rx, y: ry } } } = this.currentMouseoverRender;
|
14090
14156
|
//const rp = this.currentMouseoverRender?.absoluteRenderRect as Rect;
|
14091
14157
|
const rp = ElementUtil.getRenderAbsolutePaintRect(cellRender);
|
14092
|
-
rp.y -= this.viewOptions.pageOffset.y;
|
14158
|
+
//rp.y -= this.viewOptions.pageOffset.y;
|
14093
14159
|
const relativePos = { x: mousePos.x - rp.x, y: mousePos.y - rp.y };
|
14094
14160
|
const isInCellBorder = CommonUtil.isInRectBorder(cellRender.rect, 2, relativePos);
|
14095
14161
|
cursorType = ElementUtil.getBorderCursor(isInCellBorder.borderType);
|
@@ -14206,7 +14272,7 @@ class DocumentEvent {
|
|
14206
14272
|
const startElement = this.startHitInfo.render.element;
|
14207
14273
|
const mousedownEvent = new MousedownElementEvent(this.docCtx);
|
14208
14274
|
mousedownEvent.source = startElement;
|
14209
|
-
DocumentEvent.invokeEvent('ElementClick', startElement, mousedownEvent, "All"
|
14275
|
+
DocumentEvent.invokeEvent('ElementClick', startElement, mousedownEvent, "All");
|
14210
14276
|
//this.refreshDocument();
|
14211
14277
|
}
|
14212
14278
|
const { startControl, startOffset, collapsed } = this.selectionState;
|
@@ -14218,7 +14284,7 @@ class DocumentEvent {
|
|
14218
14284
|
dropEvent.source = startControl;
|
14219
14285
|
dropEvent.sourceOffset = startOffset;
|
14220
14286
|
dropEvent.dragElement = this.focusedElement;
|
14221
|
-
if (DocumentEvent.invokeEvent('ElementDrop', startControl, dropEvent, 'All'
|
14287
|
+
if (DocumentEvent.invokeEvent('ElementDrop', startControl, dropEvent, 'All')) {
|
14222
14288
|
return;
|
14223
14289
|
}
|
14224
14290
|
this.docCtx.docChange.moveElement(startControl, startOffset, this.focusedElement, this.startHitInfo.offset, this.selectionState);
|
@@ -14254,7 +14320,7 @@ class DocumentEvent {
|
|
14254
14320
|
if (hitInfo) {
|
14255
14321
|
docEvent.source = hitInfo.element;
|
14256
14322
|
docEvent.sourceRender = hitInfo.render;
|
14257
|
-
const res = DocumentEvent.invokeEvent('ElementDblClick', hitInfo.element, docEvent, 'All'
|
14323
|
+
const res = DocumentEvent.invokeEvent('ElementDblClick', hitInfo.element, docEvent, 'All');
|
14258
14324
|
if (res) {
|
14259
14325
|
return;
|
14260
14326
|
}
|
@@ -14435,7 +14501,7 @@ class DocumentEvent {
|
|
14435
14501
|
* @param eventStage
|
14436
14502
|
* @param docCtx
|
14437
14503
|
*/
|
14438
|
-
static invokeEvent(type, sourceElement, event, eventStage
|
14504
|
+
static invokeEvent(type, sourceElement, event, eventStage) {
|
14439
14505
|
const parents = ElementUtil.getParentElements(sourceElement);
|
14440
14506
|
//先执行捕获阶段,在执行冒泡
|
14441
14507
|
for (let i = parents.length - 1; i > -parents.length; i--) {
|
@@ -14969,7 +15035,7 @@ class DocumentInput {
|
|
14969
15035
|
const evt = nodeEvt.sourceEvt;
|
14970
15036
|
const keyEvent = new KeyboradElementEvent(this.docCtx);
|
14971
15037
|
keyEvent.sourceEvent = evt;
|
14972
|
-
if (DocumentEvent.invokeEvent('ElementKeyDown', this.docCtx.selectionState.startControl, keyEvent, 'Capture'
|
15038
|
+
if (DocumentEvent.invokeEvent('ElementKeyDown', this.docCtx.selectionState.startControl, keyEvent, 'Capture')) {
|
14973
15039
|
return;
|
14974
15040
|
}
|
14975
15041
|
if (evt.keyCode === 8) {
|
@@ -15096,7 +15162,13 @@ class DocumentChange {
|
|
15096
15162
|
this.onInputBySelectRange(data);
|
15097
15163
|
return;
|
15098
15164
|
}
|
15099
|
-
|
15165
|
+
const inputEvent = new InputElementEvent(this.docCtx);
|
15166
|
+
inputEvent.data = data.data;
|
15167
|
+
DocumentEvent.invokeEvent('ElementInput', startControl, inputEvent, 'All');
|
15168
|
+
if (inputEvent.isCancel) {
|
15169
|
+
return;
|
15170
|
+
}
|
15171
|
+
//判断是否需要创建新留痕区域
|
15100
15172
|
if (enableTrackChanges && !this.isInCorrectTrackRegion(startControl, exports.TrackRunTypeEnum.Inserted)) {
|
15101
15173
|
this.newInputTrackChanges(data, startControl, startOffset);
|
15102
15174
|
return;
|
@@ -15203,7 +15275,7 @@ class DocumentChange {
|
|
15203
15275
|
}
|
15204
15276
|
}
|
15205
15277
|
/**
|
15206
|
-
*
|
15278
|
+
* 创建新留痕块,并返回留痕块输入定位文本
|
15207
15279
|
* @param startControl
|
15208
15280
|
* @param startOffset
|
15209
15281
|
* @param trackType
|
@@ -15359,7 +15431,7 @@ class DocumentChange {
|
|
15359
15431
|
eventElement.source = startControl;
|
15360
15432
|
eventElement.sourceEvent = evt;
|
15361
15433
|
eventElement.sourceOffset = startOffset;
|
15362
|
-
const res = DocumentEvent.invokeEvent('BackspaceKey', startControl, eventElement, 'Capture'
|
15434
|
+
const res = DocumentEvent.invokeEvent('BackspaceKey', startControl, eventElement, 'Capture');
|
15363
15435
|
if (res && res.isCancel) {
|
15364
15436
|
return;
|
15365
15437
|
}
|
@@ -15382,7 +15454,7 @@ class DocumentChange {
|
|
15382
15454
|
eventElement.source = startControl;
|
15383
15455
|
eventElement.sourceEvent = evt;
|
15384
15456
|
eventElement.sourceOffset = startOffset;
|
15385
|
-
const res = DocumentEvent.invokeEvent('DeleteKey', startControl, eventElement, 'Capture'
|
15457
|
+
const res = DocumentEvent.invokeEvent('DeleteKey', startControl, eventElement, 'Capture');
|
15386
15458
|
if (res && res.isCancel) {
|
15387
15459
|
return;
|
15388
15460
|
}
|
@@ -16141,6 +16213,25 @@ class DocumentChange {
|
|
16141
16213
|
});
|
16142
16214
|
}
|
16143
16215
|
}
|
16216
|
+
static setParaStyle(ss, setterFunc) {
|
16217
|
+
if (ss.collapsed && ss.startControl) {
|
16218
|
+
const para = ElementUtil.getParentByType(ss.startControl, ParagraphElement);
|
16219
|
+
if (para) {
|
16220
|
+
setterFunc(para.props);
|
16221
|
+
}
|
16222
|
+
}
|
16223
|
+
else {
|
16224
|
+
const range = ss.selectedRange;
|
16225
|
+
if (!range) {
|
16226
|
+
return;
|
16227
|
+
}
|
16228
|
+
RangeUtil.recursionTraversalRangeHandler(range, (itemRange) => {
|
16229
|
+
if (itemRange.target instanceof ParagraphElement) {
|
16230
|
+
setterFunc(itemRange.target.props);
|
16231
|
+
}
|
16232
|
+
});
|
16233
|
+
}
|
16234
|
+
}
|
16144
16235
|
/**
|
16145
16236
|
* 复制
|
16146
16237
|
* @param evt
|
@@ -20726,7 +20817,7 @@ class CanvasTextEditor extends AbsolutePanel {
|
|
20726
20817
|
}
|
20727
20818
|
const elementEvent = new ContextMenuElementEvent(this.docCtx);
|
20728
20819
|
elementEvent.source = startControl;
|
20729
|
-
DocumentEvent.invokeEvent('ElementContextMenu', startControl, elementEvent, 'All'
|
20820
|
+
DocumentEvent.invokeEvent('ElementContextMenu', startControl, elementEvent, 'All');
|
20730
20821
|
const position = { x: evt.offsetX + 10, y: evt.offsetY, translateY: this.viewOptions.pageOffset.y };
|
20731
20822
|
this.onContextMenuItemChanged.next({ pos: position, menus: elementEvent.menus });
|
20732
20823
|
}
|
@@ -20892,14 +20983,16 @@ class CanvasTextEditor extends AbsolutePanel {
|
|
20892
20983
|
return null;
|
20893
20984
|
}
|
20894
20985
|
/**
|
20895
|
-
*
|
20896
|
-
* @param
|
20986
|
+
* 设置段落样式
|
20987
|
+
* @param newProps
|
20897
20988
|
*/
|
20898
|
-
|
20989
|
+
setParaStyle(newProps) {
|
20899
20990
|
const setterFunc = (paraProps) => {
|
20900
|
-
|
20991
|
+
Object.keys(newProps).forEach(key => {
|
20992
|
+
paraProps[key] = newProps[key];
|
20993
|
+
});
|
20901
20994
|
};
|
20902
|
-
DocumentChange.
|
20995
|
+
DocumentChange.setParaStyle(this.selectionState, setterFunc);
|
20903
20996
|
}
|
20904
20997
|
combineCell() {
|
20905
20998
|
TableUtil.mergeCells(this.selectionState);
|
@@ -21459,26 +21552,6 @@ class CanvasTextEditor extends AbsolutePanel {
|
|
21459
21552
|
insertNewRow(tb, insertRowIndex) {
|
21460
21553
|
return TableUtil.insertNewRow(tb, insertRowIndex);
|
21461
21554
|
}
|
21462
|
-
generatorDoc(data) {
|
21463
|
-
//根据传入的参数,动态生成病情信息的结构化报告
|
21464
|
-
const para = new ParagraphElement();
|
21465
|
-
//创建患者姓名文本标签
|
21466
|
-
const patNameLabel = new TextGroupElement();
|
21467
|
-
patNameLabel.text = "患者姓名:";
|
21468
|
-
//添加到段落中
|
21469
|
-
para.addChild(patNameLabel);
|
21470
|
-
//创建患者姓名数据元
|
21471
|
-
const patNameDataEle = new DataElementText();
|
21472
|
-
patNameDataEle.props.valueTextProps = new TextProps();
|
21473
|
-
patNameDataEle.props.valueTextProps.fontName = '宋体';
|
21474
|
-
patNameDataEle.props.valueTextProps.fontSize = 16;
|
21475
|
-
//数据元赋值
|
21476
|
-
patNameDataEle.setValue(data.patName);
|
21477
|
-
//添加到段落中
|
21478
|
-
para.addChild(patNameDataEle);
|
21479
|
-
//添加到正文中
|
21480
|
-
this.docCtx.document.bodyElement.addChild(para);
|
21481
|
-
}
|
21482
21555
|
}
|
21483
21556
|
|
21484
21557
|
/**
|
@@ -21897,6 +21970,7 @@ exports.InlineGroupElement = InlineGroupElement;
|
|
21897
21970
|
exports.InlineGroupInputElement = InlineGroupInputElement;
|
21898
21971
|
exports.InlineGroupRenderObject = InlineGroupRenderObject;
|
21899
21972
|
exports.InlineMuiltBlockLineRenderObject = InlineMuiltBlockLineRenderObject;
|
21973
|
+
exports.InputElementEvent = InputElementEvent;
|
21900
21974
|
exports.IsInSideDataElement = IsInSideDataElement;
|
21901
21975
|
exports.IsInSideInlineGroupInputElement = IsInSideInlineGroupInputElement;
|
21902
21976
|
exports.KeyboradElementEvent = KeyboradElementEvent;
|
@@ -21971,6 +22045,7 @@ exports.deleteCurrentParagraph = deleteCurrentParagraph;
|
|
21971
22045
|
exports.documentPrint = documentPrint;
|
21972
22046
|
exports.drawDecorator = drawDecorator;
|
21973
22047
|
exports.elementTypeEventHandler = elementTypeEventHandler;
|
22048
|
+
exports.falseChar = falseChar;
|
21974
22049
|
exports.fontMapFunc = fontMapFunc;
|
21975
22050
|
exports.fromEvent = fromEvent;
|
21976
22051
|
exports.getCalleeName = getCalleeName;
|
@@ -21991,6 +22066,7 @@ exports.targetMaps = targetMaps;
|
|
21991
22066
|
exports.textLineRenderMode = textLineRenderMode;
|
21992
22067
|
exports.toRawType = toRawType;
|
21993
22068
|
exports.toTypeString = toTypeString;
|
22069
|
+
exports.trueChar = trueChar;
|
21994
22070
|
exports.validateDataEle = validateDataEle;
|
21995
22071
|
exports.validateDataEleRenderObj = validateDataEleRenderObj;
|
21996
22072
|
exports.validateInlineInputRenderObj = validateInlineInputRenderObj;
|