@hailin-zheng/editor-core 1.1.21 → 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];
@@ -11508,10 +11508,14 @@ class ParagraphMeasure {
11508
11508
  setAlignJustify(render, count, spaceWidth) {
11509
11509
  if (render instanceof BranchRenderObject) {
11510
11510
  let width = 0;
11511
+ //累计元素的偏移量
11512
+ let offset = 0;
11511
11513
  for (let i = 0; i < render.length; i++) {
11512
11514
  const currRender = render.getChild(i);
11515
+ const currWidth = currRender.rect.width;
11513
11516
  count += this.setAlignJustify(currRender, count, spaceWidth);
11514
- currRender.rect.x += width;
11517
+ currRender.rect.x += offset;
11518
+ offset += currRender.rect.width - currWidth;
11515
11519
  width += currRender.rect.width;
11516
11520
  }
11517
11521
  render.rect.width = width;
@@ -19299,8 +19303,8 @@ class SurfaceView extends NodeItems {
19299
19303
  class LabelNode extends TextBase {
19300
19304
  constructor() {
19301
19305
  super();
19302
- this.border = 1;
19303
- this.borderColor = '#000';
19306
+ // this.border=1;
19307
+ // this.borderColor='#000';
19304
19308
  }
19305
19309
  _textWrapping = 'no';
19306
19310
  get textWrapping() {
@@ -20651,7 +20655,7 @@ class TimelineControl extends AbsolutePanel {
20651
20655
  }, 0);
20652
20656
  return finalSize;
20653
20657
  }
20654
- rebuild() {
20658
+ reBuild() {
20655
20659
  treeForEach(this, item => {
20656
20660
  if (item instanceof NodeItems) {
20657
20661
  return item.controls;
@@ -20835,7 +20839,7 @@ class TimelineGridControl extends TimelineBaseControl {
20835
20839
  value: this.randomNum(70, 150)
20836
20840
  });
20837
20841
  }
20838
- this.eventData.push({ date: moment$1(this.startTime).add(i, 'days').toDate(), value: '入\r\n' });
20842
+ this.eventData.push({ date: moment$1(this.startTime).add(i, 'days').toDate(), value: '入\r\n院\r\n111' });
20839
20843
  }
20840
20844
  this.temperatureData.sort((prev, curr) => {
20841
20845
  return curr.date > prev.date ? 1 : -1;
@@ -20843,6 +20847,10 @@ class TimelineGridControl extends TimelineBaseControl {
20843
20847
  this.heartRateData.sort((prev, curr) => curr.date > prev.date ? 1 : -1);
20844
20848
  }
20845
20849
  buildOverride(e) {
20850
+ this.temperatureData.length = 0;
20851
+ this.heartRateData.length = 0;
20852
+ this.eventData.length = 0;
20853
+ this.init();
20846
20854
  this.buildTemperature(e);
20847
20855
  this.buildHearRate(e);
20848
20856
  this.buildStampUnit(e);
@@ -21625,7 +21633,7 @@ function createTimeline() {
21625
21633
  const timeGridContainer = new TimeGridContainer();
21626
21634
  //timeGridContainer.y = 80;
21627
21635
  const timelineGridControl = timeGridContainer.timelineGridControl; //new TimeLineControl();
21628
- timelineGridControl.showDays = 30;
21636
+ timelineGridControl.showDays = 100;
21629
21637
  timelineGridControl.width = timelineGridControl.getLayoutWidth();
21630
21638
  timelineGridControl.height = 300;
21631
21639
  timelineGridControl.init();
@@ -22615,6 +22623,11 @@ class CanvasTextEditor extends AbsolutePanel {
22615
22623
  surface.addChild(scrollView);
22616
22624
  surface.addChild(rule2);
22617
22625
  //surface.addChild(win);
22626
+ //
22627
+ // setInterval(()=>{
22628
+ // timeLineControl.reBuild();
22629
+ // this.onChanged();
22630
+ // },20)
22618
22631
  surface.start();
22619
22632
  }
22620
22633
  /**