@hailin-zheng/editor-core 2.0.27 → 2.0.28
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 +18 -28
- package/index-cjs.js.map +1 -1
- package/index.js +18 -28
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +1 -7
- package/package.json +1 -1
package/index.js
CHANGED
@@ -3396,7 +3396,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3396
3396
|
ns: "http://www.w3.org/2000/svg",
|
3397
3397
|
attrs: {
|
3398
3398
|
id: "selection",
|
3399
|
-
}
|
3399
|
+
},
|
3400
3400
|
},
|
3401
3401
|
children: []
|
3402
3402
|
};
|
@@ -3421,7 +3421,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3421
3421
|
height: this.rect.height,
|
3422
3422
|
viewBox: `0 0 ${this.rect.width} ${this.rect.height}`,
|
3423
3423
|
overflow: "hidden"
|
3424
|
-
}
|
3424
|
+
},
|
3425
3425
|
},
|
3426
3426
|
children: [
|
3427
3427
|
pageCorner, highlight, ...CommonUtil.toArray(event.getChildNodes(this)), pageNum, selection
|
@@ -13338,6 +13338,7 @@ class EditorContext {
|
|
13338
13338
|
this._document.destroy();
|
13339
13339
|
}
|
13340
13340
|
this.clearPrevDocCb = null;
|
13341
|
+
this.selectionState.startHitInfo = null;
|
13341
13342
|
};
|
13342
13343
|
}
|
13343
13344
|
clear() {
|
@@ -19967,16 +19968,14 @@ function createPrintTemplate({ width, height, orient }) {
|
|
19967
19968
|
box-sizing: border-box;
|
19968
19969
|
-moz-box-sizing: border-box;
|
19969
19970
|
}
|
19970
|
-
body *{
|
19971
|
-
white-space: pre;
|
19972
|
-
}
|
19973
19971
|
@page {
|
19974
19972
|
size: ${orient};
|
19975
19973
|
margin: 0;
|
19974
|
+
padding: 0;
|
19976
19975
|
}
|
19977
19976
|
div {
|
19978
19977
|
width: ${width}mm;
|
19979
|
-
|
19978
|
+
height: ${height}mm;
|
19980
19979
|
font-size: 0;
|
19981
19980
|
}
|
19982
19981
|
@media print {
|
@@ -19984,6 +19983,7 @@ function createPrintTemplate({ width, height, orient }) {
|
|
19984
19983
|
body {
|
19985
19984
|
width: ${width}mm;
|
19986
19985
|
height: ${height}mm;
|
19986
|
+
margin: 0;
|
19987
19987
|
}
|
19988
19988
|
div {
|
19989
19989
|
width: initial;
|
@@ -27172,22 +27172,26 @@ class DocEditor {
|
|
27172
27172
|
*/
|
27173
27173
|
setCursor() {
|
27174
27174
|
this.selectionState;
|
27175
|
-
if (!this.canSetCursor() || !this.
|
27175
|
+
if (!this.canSetCursor() || !this.selectionState.startHitInfo) {
|
27176
27176
|
this.selectionState.editable = false;
|
27177
27177
|
this.docCtx.selectionState.cursorPos = null;
|
27178
|
-
this.
|
27178
|
+
const cursorRect = this.getCursorRect();
|
27179
|
+
this.hiddenInput(false, cursorRect);
|
27179
27180
|
return false;
|
27180
27181
|
}
|
27181
27182
|
const cursorRect = this.getCursorRect();
|
27182
27183
|
this.docCtx.cursorRect = ElementUtil.cloneRect(cursorRect);
|
27183
27184
|
this.selectionState.cursorPos = cursorRect;
|
27184
|
-
const abPos =
|
27185
|
+
const abPos = ElementUtil.cloneRect(cursorRect);
|
27185
27186
|
this.setCursorPosition(abPos);
|
27186
27187
|
//this.documentEvent.invokeCursor(startControl);
|
27187
27188
|
return true;
|
27188
27189
|
}
|
27189
27190
|
getCursorRect() {
|
27190
27191
|
try {
|
27192
|
+
if (!this.documentEvent.startHitInfo) {
|
27193
|
+
return { x: 0, y: 0, width: 0, height: 0 };
|
27194
|
+
}
|
27191
27195
|
const { startControl, startOffset } = this.selectionState;
|
27192
27196
|
const { startRegion, hitDocIndex } = this.documentEvent.startHitInfo;
|
27193
27197
|
const cursorPos = DocumentCursor.getElementCursorPos(startControl, startOffset, startRegion, hitDocIndex);
|
@@ -27204,14 +27208,16 @@ class DocEditor {
|
|
27204
27208
|
*/
|
27205
27209
|
setCursorVisibility(visibility) {
|
27206
27210
|
if (visibility) {
|
27211
|
+
this.editInput.style.removeProperty('display');
|
27207
27212
|
this.editInput.focus();
|
27208
27213
|
}
|
27209
27214
|
}
|
27210
|
-
hiddenInput(reset = true) {
|
27215
|
+
hiddenInput(reset = true, pos = null) {
|
27211
27216
|
//this.input.style.display = 'none';
|
27212
|
-
this.editInput.style.left = '-2px';
|
27213
|
-
this.editInput.style.top = '-2px';
|
27217
|
+
this.editInput.style.left = pos ? pos.x + 'px' : '-2px';
|
27218
|
+
this.editInput.style.top = pos ? pos.y + 'px' : '-2px';
|
27214
27219
|
this.editInput.readOnly = true;
|
27220
|
+
this.editInput.style.display = 'none';
|
27215
27221
|
!reset && this.editInput.focus();
|
27216
27222
|
}
|
27217
27223
|
/**
|
@@ -27226,22 +27232,6 @@ class DocEditor {
|
|
27226
27232
|
this.setCursorVisibility(true);
|
27227
27233
|
//this.setCursorInputStatus();
|
27228
27234
|
}
|
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
27235
|
/**
|
27246
27236
|
* 判断是否光标可以设置接受编辑
|
27247
27237
|
* @returns
|