@hailin-zheng/editor-core 1.1.22 → 1.1.23

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.js CHANGED
@@ -2,8 +2,8 @@ import { nanoid } from 'nanoid';
2
2
  import moment from 'moment';
3
3
  import * as acor from 'acorn';
4
4
  import { generate } from 'astring';
5
- import * as estraverse from 'estraverse';
6
- import bwipjs from 'bwip-js';
5
+ import estraverse from 'estraverse';
6
+ import * as bwipjs from 'bwip-js';
7
7
  import moment$1 from 'moment/moment';
8
8
 
9
9
  /**
@@ -4090,7 +4090,6 @@ class DocumentContainerRender extends BlockContainerRenderObject {
4090
4090
 
4091
4091
  class TextGroupElement extends LeafElement {
4092
4092
  textMeasures = [];
4093
- fontBoundingBox;
4094
4093
  isMeasure = false;
4095
4094
  constructor() {
4096
4095
  super('text');
@@ -4130,7 +4129,7 @@ class TextGroupElement extends LeafElement {
4130
4129
  createRenderObject(data) {
4131
4130
  if (!this.isMeasure || this.modifyFlag !== ModifyFlag$1.None || !this.cacheRender) {
4132
4131
  data.renderCtx.contentContext.measureTextUnits(this.textMeasures, this.props);
4133
- this.fontBoundingBox = data.renderCtx.contentContext.measureTextMetrics(this.props.getFont());
4132
+ //data.renderCtx.contentContext.measureTextMetrics(this.props.getFont());
4134
4133
  this.isMeasure = true;
4135
4134
  }
4136
4135
  const render = new TextGroupRenderObject(this);
@@ -4204,7 +4203,7 @@ class TextGroupRenderObject extends LeafRenderObject {
4204
4203
  if (this.element.props.border) {
4205
4204
  render.contentContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height);
4206
4205
  }
4207
- render.contentContext.drawTextUnits(this, position.x, position.y, this.element.fontBoundingBox.fontBoundingBoxAscent);
4206
+ render.contentContext.drawTextUnits(this, position.x, position.y + (this.rect.height - this.element.props.fontSize) / 2);
4208
4207
  }
4209
4208
  constructor(element) {
4210
4209
  super(element);
@@ -4223,7 +4222,8 @@ class TextGroupRenderObject extends LeafRenderObject {
4223
4222
  }
4224
4223
  measure() {
4225
4224
  this.rect.width = this.textMeasures.reduce((prev, curr) => prev + curr.actualSize, 0);
4226
- this.rect.height = this.element.fontBoundingBox.fontBoundingBoxAscent + this.element.fontBoundingBox.fontBoundingBoxDescent;
4225
+ this.rect.height = Math.ceil(this.element.props.fontSize * 1.4);
4226
+ // this.element.fontBoundingBox.fontBoundingBoxAscent + this.element.fontBoundingBox.fontBoundingBoxDescent;
4227
4227
  }
4228
4228
  }
4229
4229
  class TextGroupFactory extends ElementFactory {
@@ -4563,7 +4563,7 @@ class DocumentCursor {
4563
4563
  if (['superscript', 'subscript'].indexOf(ele.props.vertAlign) >= 0) {
4564
4564
  rect.height -= ele.props.fontSize / 2;
4565
4565
  if (ele.props.vertAlign === 'subscript') {
4566
- rect.y += rect.height;
4566
+ rect.y += rect.height * 2 / 5;
4567
4567
  }
4568
4568
  }
4569
4569
  rect.x += horX;
@@ -7781,7 +7781,7 @@ class PaintContent {
7781
7781
  this.init();
7782
7782
  }
7783
7783
  init() {
7784
- this.ctx.textBaseline = 'alphabetic';
7784
+ this.ctx.textBaseline = 'top';
7785
7785
  }
7786
7786
  setGlobalAlpha(alpha) {
7787
7787
  this.ctx.globalAlpha = alpha;
@@ -7800,8 +7800,8 @@ class PaintContent {
7800
7800
  this.ctx.save();
7801
7801
  this.ctx.fillStyle = textProps.color;
7802
7802
  this.ctx.font = textProps.getFont();
7803
- const vertHeight = textProps.vertAlign === 'superscript' ? 0 : height;
7804
- this.ctx.fillText(text, x, y + vertHeight - height / 7);
7803
+ const vertHeight = 0; // textProps.vertAlign === 'superscript' ? 0 : height;
7804
+ this.ctx.fillText(text, x, y + vertHeight);
7805
7805
  this.ctx.restore();
7806
7806
  if (textProps.linethrough) {
7807
7807
  this.drawHoriLine(x, y + (Math.ceil(height / 2)), width, textProps.color, 1);
@@ -7821,7 +7821,7 @@ class PaintContent {
7821
7821
  this.ctx.fill();
7822
7822
  this.ctx.restore();
7823
7823
  }
7824
- drawTextUnits(textGroupRender, x, y, baseLine) {
7824
+ drawTextUnits(textGroupRender, x, y) {
7825
7825
  const textEle = textGroupRender.element;
7826
7826
  const textProps = textEle.props;
7827
7827
  const { width, height } = textGroupRender.rect;
@@ -7844,10 +7844,10 @@ class PaintContent {
7844
7844
  this.drawHoriLine(x, y, width, textProps.color, 1);
7845
7845
  }
7846
7846
  let horX = 0;
7847
- let vertHeight = baseLine;
7848
- if (textProps.vertAlign === 'superscript') {
7847
+ let vertHeight = 0; //baseLine;
7848
+ if (textProps.vertAlign === 'subscript') {
7849
7849
  //到top
7850
- vertHeight -= textProps.fontSize * 2 / 5;
7850
+ vertHeight += textProps.fontSize * 2 / 5;
7851
7851
  }
7852
7852
  for (let i = 0; i < textGroupRender.textMeasures.length; i++) {
7853
7853
  const unit = textGroupRender.textMeasures[i];