@hailin-zheng/editor-core 1.1.1 → 1.1.3
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/controls/Config.d.ts +1 -0
- package/controls/ScrollView.d.ts +1 -0
- package/controls/SurfaceView.d.ts +1 -0
- package/controls/ViewPaint.d.ts +2 -2
- package/index-cjs.js +183 -86
- package/index-cjs.js.map +1 -1
- package/index.js +183 -87
- package/index.js.map +1 -1
- package/med_editor/framework/document-event.d.ts +1 -1
- package/med_editor/framework/element-define.d.ts +3 -0
- package/med_editor/framework/event-subject.d.ts +3 -1
- package/med_editor/framework/impl/data-element/data-element-base-impl.d.ts +5 -0
- package/med_editor/framework/impl/data-element/data-element-group-impl.d.ts +1 -2
- package/med_editor/framework/paragraph-arrange.d.ts +1 -0
- package/med_editor/framework/render-context.d.ts +3 -2
- package/med_editor/framework/render-define.d.ts +1 -0
- package/med_editor/texteditor.d.ts +8 -1
- package/package.json +1 -1
package/index-cjs.js
CHANGED
@@ -394,6 +394,7 @@ class BlockContentRenderObject extends BranchRenderObject {
|
|
394
394
|
}
|
395
395
|
}
|
396
396
|
class InlineGroupRenderObject extends BranchRenderObject {
|
397
|
+
paintPos;
|
397
398
|
}
|
398
399
|
/**
|
399
400
|
* 包含块级渲染元素的容器元素,例如body、table-cell等
|
@@ -935,8 +936,10 @@ class Subject$1 extends EventSourceCore$1 {
|
|
935
936
|
this.addSub(sub);
|
936
937
|
return sub;
|
937
938
|
}
|
938
|
-
|
939
|
-
|
939
|
+
}
|
940
|
+
class OnceSubject extends Subject$1 {
|
941
|
+
subscribe(listener) {
|
942
|
+
const sub = super.subscribe(listener);
|
940
943
|
sub.once = true;
|
941
944
|
return sub;
|
942
945
|
}
|
@@ -1323,13 +1326,23 @@ class BranchElement extends Element {
|
|
1323
1326
|
}
|
1324
1327
|
else {
|
1325
1328
|
this.modifyFlag = exports.ModifyFlag.Modify;
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
+
clearChildrenRenderCache(this);
|
1330
|
+
// for (let i = 0; i < this.length; i++) {
|
1331
|
+
// this.getChild(i).pubOnChange('to-child')
|
1332
|
+
// }
|
1329
1333
|
}
|
1330
1334
|
this._onChangeEvent.next();
|
1331
1335
|
}
|
1332
1336
|
}
|
1337
|
+
function clearChildrenRenderCache(ele) {
|
1338
|
+
for (let i = 0; i < ele.length; i++) {
|
1339
|
+
const curr = ele.getChild(i);
|
1340
|
+
curr.cacheRender = null;
|
1341
|
+
if (curr instanceof BranchElement) {
|
1342
|
+
clearChildrenRenderCache(curr);
|
1343
|
+
}
|
1344
|
+
}
|
1345
|
+
}
|
1333
1346
|
/**
|
1334
1347
|
* 行内编组元素
|
1335
1348
|
*/
|
@@ -1443,6 +1456,8 @@ class ViewOptions {
|
|
1443
1456
|
defaultColor = "rgb(0,0,0)";
|
1444
1457
|
selectionOverlaysColor = 'rgb(131,175,155,0.5)';
|
1445
1458
|
dataEleOverlaysColor = 'rgb(131,175,155,0.5)';
|
1459
|
+
dataEleFocusedBgColor = 'rgb(131,175,155,0.8)';
|
1460
|
+
dataEleErrorBgColor = '#ff4d4f';
|
1446
1461
|
dataEleReadOnlyOverlayColor = '#d9d9d9';
|
1447
1462
|
dataEleOutlineColor = 'rgb(131,175,155,0.7)';
|
1448
1463
|
viewBackcolor = 'rgb(230,230,230)';
|
@@ -1474,6 +1489,8 @@ class ViewOptions {
|
|
1474
1489
|
enableDyExpression = false;
|
1475
1490
|
//是否显示标尺
|
1476
1491
|
showRule = true;
|
1492
|
+
//是否开启数据元输入验证功能
|
1493
|
+
enableDataEleInputValidate = false;
|
1477
1494
|
//整页模式,不分页
|
1478
1495
|
_fullPageView = false;
|
1479
1496
|
get fullPageView() {
|
@@ -3678,8 +3695,12 @@ class InlineGroupInputElement extends InlineGroupElement {
|
|
3678
3695
|
}
|
3679
3696
|
}
|
3680
3697
|
class DataElementInlineGroup extends InlineGroupInputElement {
|
3698
|
+
errorTip;
|
3681
3699
|
constructor(type) {
|
3682
3700
|
super(type);
|
3701
|
+
this.onChangeSubject.subscribe(() => {
|
3702
|
+
this.onChangedValidate();
|
3703
|
+
});
|
3683
3704
|
this.addEvent('ElementMousemove', (evt) => {
|
3684
3705
|
this.isMouseenter = true;
|
3685
3706
|
this.refreshView();
|
@@ -3743,6 +3764,21 @@ class DataElementInlineGroup extends InlineGroupInputElement {
|
|
3743
3764
|
this.expressFn = new Function();
|
3744
3765
|
}
|
3745
3766
|
}
|
3767
|
+
/**
|
3768
|
+
* 数据元发生更改后,进行数据验证
|
3769
|
+
*/
|
3770
|
+
onChangedValidate() {
|
3771
|
+
this.errorTip = '';
|
3772
|
+
const options = getCurrOptions(this);
|
3773
|
+
if (!options || !options.enableDataEleInputValidate) {
|
3774
|
+
return;
|
3775
|
+
}
|
3776
|
+
this.errorTip = this.validate();
|
3777
|
+
}
|
3778
|
+
}
|
3779
|
+
function getCurrOptions(ele) {
|
3780
|
+
const doc = ElementUtil.getParent(ele, item => item.type === 'doc');
|
3781
|
+
return doc?.viewOptions;
|
3746
3782
|
}
|
3747
3783
|
class DataElementRenderObject extends InlineGroupRenderObject {
|
3748
3784
|
render(e) {
|
@@ -3753,9 +3789,18 @@ class DataElementRenderObject extends InlineGroupRenderObject {
|
|
3753
3789
|
}
|
3754
3790
|
render.contentContext.tran(() => {
|
3755
3791
|
//绘制数据元区域底色
|
3792
|
+
let bgColor = '';
|
3756
3793
|
if (this.element.isMouseenter) {
|
3757
|
-
|
3758
|
-
|
3794
|
+
bgColor = this.element.props.editable ? viewOptions.dataEleOverlaysColor : viewOptions.dataEleReadOnlyOverlayColor;
|
3795
|
+
}
|
3796
|
+
if (this.element.isFocused) {
|
3797
|
+
bgColor = e.docCtx.viewOptions.dataEleFocusedBgColor;
|
3798
|
+
}
|
3799
|
+
if (this.element.errorTip) {
|
3800
|
+
bgColor = viewOptions.dataEleErrorBgColor;
|
3801
|
+
}
|
3802
|
+
if (bgColor) {
|
3803
|
+
render.overlaysContext.fillRect(position.x, position.y - 2, this.rect.width, this.rect.height + 4, bgColor);
|
3759
3804
|
}
|
3760
3805
|
if (this.element.props.secretBrowse && viewOptions.secretBrowse) {
|
3761
3806
|
render.contentContext.ctx.filter = "blur(10px)";
|
@@ -3777,23 +3822,25 @@ class DataElementRenderObject extends InlineGroupRenderObject {
|
|
3777
3822
|
* @private
|
3778
3823
|
*/
|
3779
3824
|
drawCaption(e) {
|
3780
|
-
|
3781
|
-
|
3782
|
-
|
3783
|
-
|
3784
|
-
|
3785
|
-
|
3825
|
+
e.render.onRenderCompleted.subscribe(() => {
|
3826
|
+
const { render, position, docCtx: { viewOptions } } = e;
|
3827
|
+
//获取到焦点时,绘制数据元标题
|
3828
|
+
if (render.drawMode === 'view' && this.element.isFocused && this.element.paintRenders.indexOf(this) === 0) {
|
3829
|
+
const { caption } = this.element.props;
|
3830
|
+
if (!caption) {
|
3831
|
+
return;
|
3832
|
+
}
|
3833
|
+
const textProps = new TextProps();
|
3834
|
+
textProps.fontSize = 16;
|
3835
|
+
textProps.fontName = viewOptions.defaultFontName;
|
3836
|
+
textProps.color = '#fff';
|
3837
|
+
const titleWidth = render.contentContext.measureText(caption, textProps).width;
|
3838
|
+
const x = position.x;
|
3839
|
+
const y = position.y - 20;
|
3840
|
+
render.contentContext.fillRect(x, y, titleWidth + 10, 20, 'blue');
|
3841
|
+
render.contentContext.drawText(caption, textProps, x + 5, y, titleWidth, 20);
|
3786
3842
|
}
|
3787
|
-
|
3788
|
-
textProps.fontSize = 16;
|
3789
|
-
textProps.fontName = viewOptions.defaultFontName;
|
3790
|
-
textProps.color = '#fff';
|
3791
|
-
const titleWidth = render.contentContext.measureText(caption, textProps).width;
|
3792
|
-
const x = position.x;
|
3793
|
-
const y = position.y - 20;
|
3794
|
-
render.contentContext.fillRect(x, y, titleWidth + 10, 20, 'blue');
|
3795
|
-
render.contentContext.drawText(caption, textProps, x + 5, y, titleWidth, 20);
|
3796
|
-
}
|
3843
|
+
});
|
3797
3844
|
}
|
3798
3845
|
}
|
3799
3846
|
const validateDataEle = (ele) => {
|
@@ -4483,7 +4530,7 @@ class PSymbolElement extends LeafElement {
|
|
4483
4530
|
super('psym');
|
4484
4531
|
this.textProps = new TextProps();
|
4485
4532
|
this.textProps.fontSize = this.defaultHeight;
|
4486
|
-
this.textProps.fontName = '
|
4533
|
+
this.textProps.fontName = 'sans-serif';
|
4487
4534
|
this.textProps.color = '#8c8c8c';
|
4488
4535
|
}
|
4489
4536
|
createRenderObject() {
|
@@ -4510,7 +4557,7 @@ class PSymbolRenderObject extends LeafRenderObject {
|
|
4510
4557
|
if (render.drawMode === 'print') {
|
4511
4558
|
return;
|
4512
4559
|
}
|
4513
|
-
render.contentContext.drawText('
|
4560
|
+
render.contentContext.drawText('↩', this.element.textProps, position.x, position.y, 20, this.rect.height);
|
4514
4561
|
}
|
4515
4562
|
//绘制段落符号
|
4516
4563
|
clone() {
|
@@ -4578,6 +4625,9 @@ class TableCellElement extends BlockContainerElement {
|
|
4578
4625
|
throw new Error('row is null');
|
4579
4626
|
}
|
4580
4627
|
const table = row.parent;
|
4628
|
+
if (!table) {
|
4629
|
+
debugger;
|
4630
|
+
}
|
4581
4631
|
const cellIndex = row.getChildIndex(this);
|
4582
4632
|
let cellWidth = table.getCellWidth(cellIndex);
|
4583
4633
|
const cellOffset = table.getCellOffsetX(cellIndex);
|
@@ -7623,8 +7673,7 @@ class RenderContext {
|
|
7623
7673
|
drawMode = 'view';
|
7624
7674
|
contentOffCanvas;
|
7625
7675
|
overlayOffCanvas;
|
7626
|
-
|
7627
|
-
onRenderCompleted = new Subject$1();
|
7676
|
+
onRenderCompleted = new OnceSubject();
|
7628
7677
|
constructor(mainContext) {
|
7629
7678
|
this.mainContext = mainContext;
|
7630
7679
|
}
|
@@ -7646,7 +7695,6 @@ class RenderContext {
|
|
7646
7695
|
this.pageRect = { x: 0, y: 0, width: pageSetting.width, height: pageSetting.height };
|
7647
7696
|
ElementUtil.setCanvasProps(this.contentOffCanvas, this.contentContext.ctx, pageSetting);
|
7648
7697
|
ElementUtil.setCanvasProps(this.overlayOffCanvas, this.overlaysContext.ctx, pageSetting);
|
7649
|
-
//ElementUtil.setCanvasProps(this.mainContext.ctx.canvas, this.mainContext.ctx, pageSetting)
|
7650
7698
|
}
|
7651
7699
|
clear() {
|
7652
7700
|
this.contentContext.clear();
|
@@ -8685,7 +8733,7 @@ class DataElementDate extends DataElementInlineGroup {
|
|
8685
8733
|
this.props.valueTextProps.clone(valueText.props);
|
8686
8734
|
valueText.text = formatStr;
|
8687
8735
|
this.addChild(valueText, this.length - 1);
|
8688
|
-
|
8736
|
+
this.onChangedValidate();
|
8689
8737
|
}
|
8690
8738
|
getValue() {
|
8691
8739
|
return ElementSerialize.serializeString(this);
|
@@ -8775,9 +8823,9 @@ class DataElementGroupElement extends InlineGroupInputElement {
|
|
8775
8823
|
}
|
8776
8824
|
}
|
8777
8825
|
class DataElementGroupRenderObject extends InlineGroupRenderObject {
|
8778
|
-
paintPos;
|
8779
8826
|
render(e) {
|
8780
8827
|
this.paintPos = e.position;
|
8828
|
+
e.render.onRenderCompleted.subscribe(() => { this.paintDecorate(e); });
|
8781
8829
|
}
|
8782
8830
|
getCurrentParaGroupRenders() {
|
8783
8831
|
const renders = [];
|
@@ -8790,7 +8838,7 @@ class DataElementGroupRenderObject extends InlineGroupRenderObject {
|
|
8790
8838
|
}
|
8791
8839
|
return renders;
|
8792
8840
|
}
|
8793
|
-
|
8841
|
+
paintDecorate(e) {
|
8794
8842
|
const { render, docCtx: { viewOptions } } = e;
|
8795
8843
|
const canPaint = this.element.isMouseenter || this.element.isFocused;
|
8796
8844
|
if (canPaint && this.element.paintRenders.indexOf(this) === 0) {
|
@@ -9051,6 +9099,7 @@ class DataElementList extends DataElementInlineGroup {
|
|
9051
9099
|
this.addChild(valueText, this.length - 1);
|
9052
9100
|
}
|
9053
9101
|
}
|
9102
|
+
this.onChangedValidate();
|
9054
9103
|
}
|
9055
9104
|
getValue() {
|
9056
9105
|
const values = ElementSerialize.serializeString(this);
|
@@ -9144,6 +9193,7 @@ class DataElementText extends DataElementInlineGroup {
|
|
9144
9193
|
valueText.text = val + '';
|
9145
9194
|
this.addChild(valueText, this.length - 1);
|
9146
9195
|
}
|
9196
|
+
this.onChangedValidate();
|
9147
9197
|
}
|
9148
9198
|
getValue() {
|
9149
9199
|
return ElementSerialize.serializeString(this, { all: false });
|
@@ -10980,8 +11030,6 @@ class ElementPaint {
|
|
10980
11030
|
}
|
10981
11031
|
paintPagePos;
|
10982
11032
|
drawPages(docContainer, selectedSets) {
|
10983
|
-
// this.rePaint = rePaint;
|
10984
|
-
//this.measureCommContainer = measureCommContainer;
|
10985
11033
|
this.selectedSets = selectedSets;
|
10986
11034
|
const pageCount = docContainer.length;
|
10987
11035
|
const containerPos = { x: docContainer.rect.x - this.viewOptions.pageOffset.x, y: docContainer.rect.y - this.viewOptions.pageOffset.y };
|
@@ -11007,13 +11055,13 @@ class ElementPaint {
|
|
11007
11055
|
});
|
11008
11056
|
nextRenderFn();
|
11009
11057
|
const { scale, viewSettings: { width, height } } = this.viewOptions;
|
11058
|
+
while (this.renderCtx.onRenderCompleted.subs.length > 0) {
|
11059
|
+
this.renderCtx.onRenderCompleted.next();
|
11060
|
+
}
|
11010
11061
|
this.renderCtx.commit({ width, height, scale }, this.viewOptions.pageOffset);
|
11011
11062
|
}
|
11012
11063
|
drawRenderObject(renderObject, parent, parentInViewPort = false) {
|
11013
11064
|
const element = renderObject.element;
|
11014
|
-
// if (this.rePaint && element) {
|
11015
|
-
// //element.paintRenders.push(renderObject);
|
11016
|
-
// }
|
11017
11065
|
const { x: rx, y: ry, width: rw, height: rh } = renderObject.rect;
|
11018
11066
|
const currPosition = { x: rx + parent.x, y: ry + parent.y };
|
11019
11067
|
//判断当前绘制元素是否在视窗内
|
@@ -11053,18 +11101,6 @@ class ElementPaint {
|
|
11053
11101
|
};
|
11054
11102
|
renderObject.render(renderData);
|
11055
11103
|
}
|
11056
|
-
// //审阅信息
|
11057
|
-
// if (this.viewOptions.showReviewWindow && element && element.type === 'comm') {
|
11058
|
-
// const commElement = element as CommentElement;
|
11059
|
-
// if (commElement.props.markType === 'start') {
|
11060
|
-
// //获取当前绘制元素相对于当前页的坐标
|
11061
|
-
// this.paintCommMap.push({
|
11062
|
-
// ele: commElement,
|
11063
|
-
// render: renderObject,
|
11064
|
-
// pos: { x: currPosition.x - this.paintPagePos.x, y: currPosition.y - this.paintPagePos.y }
|
11065
|
-
// });
|
11066
|
-
// }
|
11067
|
-
// }
|
11068
11104
|
}
|
11069
11105
|
//处理选中拖蓝
|
11070
11106
|
if (inViewPort && this.selectedSets.has(element)) {
|
@@ -11500,6 +11536,7 @@ class EditorContext {
|
|
11500
11536
|
this.clearPrevDocCb?.();
|
11501
11537
|
//this.ele_types_handlers.length = 0;
|
11502
11538
|
this.imageLoader.clear();
|
11539
|
+
this._document = null;
|
11503
11540
|
}
|
11504
11541
|
/**
|
11505
11542
|
* 切换行打印模式
|
@@ -11879,6 +11916,8 @@ class DynamicContextParser {
|
|
11879
11916
|
TableData(tableId, startRow, startCol, endRow, endCol) {
|
11880
11917
|
const tb = this.doc.treeFind(item => item instanceof TableElement && item.props.id === tableId);
|
11881
11918
|
const res = [];
|
11919
|
+
startRow = startRow < 0 ? tb.length + startRow : startRow;
|
11920
|
+
startCol = startCol < 0 ? tb.length + startCol : startCol;
|
11882
11921
|
endRow = endRow < 0 ? tb.length + endRow : endRow;
|
11883
11922
|
endCol = endCol < 0 ? tb.length + endCol : endCol;
|
11884
11923
|
for (let i = startRow; i <= endRow; i++) {
|
@@ -12105,7 +12144,6 @@ class ParagraphMeasure {
|
|
12105
12144
|
*/
|
12106
12145
|
setParaTextAlign(counter, paraLineIndex, paraElement, limitWidth, paraLineRender) {
|
12107
12146
|
let indent = paraLineRender.startX;
|
12108
|
-
paraLineRender.line.rect.width = limitWidth;
|
12109
12147
|
if (paraElement.props.textAlign === 'center') {
|
12110
12148
|
const remainSpace = limitWidth - paraLineRender.line.rect.width;
|
12111
12149
|
const startX = Math.ceil(remainSpace / 2) + indent;
|
@@ -12129,6 +12167,7 @@ class ParagraphMeasure {
|
|
12129
12167
|
//return indent;
|
12130
12168
|
}
|
12131
12169
|
else ;
|
12170
|
+
paraLineRender.line.rect.width = limitWidth;
|
12132
12171
|
}
|
12133
12172
|
/**
|
12134
12173
|
* 设置两端对齐
|
@@ -12256,8 +12295,15 @@ class ParagraphMeasure {
|
|
12256
12295
|
}
|
12257
12296
|
}
|
12258
12297
|
}
|
12259
|
-
|
12260
|
-
|
12298
|
+
this.arrangeInlineItems(data, ele.getChild(i));
|
12299
|
+
}
|
12300
|
+
}
|
12301
|
+
arrangeInlineItems(parentLine, ele) {
|
12302
|
+
if (ele instanceof InlineGroupElement) {
|
12303
|
+
this.arrangeInlineGroupElement(parentLine, ele);
|
12304
|
+
}
|
12305
|
+
else {
|
12306
|
+
this.arrange(parentLine, ele);
|
12261
12307
|
}
|
12262
12308
|
}
|
12263
12309
|
arrangeLeafElement(parentLine, ele) {
|
@@ -12634,7 +12680,9 @@ class DocumentArrange {
|
|
12634
12680
|
continue;
|
12635
12681
|
}
|
12636
12682
|
if (Array.isArray(childRender)) {
|
12637
|
-
|
12683
|
+
if (childRender.length > 1) {
|
12684
|
+
element.cacheRender = null;
|
12685
|
+
}
|
12638
12686
|
for (let j = 0; j < childRender.length; j++) {
|
12639
12687
|
if (j > 0) {
|
12640
12688
|
render = this.createRenderObject(element);
|
@@ -14247,7 +14295,7 @@ class PageBreakRenderObject extends LeafRenderObject {
|
|
14247
14295
|
if (render.drawMode === 'print') {
|
14248
14296
|
return;
|
14249
14297
|
}
|
14250
|
-
render.contentContext.drawText('
|
14298
|
+
render.contentContext.drawText('↩', this.element.textProps, position.x, position.y, 20, this.rect.height);
|
14251
14299
|
}
|
14252
14300
|
clone() {
|
14253
14301
|
const render = new PageBreakRenderObject(this.element);
|
@@ -14770,7 +14818,8 @@ class DocumentEvent {
|
|
14770
14818
|
};
|
14771
14819
|
}
|
14772
14820
|
}
|
14773
|
-
|
14821
|
+
//只有设计模式时,才需要进行边界判断,方可调整表格列宽等
|
14822
|
+
if (!this.ismousedown && this.viewOptions.docMode === exports.DocMode.Design) {
|
14774
14823
|
this.edgeRenderInfo = edgeRenderInfo;
|
14775
14824
|
}
|
14776
14825
|
//存在边界元素,并且当前边界处于鼠标按下状态
|
@@ -18305,7 +18354,6 @@ function getCurrentActiveAppContext() {
|
|
18305
18354
|
function setCurrentActiveAppContext(ctx) {
|
18306
18355
|
currentActiveAppContext = ctx;
|
18307
18356
|
}
|
18308
|
-
let taskId;
|
18309
18357
|
function renderApp(root, renderCtx, nodeEvent) {
|
18310
18358
|
window['root'] = root;
|
18311
18359
|
// const nodeEvent = new NodeEvent(root, renderCtx.mainContext.ctx.canvas);
|
@@ -18315,15 +18363,13 @@ function renderApp(root, renderCtx, nodeEvent) {
|
|
18315
18363
|
return;
|
18316
18364
|
}
|
18317
18365
|
delayTask = true;
|
18318
|
-
|
18319
|
-
console.log(taskId + "正在运行中");
|
18366
|
+
setTimeout(() => {
|
18320
18367
|
currentActiveAppContext = { root, render: flushTask };
|
18321
18368
|
delayTask = false;
|
18322
18369
|
root.clearPopNodes();
|
18323
18370
|
prepareRender(root, renderCtx, nodeEvent.appState);
|
18324
18371
|
updateCursor(nodeEvent, renderCtx);
|
18325
18372
|
currentActiveAppContext = null;
|
18326
|
-
console.log(taskId + "运行完成");
|
18327
18373
|
}, 16);
|
18328
18374
|
};
|
18329
18375
|
flushTask();
|
@@ -18630,6 +18676,7 @@ class ButtonBase extends TextBase {
|
|
18630
18676
|
|
18631
18677
|
const ViewConfig = {
|
18632
18678
|
surfaceBgColor: '#f0f0f0',
|
18679
|
+
showMousePositionLine: false,
|
18633
18680
|
primaryColor: '#6750A4',
|
18634
18681
|
onPrimaryColor: '#FFFFFF',
|
18635
18682
|
themeSecondaryColor: '#2b88d8',
|
@@ -19263,7 +19310,7 @@ function invokeNodeEvent(node, event, name, useCapture) {
|
|
19263
19310
|
|
19264
19311
|
class ViewPaint {
|
19265
19312
|
ctx;
|
19266
|
-
onRenderCompleted = new
|
19313
|
+
onRenderCompleted = new OnceSubject();
|
19267
19314
|
pageSetting;
|
19268
19315
|
pageRect;
|
19269
19316
|
constructor(ctx) {
|
@@ -19451,8 +19498,8 @@ class ViewPaint {
|
|
19451
19498
|
let { x, y } = lines[i];
|
19452
19499
|
x = Math.ceil(x);
|
19453
19500
|
y = Math.ceil(y);
|
19454
|
-
x += 0.5;
|
19455
|
-
y += 0.5;
|
19501
|
+
// x += 0.5;
|
19502
|
+
// y += 0.5;
|
19456
19503
|
if (i === 0) {
|
19457
19504
|
this.ctx.moveTo(x, y);
|
19458
19505
|
}
|
@@ -19475,8 +19522,8 @@ class ViewPaint {
|
|
19475
19522
|
}
|
19476
19523
|
}
|
19477
19524
|
drawRadioBox(x, y, width, height, isChecked) {
|
19478
|
-
x = x + Math.floor(width / 2);
|
19479
|
-
y = y + Math.floor(height / 2);
|
19525
|
+
// x = x + Math.floor(width / 2);
|
19526
|
+
// y = y + Math.floor(height / 2);
|
19480
19527
|
width = Math.floor(width / 2);
|
19481
19528
|
this.ctx.save();
|
19482
19529
|
this.ctx.strokeStyle = 'black';
|
@@ -19620,6 +19667,13 @@ class SurfaceView extends NodeItems {
|
|
19620
19667
|
this.reLayout = false;
|
19621
19668
|
}
|
19622
19669
|
e.render.fillRect(0, 0, this.finalRect.width, this.finalRect.height, ViewConfig.surfaceBgColor);
|
19670
|
+
e.next(e.render);
|
19671
|
+
this.drawMouseLinePosition(e);
|
19672
|
+
}
|
19673
|
+
drawMouseLinePosition(e) {
|
19674
|
+
{
|
19675
|
+
return;
|
19676
|
+
}
|
19623
19677
|
}
|
19624
19678
|
start() {
|
19625
19679
|
this.renderSchedule = renderApp(this, this.renderCtx, this.nodeEvent);
|
@@ -20019,7 +20073,7 @@ class MenuContainer extends NodeItems {
|
|
20019
20073
|
}
|
20020
20074
|
preRender(e) {
|
20021
20075
|
const { render, renderPos, next } = e;
|
20022
|
-
e.render.onRenderCompleted.
|
20076
|
+
e.render.onRenderCompleted.subscribe((render) => {
|
20023
20077
|
e.appState.surface.registerPopNode(this);
|
20024
20078
|
const parentPos = { x: renderPos.x - this.finalRect.x, y: renderPos.y - this.finalRect.y };
|
20025
20079
|
render.tran(() => {
|
@@ -20093,11 +20147,31 @@ class ScrollView extends NodeItems {
|
|
20093
20147
|
});
|
20094
20148
|
this.addEventListener('wheel', evt => {
|
20095
20149
|
const { deltaY, deltaX } = evt;
|
20096
|
-
console.log(`deltaX:${deltaX},deltaY:${deltaY}`);
|
20097
20150
|
this.horBar.updateScrollByCurrent(deltaX / 10, deltaY / 10);
|
20098
20151
|
this.verBar.updateScrollByCurrent(deltaX / 10, deltaY / 10);
|
20099
20152
|
});
|
20100
20153
|
}
|
20154
|
+
scrollTo(x, y) {
|
20155
|
+
if (!this.content.finalRect || !this.finalRect) {
|
20156
|
+
return;
|
20157
|
+
}
|
20158
|
+
if (y > this.content.finalRect.height) {
|
20159
|
+
y = this.content.finalRect.height;
|
20160
|
+
}
|
20161
|
+
if (x > this.content.finalRect.width) {
|
20162
|
+
x = this.content.finalRect.width;
|
20163
|
+
}
|
20164
|
+
let scrollX = x - this.finalRect.width;
|
20165
|
+
let scrollY = y - this.finalRect.height;
|
20166
|
+
scrollX = scrollX < 0 ? 0 : scrollX;
|
20167
|
+
scrollY = scrollY < 0 ? 0 : scrollY;
|
20168
|
+
this.scrollX = scrollX;
|
20169
|
+
this.scrollY = scrollY;
|
20170
|
+
this.onScrollEvent.next({
|
20171
|
+
x: this.scrollX,
|
20172
|
+
y: this.scrollY
|
20173
|
+
});
|
20174
|
+
}
|
20101
20175
|
measureOverride(e, availableSize) {
|
20102
20176
|
const measureSize = availableSize;
|
20103
20177
|
this.content.measure(e, measureSize);
|
@@ -20320,10 +20394,6 @@ class ScrollBar extends NodeItems {
|
|
20320
20394
|
const x = this.orientation === 'horizontal' ? (scrollView.scrollX / scrollView.content.finalRect.width) * finalSize.width : (ScrollBarSize - this.thumbSize) / 2;
|
20321
20395
|
const y = this.orientation === 'horizontal' ? (ScrollBarSize - this.thumbSize) / 2 : (scrollView.scrollY / scrollView.content.finalRect.height) * finalSize.height;
|
20322
20396
|
this.thumb.arrange(e, { x, y, width, height });
|
20323
|
-
if (this.orientation === 'vertical') {
|
20324
|
-
console.log(y, height, finalSize.width, finalSize.height, scrollView.scrollY);
|
20325
|
-
if (scrollView.scrollY === 4.723577235772358) ;
|
20326
|
-
}
|
20327
20397
|
return super.arrangeOverride(e, finalSize);
|
20328
20398
|
}
|
20329
20399
|
render(e) {
|
@@ -20427,6 +20497,9 @@ class RuleControl extends NodeItems {
|
|
20427
20497
|
super();
|
20428
20498
|
this.docCtx = docCtx;
|
20429
20499
|
this.ss = docCtx.selectionState;
|
20500
|
+
this.bgColor = '#fff';
|
20501
|
+
this.shadowBlur = 5;
|
20502
|
+
this.shadowColor = '#000';
|
20430
20503
|
this.options = {
|
20431
20504
|
width: 0,
|
20432
20505
|
pagePL: 0,
|
@@ -20904,8 +20977,6 @@ class CanvasTextEditor extends NodeItems {
|
|
20904
20977
|
pagePL = left;
|
20905
20978
|
pagePR = right;
|
20906
20979
|
}
|
20907
|
-
// this.docRule.setRuleOptions({width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft});
|
20908
|
-
// this.docRule.refreshRule();
|
20909
20980
|
this.rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
20910
20981
|
}
|
20911
20982
|
createDocViewer() {
|
@@ -21004,12 +21075,17 @@ class CanvasTextEditor extends NodeItems {
|
|
21004
21075
|
this.documentPaint.rePages();
|
21005
21076
|
});
|
21006
21077
|
this.updateDocSize();
|
21007
|
-
//页面高度
|
21008
|
-
// this.documentSelection.updateSelectionState();
|
21009
|
-
// this.selectionOverlays.getSelectionTreeData();
|
21010
|
-
// this.beforeRenderSubject.next();
|
21011
21078
|
}
|
21012
|
-
|
21079
|
+
this.updateSelection();
|
21080
|
+
this.refreshDocRule();
|
21081
|
+
this.onChanged();
|
21082
|
+
//this.refreshView();
|
21083
|
+
}
|
21084
|
+
/**
|
21085
|
+
* 计算选区内容对象
|
21086
|
+
* @private
|
21087
|
+
*/
|
21088
|
+
updateSelection() {
|
21013
21089
|
let ssChanged = false;
|
21014
21090
|
try {
|
21015
21091
|
//防止由于选区不正确导致的错误,导致后续的当前任务无法释放
|
@@ -21020,18 +21096,12 @@ class CanvasTextEditor extends NodeItems {
|
|
21020
21096
|
}
|
21021
21097
|
this.selectionOverlays.getSelectionTreeData();
|
21022
21098
|
ssChanged && this.selectionChanged.next(this.documentSelection.selectionState);
|
21023
|
-
this.refreshDocRule();
|
21024
|
-
this.onChanged();
|
21025
|
-
//this.refreshView();
|
21026
21099
|
}
|
21027
21100
|
/**
|
21028
21101
|
* 刷新绘制文档
|
21029
21102
|
* @param rePaint
|
21030
21103
|
*/
|
21031
21104
|
refreshView() {
|
21032
|
-
// const ssChanged = this.documentSelection.updateSelectionState();
|
21033
|
-
// this.selectionOverlays.getSelectionTreeData();
|
21034
|
-
// ssChanged && this.selectionChanged.next(this.documentSelection.selectionState);
|
21035
21105
|
this.documentPaint.refreshView();
|
21036
21106
|
this.setCursor();
|
21037
21107
|
}
|
@@ -21129,7 +21199,7 @@ class CanvasTextEditor extends NodeItems {
|
|
21129
21199
|
*/
|
21130
21200
|
docClickHandle(evt) {
|
21131
21201
|
this.setCursor();
|
21132
|
-
this.
|
21202
|
+
this.updateSelection();
|
21133
21203
|
this.onClickEvent.next(evt);
|
21134
21204
|
}
|
21135
21205
|
/**
|
@@ -21141,6 +21211,7 @@ class CanvasTextEditor extends NodeItems {
|
|
21141
21211
|
if (res) {
|
21142
21212
|
this.flushToSchedule();
|
21143
21213
|
}
|
21214
|
+
this.updateSelection();
|
21144
21215
|
this.onDblClickEvent.next(evt);
|
21145
21216
|
}
|
21146
21217
|
/**
|
@@ -21223,8 +21294,6 @@ class CanvasTextEditor extends NodeItems {
|
|
21223
21294
|
let minDocViewWidth = pageWidth + this.viewOptions.docSpace * 2;
|
21224
21295
|
let maxDocViewWidth = this.surfaceView.width;
|
21225
21296
|
this.width = Math.max(minDocViewWidth, maxDocViewWidth) - ScrollBarSize;
|
21226
|
-
// this.viewOptions.viewSettings.width = this.width;
|
21227
|
-
// this.viewOptions.viewSettings.height = this.scrollView.height as number;
|
21228
21297
|
const docSize = this.documentPaint.getDocumentContainerHeight();
|
21229
21298
|
this.height = docSize.height;
|
21230
21299
|
this.updateRenderCtx();
|
@@ -21237,6 +21306,7 @@ class CanvasTextEditor extends NodeItems {
|
|
21237
21306
|
this.updateRenderCtx();
|
21238
21307
|
this.documentPaint.layoutPages();
|
21239
21308
|
this.refreshDocument();
|
21309
|
+
this.updateLayout();
|
21240
21310
|
}
|
21241
21311
|
/**
|
21242
21312
|
* 缩放视图
|
@@ -21548,6 +21618,7 @@ class CanvasTextEditor extends NodeItems {
|
|
21548
21618
|
return;
|
21549
21619
|
}
|
21550
21620
|
//this.docScroll.scrollTo(cursorPos.rect.x, cursorPos.rect.y - this.viewOptions.translateY);
|
21621
|
+
this.scrollView.scrollTo(cursorPos.rect.x, cursorPos.rect.y + 100);
|
21551
21622
|
}
|
21552
21623
|
}
|
21553
21624
|
/**
|
@@ -21704,6 +21775,13 @@ class CanvasTextEditor extends NodeItems {
|
|
21704
21775
|
scrollView.y = 30;
|
21705
21776
|
this.scrollView = scrollView;
|
21706
21777
|
scrollView.content.addChild(this);
|
21778
|
+
const label = new LabelNode();
|
21779
|
+
label.text = '请注意了';
|
21780
|
+
label.bgColor = '#fff';
|
21781
|
+
label.padding = 2;
|
21782
|
+
label.x = 100;
|
21783
|
+
label.y = 100;
|
21784
|
+
//this.addChild(label);
|
21707
21785
|
scrollView.onScrollEvent.subscribe(data => {
|
21708
21786
|
//console.log(data);
|
21709
21787
|
this.viewOptions.pageOffset.x = data.x;
|
@@ -21725,7 +21803,6 @@ class CanvasTextEditor extends NodeItems {
|
|
21725
21803
|
this.viewOptions.viewSettings.height = data.height;
|
21726
21804
|
this.updateDocSize();
|
21727
21805
|
this.resetViewer();
|
21728
|
-
this.updateLayout();
|
21729
21806
|
});
|
21730
21807
|
surface.addChild(scrollView);
|
21731
21808
|
const rule2 = new RuleControl(this.docCtx);
|
@@ -21735,6 +21812,7 @@ class CanvasTextEditor extends NodeItems {
|
|
21735
21812
|
rule2.x = 20;
|
21736
21813
|
rule2.y = 500;
|
21737
21814
|
surface.addChild(rule2);
|
21815
|
+
//surface.addChild(win);
|
21738
21816
|
surface.start();
|
21739
21817
|
}
|
21740
21818
|
/**
|
@@ -21807,6 +21885,24 @@ class CanvasTextEditor extends NodeItems {
|
|
21807
21885
|
appCtx.root.setInputPosition(caretPos);
|
21808
21886
|
}
|
21809
21887
|
}
|
21888
|
+
measureOverride(e, availableSize) {
|
21889
|
+
this.controls.forEach(item => {
|
21890
|
+
item.measure(e, availableSize);
|
21891
|
+
});
|
21892
|
+
return super.measureOverride(e, availableSize);
|
21893
|
+
}
|
21894
|
+
arrangeOverride(e, finalSize) {
|
21895
|
+
this.controls.forEach(item => {
|
21896
|
+
const itemRect = {
|
21897
|
+
x: item.x,
|
21898
|
+
y: item.y,
|
21899
|
+
width: item.desiredSize.width,
|
21900
|
+
height: item.desiredSize.height
|
21901
|
+
};
|
21902
|
+
item.arrange(e, itemRect);
|
21903
|
+
});
|
21904
|
+
return super.arrangeOverride(e, finalSize);
|
21905
|
+
}
|
21810
21906
|
}
|
21811
21907
|
|
21812
21908
|
/**
|
@@ -22235,6 +22331,7 @@ exports.MarginProps = MarginProps;
|
|
22235
22331
|
exports.MouseElementEvent = MouseElementEvent;
|
22236
22332
|
exports.MousedownElementEvent = MousedownElementEvent;
|
22237
22333
|
exports.MuiltBlockLineRenderObject = MuiltBlockLineRenderObject;
|
22334
|
+
exports.OnceSubject = OnceSubject;
|
22238
22335
|
exports.PSymbolElement = PSymbolElement;
|
22239
22336
|
exports.PSymbolRenderObject = PSymbolRenderObject;
|
22240
22337
|
exports.PaddingProps = PaddingProps;
|