@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 CHANGED
@@ -3391,7 +3391,9 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3391
3391
  sel: 'g#page-num',
3392
3392
  data: {
3393
3393
  ns: 'http://www.w3.org/2000/svg',
3394
- attrs: {}
3394
+ attrs: {
3395
+ xmlns: 'http://www.w3.org/2000/svg'
3396
+ }
3395
3397
  },
3396
3398
  children: []
3397
3399
  };
@@ -3424,7 +3426,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3424
3426
  ns: "http://www.w3.org/2000/svg",
3425
3427
  attrs: {
3426
3428
  id: "selection",
3427
- }
3429
+ },
3428
3430
  },
3429
3431
  children: []
3430
3432
  };
@@ -3449,7 +3451,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3449
3451
  height: this.rect.height,
3450
3452
  viewBox: `0 0 ${this.rect.width} ${this.rect.height}`,
3451
3453
  overflow: "hidden"
3452
- }
3454
+ },
3453
3455
  },
3454
3456
  children: [
3455
3457
  pageCorner, highlight, ...CommonUtil.toArray(event.getChildNodes(this)), pageNum, selection
@@ -4792,15 +4794,19 @@ class TextGroupRenderObject extends LeafRenderObject {
4792
4794
  else if (props.vertAlign === 'superscript') ;
4793
4795
  const fontSize = (props.vertAlign ? props.fontSize * 3 / 5 : props.fontSize);
4794
4796
  const arr = [];
4797
+ let text = '';
4795
4798
  this.textMeasures.reduce((prev, curr) => {
4796
- arr.push(prev);
4799
+ if (curr.char !== ' ') {
4800
+ arr.push(prev);
4801
+ text += curr.char;
4802
+ }
4797
4803
  return curr.actualSize + prev;
4798
4804
  }, this.rect.x);
4799
4805
  const x = arr.join(' ');
4800
4806
  const y = this.rect.y + vertHeight; //this.textMeasures.map(item => this.rect.y + vertHeight).join(' ');
4801
- const text = this.textMeasures.map(item => {
4802
- return item.char;
4803
- }).join('');
4807
+ // const text = this.textMeasures.map(item => {
4808
+ // return item.char
4809
+ // }).join('');
4804
4810
  const t = {
4805
4811
  sel: 'text',
4806
4812
  text: text,
@@ -13362,6 +13368,7 @@ class EditorContext {
13362
13368
  this._document.destroy();
13363
13369
  }
13364
13370
  this.clearPrevDocCb = null;
13371
+ this.selectionState.startHitInfo = null;
13365
13372
  };
13366
13373
  }
13367
13374
  clear() {
@@ -19991,16 +19998,14 @@ function createPrintTemplate({ width, height, orient }) {
19991
19998
  box-sizing: border-box;
19992
19999
  -moz-box-sizing: border-box;
19993
20000
  }
19994
- body *{
19995
- white-space: pre;
19996
- }
19997
20001
  @page {
19998
20002
  size: ${orient};
19999
20003
  margin: 0;
20004
+ padding: 0;
20000
20005
  }
20001
20006
  div {
20002
20007
  width: ${width}mm;
20003
- min-height: ${height}mm;
20008
+ height: ${height}mm;
20004
20009
  font-size: 0;
20005
20010
  }
20006
20011
  @media print {
@@ -20008,6 +20013,7 @@ function createPrintTemplate({ width, height, orient }) {
20008
20013
  body {
20009
20014
  width: ${width}mm;
20010
20015
  height: ${height}mm;
20016
+ margin: 0;
20011
20017
  }
20012
20018
  div {
20013
20019
  width: initial;
@@ -27196,22 +27202,26 @@ class DocEditor {
27196
27202
  */
27197
27203
  setCursor() {
27198
27204
  this.selectionState;
27199
- if (!this.canSetCursor() || !this.documentEvent.startHitInfo) {
27205
+ if (!this.canSetCursor() || !this.selectionState.startHitInfo) {
27200
27206
  this.selectionState.editable = false;
27201
27207
  this.docCtx.selectionState.cursorPos = null;
27202
- this.hiddenInput(false);
27208
+ const cursorRect = this.getCursorRect();
27209
+ this.hiddenInput(false, cursorRect);
27203
27210
  return false;
27204
27211
  }
27205
27212
  const cursorRect = this.getCursorRect();
27206
27213
  this.docCtx.cursorRect = ElementUtil.cloneRect(cursorRect);
27207
27214
  this.selectionState.cursorPos = cursorRect;
27208
- const abPos = this.transToAbsolutePos(ElementUtil.cloneRect(cursorRect));
27215
+ const abPos = ElementUtil.cloneRect(cursorRect);
27209
27216
  this.setCursorPosition(abPos);
27210
27217
  //this.documentEvent.invokeCursor(startControl);
27211
27218
  return true;
27212
27219
  }
27213
27220
  getCursorRect() {
27214
27221
  try {
27222
+ if (!this.documentEvent.startHitInfo) {
27223
+ return { x: 0, y: 0, width: 0, height: 0 };
27224
+ }
27215
27225
  const { startControl, startOffset } = this.selectionState;
27216
27226
  const { startRegion, hitDocIndex } = this.documentEvent.startHitInfo;
27217
27227
  const cursorPos = DocumentCursor.getElementCursorPos(startControl, startOffset, startRegion, hitDocIndex);
@@ -27228,14 +27238,16 @@ class DocEditor {
27228
27238
  */
27229
27239
  setCursorVisibility(visibility) {
27230
27240
  if (visibility) {
27241
+ this.editInput.style.removeProperty('display');
27231
27242
  this.editInput.focus();
27232
27243
  }
27233
27244
  }
27234
- hiddenInput(reset = true) {
27245
+ hiddenInput(reset = true, pos = null) {
27235
27246
  //this.input.style.display = 'none';
27236
- this.editInput.style.left = '-2px';
27237
- 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';
27238
27249
  this.editInput.readOnly = true;
27250
+ this.editInput.style.display = 'none';
27239
27251
  !reset && this.editInput.focus();
27240
27252
  }
27241
27253
  /**
@@ -27250,22 +27262,6 @@ class DocEditor {
27250
27262
  this.setCursorVisibility(true);
27251
27263
  //this.setCursorInputStatus();
27252
27264
  }
27253
- /**
27254
- * 将相对坐标位置转换为绝对坐标位
27255
- * 由于缩放,导致绝对位置=相对位置*scale
27256
- * @param pos
27257
- */
27258
- transToAbsolutePos(pos) {
27259
- const { scale } = this.viewOptions;
27260
- this.documentPaint.docContainer.rect.x;
27261
- this.documentPaint.docContainer.rect.y;
27262
- pos.x = pos.x * scale;
27263
- pos.y = pos.y * scale;
27264
- if ('height' in pos) {
27265
- pos.height = pos.height * scale;
27266
- }
27267
- return pos;
27268
- }
27269
27265
  /**
27270
27266
  * 判断是否光标可以设置接受编辑
27271
27267
  * @returns