@hailin-zheng/editor-core 1.1.0 → 1.1.2

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.
@@ -1,5 +1,6 @@
1
1
  export declare const ViewConfig: {
2
2
  surfaceBgColor: string;
3
+ showMousePositionLine: boolean;
3
4
  primaryColor: string;
4
5
  onPrimaryColor: string;
5
6
  themeSecondaryColor: string;
@@ -26,6 +26,7 @@ export declare class SurfaceView extends NodeItems {
26
26
  measureOverride(e: IMeasureEvent, availableSize: Size): Size;
27
27
  protected arrangeOverride(e: IArrangeEvent, finalSize: Size): Size;
28
28
  render(e: IRenderData): void;
29
+ private drawMouseLinePosition;
29
30
  start(): void;
30
31
  popNodes: Array<NodeCore>;
31
32
  registerPopNode(node: NodeCore): void;
package/index-cjs.js CHANGED
@@ -1472,6 +1472,8 @@ class ViewOptions {
1472
1472
  trackHistoryMaxLength = 500;
1473
1473
  //开启动态脚本功能
1474
1474
  enableDyExpression = false;
1475
+ //是否显示标尺
1476
+ showRule = true;
1475
1477
  //整页模式,不分页
1476
1478
  _fullPageView = false;
1477
1479
  get fullPageView() {
@@ -4481,7 +4483,7 @@ class PSymbolElement extends LeafElement {
4481
4483
  super('psym');
4482
4484
  this.textProps = new TextProps();
4483
4485
  this.textProps.fontSize = this.defaultHeight;
4484
- this.textProps.fontName = '楷体';
4486
+ this.textProps.fontName = 'sans-serif';
4485
4487
  this.textProps.color = '#8c8c8c';
4486
4488
  }
4487
4489
  createRenderObject() {
@@ -4508,7 +4510,7 @@ class PSymbolRenderObject extends LeafRenderObject {
4508
4510
  if (render.drawMode === 'print') {
4509
4511
  return;
4510
4512
  }
4511
- render.contentContext.drawText('', this.element.textProps, position.x, position.y, 20, this.rect.height);
4513
+ render.contentContext.drawText('', this.element.textProps, position.x, position.y, 20, this.rect.height);
4512
4514
  }
4513
4515
  //绘制段落符号
4514
4516
  clone() {
@@ -11862,7 +11864,17 @@ class DynamicContextParser {
11862
11864
  return condition() ? truePart() : falsePart();
11863
11865
  }
11864
11866
  Number(val) {
11865
- return Number.parseInt(val);
11867
+ if (typeof val === 'number') {
11868
+ return val;
11869
+ }
11870
+ else if (typeof val === 'string') {
11871
+ const parseVal = Number.parseInt(val.trim());
11872
+ if (Number.isNaN(parseVal)) {
11873
+ return 0;
11874
+ }
11875
+ return parseVal;
11876
+ }
11877
+ return 0;
11866
11878
  }
11867
11879
  TableData(tableId, startRow, startCol, endRow, endCol) {
11868
11880
  const tb = this.doc.treeFind(item => item instanceof TableElement && item.props.id === tableId);
@@ -12093,7 +12105,6 @@ class ParagraphMeasure {
12093
12105
  */
12094
12106
  setParaTextAlign(counter, paraLineIndex, paraElement, limitWidth, paraLineRender) {
12095
12107
  let indent = paraLineRender.startX;
12096
- paraLineRender.line.rect.width = limitWidth;
12097
12108
  if (paraElement.props.textAlign === 'center') {
12098
12109
  const remainSpace = limitWidth - paraLineRender.line.rect.width;
12099
12110
  const startX = Math.ceil(remainSpace / 2) + indent;
@@ -12117,6 +12128,7 @@ class ParagraphMeasure {
12117
12128
  //return indent;
12118
12129
  }
12119
12130
  else ;
12131
+ paraLineRender.line.rect.width = limitWidth;
12120
12132
  }
12121
12133
  /**
12122
12134
  * 设置两端对齐
@@ -14235,7 +14247,7 @@ class PageBreakRenderObject extends LeafRenderObject {
14235
14247
  if (render.drawMode === 'print') {
14236
14248
  return;
14237
14249
  }
14238
- render.contentContext.drawText('', this.element.textProps, position.x, position.y, 20, this.rect.height);
14250
+ render.contentContext.drawText('', this.element.textProps, position.x, position.y, 20, this.rect.height);
14239
14251
  }
14240
14252
  clone() {
14241
14253
  const render = new PageBreakRenderObject(this.element);
@@ -14758,7 +14770,8 @@ class DocumentEvent {
14758
14770
  };
14759
14771
  }
14760
14772
  }
14761
- if (!this.ismousedown) {
14773
+ //只有设计模式时,才需要进行边界判断,方可调整表格列宽等
14774
+ if (!this.ismousedown && this.viewOptions.docMode === exports.DocMode.Design) {
14762
14775
  this.edgeRenderInfo = edgeRenderInfo;
14763
14776
  }
14764
14777
  //存在边界元素,并且当前边界处于鼠标按下状态
@@ -18618,6 +18631,7 @@ class ButtonBase extends TextBase {
18618
18631
 
18619
18632
  const ViewConfig = {
18620
18633
  surfaceBgColor: '#f0f0f0',
18634
+ showMousePositionLine: false,
18621
18635
  primaryColor: '#6750A4',
18622
18636
  onPrimaryColor: '#FFFFFF',
18623
18637
  themeSecondaryColor: '#2b88d8',
@@ -19439,8 +19453,8 @@ class ViewPaint {
19439
19453
  let { x, y } = lines[i];
19440
19454
  x = Math.ceil(x);
19441
19455
  y = Math.ceil(y);
19442
- x += 0.5;
19443
- y += 0.5;
19456
+ // x += 0.5;
19457
+ // y += 0.5;
19444
19458
  if (i === 0) {
19445
19459
  this.ctx.moveTo(x, y);
19446
19460
  }
@@ -19463,8 +19477,8 @@ class ViewPaint {
19463
19477
  }
19464
19478
  }
19465
19479
  drawRadioBox(x, y, width, height, isChecked) {
19466
- x = x + Math.floor(width / 2);
19467
- y = y + Math.floor(height / 2);
19480
+ // x = x + Math.floor(width / 2);
19481
+ // y = y + Math.floor(height / 2);
19468
19482
  width = Math.floor(width / 2);
19469
19483
  this.ctx.save();
19470
19484
  this.ctx.strokeStyle = 'black';
@@ -19608,6 +19622,13 @@ class SurfaceView extends NodeItems {
19608
19622
  this.reLayout = false;
19609
19623
  }
19610
19624
  e.render.fillRect(0, 0, this.finalRect.width, this.finalRect.height, ViewConfig.surfaceBgColor);
19625
+ e.next(e.render);
19626
+ this.drawMouseLinePosition(e);
19627
+ }
19628
+ drawMouseLinePosition(e) {
19629
+ {
19630
+ return;
19631
+ }
19611
19632
  }
19612
19633
  start() {
19613
19634
  this.renderSchedule = renderApp(this, this.renderCtx, this.nodeEvent);
@@ -20892,8 +20913,6 @@ class CanvasTextEditor extends NodeItems {
20892
20913
  pagePL = left;
20893
20914
  pagePR = right;
20894
20915
  }
20895
- // this.docRule.setRuleOptions({width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft});
20896
- // this.docRule.refreshRule();
20897
20916
  this.rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
20898
20917
  }
20899
20918
  createDocViewer() {
@@ -20992,12 +21011,17 @@ class CanvasTextEditor extends NodeItems {
20992
21011
  this.documentPaint.rePages();
20993
21012
  });
20994
21013
  this.updateDocSize();
20995
- //页面高度
20996
- // this.documentSelection.updateSelectionState();
20997
- // this.selectionOverlays.getSelectionTreeData();
20998
- // this.beforeRenderSubject.next();
20999
21014
  }
21000
- //生成选区内容对象
21015
+ this.updateSelection();
21016
+ this.refreshDocRule();
21017
+ this.onChanged();
21018
+ //this.refreshView();
21019
+ }
21020
+ /**
21021
+ * 计算选区内容对象
21022
+ * @private
21023
+ */
21024
+ updateSelection() {
21001
21025
  let ssChanged = false;
21002
21026
  try {
21003
21027
  //防止由于选区不正确导致的错误,导致后续的当前任务无法释放
@@ -21008,18 +21032,12 @@ class CanvasTextEditor extends NodeItems {
21008
21032
  }
21009
21033
  this.selectionOverlays.getSelectionTreeData();
21010
21034
  ssChanged && this.selectionChanged.next(this.documentSelection.selectionState);
21011
- this.refreshDocRule();
21012
- this.onChanged();
21013
- //this.refreshView();
21014
21035
  }
21015
21036
  /**
21016
21037
  * 刷新绘制文档
21017
21038
  * @param rePaint
21018
21039
  */
21019
21040
  refreshView() {
21020
- // const ssChanged = this.documentSelection.updateSelectionState();
21021
- // this.selectionOverlays.getSelectionTreeData();
21022
- // ssChanged && this.selectionChanged.next(this.documentSelection.selectionState);
21023
21041
  this.documentPaint.refreshView();
21024
21042
  this.setCursor();
21025
21043
  }
@@ -21211,8 +21229,6 @@ class CanvasTextEditor extends NodeItems {
21211
21229
  let minDocViewWidth = pageWidth + this.viewOptions.docSpace * 2;
21212
21230
  let maxDocViewWidth = this.surfaceView.width;
21213
21231
  this.width = Math.max(minDocViewWidth, maxDocViewWidth) - ScrollBarSize;
21214
- // this.viewOptions.viewSettings.width = this.width;
21215
- // this.viewOptions.viewSettings.height = this.scrollView.height as number;
21216
21232
  const docSize = this.documentPaint.getDocumentContainerHeight();
21217
21233
  this.height = docSize.height;
21218
21234
  this.updateRenderCtx();
@@ -21225,6 +21241,7 @@ class CanvasTextEditor extends NodeItems {
21225
21241
  this.updateRenderCtx();
21226
21242
  this.documentPaint.layoutPages();
21227
21243
  this.refreshDocument();
21244
+ this.updateLayout();
21228
21245
  }
21229
21246
  /**
21230
21247
  * 缩放视图
@@ -21713,7 +21730,6 @@ class CanvasTextEditor extends NodeItems {
21713
21730
  this.viewOptions.viewSettings.height = data.height;
21714
21731
  this.updateDocSize();
21715
21732
  this.resetViewer();
21716
- this.updateLayout();
21717
21733
  });
21718
21734
  surface.addChild(scrollView);
21719
21735
  const rule2 = new RuleControl(this.docCtx);
@@ -21723,6 +21739,7 @@ class CanvasTextEditor extends NodeItems {
21723
21739
  rule2.x = 20;
21724
21740
  rule2.y = 500;
21725
21741
  surface.addChild(rule2);
21742
+ //surface.addChild(win);
21726
21743
  surface.start();
21727
21744
  }
21728
21745
  /**
@@ -21732,7 +21749,18 @@ class CanvasTextEditor extends NodeItems {
21732
21749
  this.rule.x = (this.viewOptions.viewSettings.width - this.rule.width) / 2;
21733
21750
  this.rule.y = 0;
21734
21751
  this.rule.width = this.viewOptions.docPageSettings.width;
21735
- this.scrollView.height = this.viewOptions.viewSettings.height - this.rule.ruleSize;
21752
+ if (!this.viewOptions.showRule) {
21753
+ this.rule.visible = false;
21754
+ this.rule.height = 0;
21755
+ this.scrollView.y = 0;
21756
+ this.scrollView.height = this.viewOptions.viewSettings.height - this.scrollView.y;
21757
+ }
21758
+ else {
21759
+ this.rule.height = 30;
21760
+ this.rule.visible = true;
21761
+ this.scrollView.y = this.rule.ruleSize;
21762
+ this.scrollView.height = this.viewOptions.viewSettings.height - this.scrollView.y;
21763
+ }
21736
21764
  }
21737
21765
  createMenu() {
21738
21766
  const menu = new Menu();