@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-cjs.js
CHANGED
@@ -3426,7 +3426,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3426
3426
|
ns: "http://www.w3.org/2000/svg",
|
3427
3427
|
attrs: {
|
3428
3428
|
id: "selection",
|
3429
|
-
}
|
3429
|
+
},
|
3430
3430
|
},
|
3431
3431
|
children: []
|
3432
3432
|
};
|
@@ -3451,7 +3451,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3451
3451
|
height: this.rect.height,
|
3452
3452
|
viewBox: `0 0 ${this.rect.width} ${this.rect.height}`,
|
3453
3453
|
overflow: "hidden"
|
3454
|
-
}
|
3454
|
+
},
|
3455
3455
|
},
|
3456
3456
|
children: [
|
3457
3457
|
pageCorner, highlight, ...CommonUtil.toArray(event.getChildNodes(this)), pageNum, selection
|
@@ -13368,6 +13368,7 @@ class EditorContext {
|
|
13368
13368
|
this._document.destroy();
|
13369
13369
|
}
|
13370
13370
|
this.clearPrevDocCb = null;
|
13371
|
+
this.selectionState.startHitInfo = null;
|
13371
13372
|
};
|
13372
13373
|
}
|
13373
13374
|
clear() {
|
@@ -19997,16 +19998,14 @@ function createPrintTemplate({ width, height, orient }) {
|
|
19997
19998
|
box-sizing: border-box;
|
19998
19999
|
-moz-box-sizing: border-box;
|
19999
20000
|
}
|
20000
|
-
body *{
|
20001
|
-
white-space: pre;
|
20002
|
-
}
|
20003
20001
|
@page {
|
20004
20002
|
size: ${orient};
|
20005
20003
|
margin: 0;
|
20004
|
+
padding: 0;
|
20006
20005
|
}
|
20007
20006
|
div {
|
20008
20007
|
width: ${width}mm;
|
20009
|
-
|
20008
|
+
height: ${height}mm;
|
20010
20009
|
font-size: 0;
|
20011
20010
|
}
|
20012
20011
|
@media print {
|
@@ -20014,6 +20013,7 @@ function createPrintTemplate({ width, height, orient }) {
|
|
20014
20013
|
body {
|
20015
20014
|
width: ${width}mm;
|
20016
20015
|
height: ${height}mm;
|
20016
|
+
margin: 0;
|
20017
20017
|
}
|
20018
20018
|
div {
|
20019
20019
|
width: initial;
|
@@ -27202,22 +27202,26 @@ class DocEditor {
|
|
27202
27202
|
*/
|
27203
27203
|
setCursor() {
|
27204
27204
|
this.selectionState;
|
27205
|
-
if (!this.canSetCursor() || !this.
|
27205
|
+
if (!this.canSetCursor() || !this.selectionState.startHitInfo) {
|
27206
27206
|
this.selectionState.editable = false;
|
27207
27207
|
this.docCtx.selectionState.cursorPos = null;
|
27208
|
-
this.
|
27208
|
+
const cursorRect = this.getCursorRect();
|
27209
|
+
this.hiddenInput(false, cursorRect);
|
27209
27210
|
return false;
|
27210
27211
|
}
|
27211
27212
|
const cursorRect = this.getCursorRect();
|
27212
27213
|
this.docCtx.cursorRect = ElementUtil.cloneRect(cursorRect);
|
27213
27214
|
this.selectionState.cursorPos = cursorRect;
|
27214
|
-
const abPos =
|
27215
|
+
const abPos = ElementUtil.cloneRect(cursorRect);
|
27215
27216
|
this.setCursorPosition(abPos);
|
27216
27217
|
//this.documentEvent.invokeCursor(startControl);
|
27217
27218
|
return true;
|
27218
27219
|
}
|
27219
27220
|
getCursorRect() {
|
27220
27221
|
try {
|
27222
|
+
if (!this.documentEvent.startHitInfo) {
|
27223
|
+
return { x: 0, y: 0, width: 0, height: 0 };
|
27224
|
+
}
|
27221
27225
|
const { startControl, startOffset } = this.selectionState;
|
27222
27226
|
const { startRegion, hitDocIndex } = this.documentEvent.startHitInfo;
|
27223
27227
|
const cursorPos = DocumentCursor.getElementCursorPos(startControl, startOffset, startRegion, hitDocIndex);
|
@@ -27234,14 +27238,16 @@ class DocEditor {
|
|
27234
27238
|
*/
|
27235
27239
|
setCursorVisibility(visibility) {
|
27236
27240
|
if (visibility) {
|
27241
|
+
this.editInput.style.removeProperty('display');
|
27237
27242
|
this.editInput.focus();
|
27238
27243
|
}
|
27239
27244
|
}
|
27240
|
-
hiddenInput(reset = true) {
|
27245
|
+
hiddenInput(reset = true, pos = null) {
|
27241
27246
|
//this.input.style.display = 'none';
|
27242
|
-
this.editInput.style.left = '-2px';
|
27243
|
-
this.editInput.style.top = '-2px';
|
27247
|
+
this.editInput.style.left = pos ? pos.x + 'px' : '-2px';
|
27248
|
+
this.editInput.style.top = pos ? pos.y + 'px' : '-2px';
|
27244
27249
|
this.editInput.readOnly = true;
|
27250
|
+
this.editInput.style.display = 'none';
|
27245
27251
|
!reset && this.editInput.focus();
|
27246
27252
|
}
|
27247
27253
|
/**
|
@@ -27256,22 +27262,6 @@ class DocEditor {
|
|
27256
27262
|
this.setCursorVisibility(true);
|
27257
27263
|
//this.setCursorInputStatus();
|
27258
27264
|
}
|
27259
|
-
/**
|
27260
|
-
* 将相对坐标位置转换为绝对坐标位
|
27261
|
-
* 由于缩放,导致绝对位置=相对位置*scale
|
27262
|
-
* @param pos
|
27263
|
-
*/
|
27264
|
-
transToAbsolutePos(pos) {
|
27265
|
-
const { scale } = this.viewOptions;
|
27266
|
-
this.documentPaint.docContainer.rect.x;
|
27267
|
-
this.documentPaint.docContainer.rect.y;
|
27268
|
-
pos.x = pos.x * scale;
|
27269
|
-
pos.y = pos.y * scale;
|
27270
|
-
if ('height' in pos) {
|
27271
|
-
pos.height = pos.height * scale;
|
27272
|
-
}
|
27273
|
-
return pos;
|
27274
|
-
}
|
27275
27265
|
/**
|
27276
27266
|
* 判断是否光标可以设置接受编辑
|
27277
27267
|
* @returns
|