@hailin-zheng/editor-core 2.0.26 → 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 +29 -33
- package/index-cjs.js.map +1 -1
- package/index.js +29 -33
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +1 -7
- package/package.json +1 -1
package/index.js
CHANGED
@@ -3361,7 +3361,9 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3361
3361
|
sel: 'g#page-num',
|
3362
3362
|
data: {
|
3363
3363
|
ns: 'http://www.w3.org/2000/svg',
|
3364
|
-
attrs: {
|
3364
|
+
attrs: {
|
3365
|
+
xmlns: 'http://www.w3.org/2000/svg'
|
3366
|
+
}
|
3365
3367
|
},
|
3366
3368
|
children: []
|
3367
3369
|
};
|
@@ -3394,7 +3396,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3394
3396
|
ns: "http://www.w3.org/2000/svg",
|
3395
3397
|
attrs: {
|
3396
3398
|
id: "selection",
|
3397
|
-
}
|
3399
|
+
},
|
3398
3400
|
},
|
3399
3401
|
children: []
|
3400
3402
|
};
|
@@ -3419,7 +3421,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3419
3421
|
height: this.rect.height,
|
3420
3422
|
viewBox: `0 0 ${this.rect.width} ${this.rect.height}`,
|
3421
3423
|
overflow: "hidden"
|
3422
|
-
}
|
3424
|
+
},
|
3423
3425
|
},
|
3424
3426
|
children: [
|
3425
3427
|
pageCorner, highlight, ...CommonUtil.toArray(event.getChildNodes(this)), pageNum, selection
|
@@ -4762,15 +4764,19 @@ class TextGroupRenderObject extends LeafRenderObject {
|
|
4762
4764
|
else if (props.vertAlign === 'superscript') ;
|
4763
4765
|
const fontSize = (props.vertAlign ? props.fontSize * 3 / 5 : props.fontSize);
|
4764
4766
|
const arr = [];
|
4767
|
+
let text = '';
|
4765
4768
|
this.textMeasures.reduce((prev, curr) => {
|
4766
|
-
|
4769
|
+
if (curr.char !== ' ') {
|
4770
|
+
arr.push(prev);
|
4771
|
+
text += curr.char;
|
4772
|
+
}
|
4767
4773
|
return curr.actualSize + prev;
|
4768
4774
|
}, this.rect.x);
|
4769
4775
|
const x = arr.join(' ');
|
4770
4776
|
const y = this.rect.y + vertHeight; //this.textMeasures.map(item => this.rect.y + vertHeight).join(' ');
|
4771
|
-
const text = this.textMeasures.map(item => {
|
4772
|
-
|
4773
|
-
}).join('');
|
4777
|
+
// const text = this.textMeasures.map(item => {
|
4778
|
+
// return item.char
|
4779
|
+
// }).join('');
|
4774
4780
|
const t = {
|
4775
4781
|
sel: 'text',
|
4776
4782
|
text: text,
|
@@ -13332,6 +13338,7 @@ class EditorContext {
|
|
13332
13338
|
this._document.destroy();
|
13333
13339
|
}
|
13334
13340
|
this.clearPrevDocCb = null;
|
13341
|
+
this.selectionState.startHitInfo = null;
|
13335
13342
|
};
|
13336
13343
|
}
|
13337
13344
|
clear() {
|
@@ -19961,16 +19968,14 @@ function createPrintTemplate({ width, height, orient }) {
|
|
19961
19968
|
box-sizing: border-box;
|
19962
19969
|
-moz-box-sizing: border-box;
|
19963
19970
|
}
|
19964
|
-
body *{
|
19965
|
-
white-space: pre;
|
19966
|
-
}
|
19967
19971
|
@page {
|
19968
19972
|
size: ${orient};
|
19969
19973
|
margin: 0;
|
19974
|
+
padding: 0;
|
19970
19975
|
}
|
19971
19976
|
div {
|
19972
19977
|
width: ${width}mm;
|
19973
|
-
|
19978
|
+
height: ${height}mm;
|
19974
19979
|
font-size: 0;
|
19975
19980
|
}
|
19976
19981
|
@media print {
|
@@ -19978,6 +19983,7 @@ function createPrintTemplate({ width, height, orient }) {
|
|
19978
19983
|
body {
|
19979
19984
|
width: ${width}mm;
|
19980
19985
|
height: ${height}mm;
|
19986
|
+
margin: 0;
|
19981
19987
|
}
|
19982
19988
|
div {
|
19983
19989
|
width: initial;
|
@@ -27166,22 +27172,26 @@ class DocEditor {
|
|
27166
27172
|
*/
|
27167
27173
|
setCursor() {
|
27168
27174
|
this.selectionState;
|
27169
|
-
if (!this.canSetCursor() || !this.
|
27175
|
+
if (!this.canSetCursor() || !this.selectionState.startHitInfo) {
|
27170
27176
|
this.selectionState.editable = false;
|
27171
27177
|
this.docCtx.selectionState.cursorPos = null;
|
27172
|
-
this.
|
27178
|
+
const cursorRect = this.getCursorRect();
|
27179
|
+
this.hiddenInput(false, cursorRect);
|
27173
27180
|
return false;
|
27174
27181
|
}
|
27175
27182
|
const cursorRect = this.getCursorRect();
|
27176
27183
|
this.docCtx.cursorRect = ElementUtil.cloneRect(cursorRect);
|
27177
27184
|
this.selectionState.cursorPos = cursorRect;
|
27178
|
-
const abPos =
|
27185
|
+
const abPos = ElementUtil.cloneRect(cursorRect);
|
27179
27186
|
this.setCursorPosition(abPos);
|
27180
27187
|
//this.documentEvent.invokeCursor(startControl);
|
27181
27188
|
return true;
|
27182
27189
|
}
|
27183
27190
|
getCursorRect() {
|
27184
27191
|
try {
|
27192
|
+
if (!this.documentEvent.startHitInfo) {
|
27193
|
+
return { x: 0, y: 0, width: 0, height: 0 };
|
27194
|
+
}
|
27185
27195
|
const { startControl, startOffset } = this.selectionState;
|
27186
27196
|
const { startRegion, hitDocIndex } = this.documentEvent.startHitInfo;
|
27187
27197
|
const cursorPos = DocumentCursor.getElementCursorPos(startControl, startOffset, startRegion, hitDocIndex);
|
@@ -27198,14 +27208,16 @@ class DocEditor {
|
|
27198
27208
|
*/
|
27199
27209
|
setCursorVisibility(visibility) {
|
27200
27210
|
if (visibility) {
|
27211
|
+
this.editInput.style.removeProperty('display');
|
27201
27212
|
this.editInput.focus();
|
27202
27213
|
}
|
27203
27214
|
}
|
27204
|
-
hiddenInput(reset = true) {
|
27215
|
+
hiddenInput(reset = true, pos = null) {
|
27205
27216
|
//this.input.style.display = 'none';
|
27206
|
-
this.editInput.style.left = '-2px';
|
27207
|
-
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';
|
27208
27219
|
this.editInput.readOnly = true;
|
27220
|
+
this.editInput.style.display = 'none';
|
27209
27221
|
!reset && this.editInput.focus();
|
27210
27222
|
}
|
27211
27223
|
/**
|
@@ -27220,22 +27232,6 @@ class DocEditor {
|
|
27220
27232
|
this.setCursorVisibility(true);
|
27221
27233
|
//this.setCursorInputStatus();
|
27222
27234
|
}
|
27223
|
-
/**
|
27224
|
-
* 将相对坐标位置转换为绝对坐标位
|
27225
|
-
* 由于缩放,导致绝对位置=相对位置*scale
|
27226
|
-
* @param pos
|
27227
|
-
*/
|
27228
|
-
transToAbsolutePos(pos) {
|
27229
|
-
const { scale } = this.viewOptions;
|
27230
|
-
this.documentPaint.docContainer.rect.x;
|
27231
|
-
this.documentPaint.docContainer.rect.y;
|
27232
|
-
pos.x = pos.x * scale;
|
27233
|
-
pos.y = pos.y * scale;
|
27234
|
-
if ('height' in pos) {
|
27235
|
-
pos.height = pos.height * scale;
|
27236
|
-
}
|
27237
|
-
return pos;
|
27238
|
-
}
|
27239
27235
|
/**
|
27240
27236
|
* 判断是否光标可以设置接受编辑
|
27241
27237
|
* @returns
|