@hailin-zheng/editor-core 2.0.27 → 2.0.29
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 +79 -38
- package/index-cjs.js.map +1 -1
- package/index.js +79 -38
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +2 -12
- package/med_editor/framework/common-util.d.ts +1 -0
- package/med_editor/framework/editor-calendar-vnode.d.ts +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
@@ -643,6 +643,15 @@ class CommonUtil {
|
|
643
643
|
ele.removeChild(ele.firstChild);
|
644
644
|
}
|
645
645
|
}
|
646
|
+
static findParent(curr, predicate) {
|
647
|
+
if (!curr) {
|
648
|
+
return null;
|
649
|
+
}
|
650
|
+
if (predicate(curr)) {
|
651
|
+
return curr;
|
652
|
+
}
|
653
|
+
return this.findParent(curr.parentElement, predicate);
|
654
|
+
}
|
646
655
|
}
|
647
656
|
|
648
657
|
const docOpsMap = new Map();
|
@@ -3396,7 +3405,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3396
3405
|
ns: "http://www.w3.org/2000/svg",
|
3397
3406
|
attrs: {
|
3398
3407
|
id: "selection",
|
3399
|
-
}
|
3408
|
+
},
|
3400
3409
|
},
|
3401
3410
|
children: []
|
3402
3411
|
};
|
@@ -3421,7 +3430,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3421
3430
|
height: this.rect.height,
|
3422
3431
|
viewBox: `0 0 ${this.rect.width} ${this.rect.height}`,
|
3423
3432
|
overflow: "hidden"
|
3424
|
-
}
|
3433
|
+
},
|
3425
3434
|
},
|
3426
3435
|
children: [
|
3427
3436
|
pageCorner, highlight, ...CommonUtil.toArray(event.getChildNodes(this)), pageNum, selection
|
@@ -8447,17 +8456,17 @@ class DataElementCheckRenderObject extends LeafRenderObject {
|
|
8447
8456
|
const style = props.style;
|
8448
8457
|
if (props.multiSelect) {
|
8449
8458
|
style === 'RadioButton' ? this.drawCircleCheckbox(t, width, height, props.checked)
|
8450
|
-
: this.drawRectCheckbox(t, width, height, props.size, props.checked);
|
8459
|
+
: this.drawRectCheckbox(t, width, height, props.size, props.checked, props.border);
|
8451
8460
|
}
|
8452
8461
|
else {
|
8453
|
-
style === 'CheckBox' ? this.drawRectCheckbox(t, width, height, props.size, props.checked)
|
8462
|
+
style === 'CheckBox' ? this.drawRectCheckbox(t, width, height, props.size, props.checked, props.border)
|
8454
8463
|
: this.drawCircleCheckbox(t, width, height, props.checked);
|
8455
8464
|
}
|
8456
8465
|
}
|
8457
8466
|
return t;
|
8458
8467
|
}
|
8459
|
-
drawRectCheckbox(t, width, height, size, checked) {
|
8460
|
-
t.children.push({
|
8468
|
+
drawRectCheckbox(t, width, height, size, checked, border) {
|
8469
|
+
border && t.children.push({
|
8461
8470
|
sel: 'rect',
|
8462
8471
|
data: {
|
8463
8472
|
ns: "http://www.w3.org/2000/svg",
|
@@ -13338,6 +13347,7 @@ class EditorContext {
|
|
13338
13347
|
this._document.destroy();
|
13339
13348
|
}
|
13340
13349
|
this.clearPrevDocCb = null;
|
13350
|
+
this.selectionState.startHitInfo = null;
|
13341
13351
|
};
|
13342
13352
|
}
|
13343
13353
|
clear() {
|
@@ -19967,9 +19977,6 @@ function createPrintTemplate({ width, height, orient }) {
|
|
19967
19977
|
box-sizing: border-box;
|
19968
19978
|
-moz-box-sizing: border-box;
|
19969
19979
|
}
|
19970
|
-
body *{
|
19971
|
-
white-space: pre;
|
19972
|
-
}
|
19973
19980
|
@page {
|
19974
19981
|
size: ${orient};
|
19975
19982
|
margin: 0;
|
@@ -26134,14 +26141,36 @@ class EditorCalendarVNode {
|
|
26134
26141
|
style: {
|
26135
26142
|
position: 'absolute',
|
26136
26143
|
left: (position.x - 10) + 'px',
|
26137
|
-
top: position.y + 'px',
|
26144
|
+
top: position.y + 5 + position.height + 'px',
|
26138
26145
|
'min-width': '100px',
|
26139
26146
|
'background-color': 'white',
|
26140
26147
|
'z-index': '1000',
|
26141
26148
|
'border-radius': '5px',
|
26142
26149
|
'box-shadow': '0 0 5px 0 rgba(0,0,0,0.2)',
|
26143
26150
|
'user-select': 'none',
|
26144
|
-
}
|
26151
|
+
},
|
26152
|
+
hook: {
|
26153
|
+
insert: (vnode) => {
|
26154
|
+
const elm = vnode.elm;
|
26155
|
+
const parent = CommonUtil.findParent(elm, (item) => item.className === 'scroll-container');
|
26156
|
+
if (parent) {
|
26157
|
+
const parentRect = parent.getBoundingClientRect();
|
26158
|
+
const elmRect = elm.getBoundingClientRect();
|
26159
|
+
if (elmRect.top < parentRect.top) {
|
26160
|
+
elm.style.top = (position.y - elmRect.height) + 'px';
|
26161
|
+
}
|
26162
|
+
if (elmRect.left < parentRect.left) {
|
26163
|
+
elm.style.left = (position.x - 10) + 'px';
|
26164
|
+
}
|
26165
|
+
if (elmRect.right > parentRect.right) {
|
26166
|
+
elm.style.left = (position.x - elmRect.width + 10) + 'px';
|
26167
|
+
}
|
26168
|
+
if (elmRect.top + elmRect.height > parentRect.top + parentRect.height) {
|
26169
|
+
elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
26170
|
+
}
|
26171
|
+
}
|
26172
|
+
}
|
26173
|
+
},
|
26145
26174
|
},
|
26146
26175
|
children: []
|
26147
26176
|
};
|
@@ -27172,22 +27201,26 @@ class DocEditor {
|
|
27172
27201
|
*/
|
27173
27202
|
setCursor() {
|
27174
27203
|
this.selectionState;
|
27175
|
-
if (!this.canSetCursor() || !this.
|
27204
|
+
if (!this.canSetCursor() || !this.selectionState.startHitInfo) {
|
27176
27205
|
this.selectionState.editable = false;
|
27177
27206
|
this.docCtx.selectionState.cursorPos = null;
|
27178
|
-
this.
|
27207
|
+
const cursorRect = this.getCursorRect();
|
27208
|
+
this.hiddenInput(false, cursorRect);
|
27179
27209
|
return false;
|
27180
27210
|
}
|
27181
27211
|
const cursorRect = this.getCursorRect();
|
27182
27212
|
this.docCtx.cursorRect = ElementUtil.cloneRect(cursorRect);
|
27183
27213
|
this.selectionState.cursorPos = cursorRect;
|
27184
|
-
const abPos =
|
27214
|
+
const abPos = ElementUtil.cloneRect(cursorRect);
|
27185
27215
|
this.setCursorPosition(abPos);
|
27186
27216
|
//this.documentEvent.invokeCursor(startControl);
|
27187
27217
|
return true;
|
27188
27218
|
}
|
27189
27219
|
getCursorRect() {
|
27190
27220
|
try {
|
27221
|
+
if (!this.documentEvent.startHitInfo) {
|
27222
|
+
return { x: 0, y: 0, width: 0, height: 0 };
|
27223
|
+
}
|
27191
27224
|
const { startControl, startOffset } = this.selectionState;
|
27192
27225
|
const { startRegion, hitDocIndex } = this.documentEvent.startHitInfo;
|
27193
27226
|
const cursorPos = DocumentCursor.getElementCursorPos(startControl, startOffset, startRegion, hitDocIndex);
|
@@ -27204,14 +27237,16 @@ class DocEditor {
|
|
27204
27237
|
*/
|
27205
27238
|
setCursorVisibility(visibility) {
|
27206
27239
|
if (visibility) {
|
27240
|
+
this.editInput.style.removeProperty('display');
|
27207
27241
|
this.editInput.focus();
|
27208
27242
|
}
|
27209
27243
|
}
|
27210
|
-
hiddenInput(reset = true) {
|
27244
|
+
hiddenInput(reset = true, pos = null) {
|
27211
27245
|
//this.input.style.display = 'none';
|
27212
|
-
this.editInput.style.left = '-2px';
|
27213
|
-
this.editInput.style.top = '-2px';
|
27246
|
+
this.editInput.style.left = pos ? pos.x + 'px' : '-2px';
|
27247
|
+
this.editInput.style.top = pos ? pos.y + 'px' : '-2px';
|
27214
27248
|
this.editInput.readOnly = true;
|
27249
|
+
this.editInput.style.display = 'none';
|
27215
27250
|
!reset && this.editInput.focus();
|
27216
27251
|
}
|
27217
27252
|
/**
|
@@ -27226,22 +27261,6 @@ class DocEditor {
|
|
27226
27261
|
this.setCursorVisibility(true);
|
27227
27262
|
//this.setCursorInputStatus();
|
27228
27263
|
}
|
27229
|
-
/**
|
27230
|
-
* 将相对坐标位置转换为绝对坐标位
|
27231
|
-
* 由于缩放,导致绝对位置=相对位置*scale
|
27232
|
-
* @param pos
|
27233
|
-
*/
|
27234
|
-
transToAbsolutePos(pos) {
|
27235
|
-
const { scale } = this.viewOptions;
|
27236
|
-
this.documentPaint.docContainer.rect.x;
|
27237
|
-
this.documentPaint.docContainer.rect.y;
|
27238
|
-
pos.x = pos.x * scale;
|
27239
|
-
pos.y = pos.y * scale;
|
27240
|
-
if ('height' in pos) {
|
27241
|
-
pos.height = pos.height * scale;
|
27242
|
-
}
|
27243
|
-
return pos;
|
27244
|
-
}
|
27245
27264
|
/**
|
27246
27265
|
* 判断是否光标可以设置接受编辑
|
27247
27266
|
* @returns
|
@@ -27324,14 +27343,14 @@ class DocEditor {
|
|
27324
27343
|
const startDecorateRender = element.paintRenders[0];
|
27325
27344
|
if (!startDecorateRender) {
|
27326
27345
|
console.error('未找到数据元开始渲染元素');
|
27327
|
-
return;
|
27346
|
+
return null;
|
27328
27347
|
}
|
27329
27348
|
const { x, height, y, width } = startDecorateRender.rect;
|
27330
27349
|
const pos = ElementUtil.getRenderAbsolutePaintPos(startDecorateRender);
|
27331
27350
|
return {
|
27332
27351
|
x: pos.x + width,
|
27333
|
-
y: pos.y
|
27334
|
-
|
27352
|
+
y: pos.y,
|
27353
|
+
height
|
27335
27354
|
};
|
27336
27355
|
}
|
27337
27356
|
/**
|
@@ -28093,14 +28112,36 @@ class DocEditor {
|
|
28093
28112
|
style: {
|
28094
28113
|
position: 'absolute',
|
28095
28114
|
left: (position.x - 10) + 'px',
|
28096
|
-
top: position.y + 'px',
|
28115
|
+
top: position.y + 5 + position.height + 'px',
|
28097
28116
|
'min-width': '100px',
|
28098
28117
|
'background-color': 'white',
|
28099
28118
|
'z-index': '1000',
|
28100
28119
|
'border-radius': '5px',
|
28101
28120
|
'box-shadow': '0 0 5px 0 rgba(0,0,0,0.2)',
|
28102
28121
|
'user-select': 'none',
|
28103
|
-
}
|
28122
|
+
},
|
28123
|
+
hook: {
|
28124
|
+
insert: (vnode) => {
|
28125
|
+
const elm = vnode.elm;
|
28126
|
+
const parent = CommonUtil.findParent(elm, (item) => item.className === 'scroll-container');
|
28127
|
+
if (parent) {
|
28128
|
+
const parentRect = parent.getBoundingClientRect();
|
28129
|
+
const elmRect = elm.getBoundingClientRect();
|
28130
|
+
if (elmRect.top < parentRect.top) {
|
28131
|
+
elm.style.top = (position.y - elmRect.height) + 'px';
|
28132
|
+
}
|
28133
|
+
if (elmRect.left < parentRect.left) {
|
28134
|
+
elm.style.left = (position.x - 10) + 'px';
|
28135
|
+
}
|
28136
|
+
if (elmRect.right > parentRect.right) {
|
28137
|
+
elm.style.left = (position.x - elmRect.width + 10) + 'px';
|
28138
|
+
}
|
28139
|
+
if (elmRect.top + elmRect.height > parentRect.top + parentRect.height) {
|
28140
|
+
elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
28141
|
+
}
|
28142
|
+
}
|
28143
|
+
}
|
28144
|
+
},
|
28104
28145
|
},
|
28105
28146
|
children: [
|
28106
28147
|
{
|