@hailin-zheng/editor-core 1.1.5 → 1.1.6
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/Canvas.d.ts +2 -5
- package/controls/Node.d.ts +15 -0
- package/controls/Text.d.ts +3 -2
- package/controls/ViewPaint.d.ts +9 -0
- package/index-cjs.js +147 -79
- package/index-cjs.js.map +1 -1
- package/index.js +147 -79
- package/index.js.map +1 -1
- package/med_editor/framework/paragraph-arrange.d.ts +4 -0
- package/med_editor/texteditor.d.ts +2 -4
- package/package.json +1 -1
- package/timeline/TimeLineControl.d.ts +46 -0
- package/timeline/TimeValueGridControl.d.ts +96 -0
- package/timeline/TimelineConfig.d.ts +67 -0
- package/timeline/TimelineScrollbar.d.ts +25 -0
- package/timeline/TimelineStatus.d.ts +61 -0
- package/timeline/TimelineTick.d.ts +63 -0
- package/timeline/example.d.ts +2 -0
- package/timeline/timezone.d.ts +0 -2
package/index.js
CHANGED
@@ -4232,7 +4232,6 @@ class TableUtil {
|
|
4232
4232
|
if (!ss.startControl) {
|
4233
4233
|
return;
|
4234
4234
|
}
|
4235
|
-
ss.clear();
|
4236
4235
|
const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
|
4237
4236
|
if (!startCell?.parent) {
|
4238
4237
|
throw new Error('parent is null');
|
@@ -4243,6 +4242,7 @@ class TableUtil {
|
|
4243
4242
|
if (tb.length === 0) {
|
4244
4243
|
tb.remove();
|
4245
4244
|
}
|
4245
|
+
ss.clear();
|
4246
4246
|
}
|
4247
4247
|
/**
|
4248
4248
|
* 移除光标所在的当前列
|
@@ -11164,6 +11164,7 @@ class ParagraphMeasure {
|
|
11164
11164
|
*/
|
11165
11165
|
measureParagraph(p, limitWidth) {
|
11166
11166
|
ElementUtil.fixParagraphContent(p);
|
11167
|
+
this.verifyPara(p, limitWidth);
|
11167
11168
|
p.cacheRender = null;
|
11168
11169
|
const paraModels = [];
|
11169
11170
|
let currRenderLine;
|
@@ -11284,6 +11285,17 @@ class ParagraphMeasure {
|
|
11284
11285
|
}
|
11285
11286
|
return paraRenders;
|
11286
11287
|
}
|
11288
|
+
/**
|
11289
|
+
* 校验当前段落属性
|
11290
|
+
*/
|
11291
|
+
verifyPara(p, limitWidth) {
|
11292
|
+
if (p.props.indent > 0 && p.props.indent + 20 > limitWidth) {
|
11293
|
+
p.props.indent = limitWidth - 20;
|
11294
|
+
}
|
11295
|
+
if (p.props.hanging > 0 && p.props.hanging + 20 > limitWidth) {
|
11296
|
+
p.props.hanging = limitWidth - 20;
|
11297
|
+
}
|
11298
|
+
}
|
11287
11299
|
/**
|
11288
11300
|
* 获取段落行布局横向坐标起始位置,被段落text-align影响
|
11289
11301
|
*/
|
@@ -17120,6 +17132,10 @@ var ModifyFlag;
|
|
17120
17132
|
class NodeCore {
|
17121
17133
|
enableClip = true;
|
17122
17134
|
pointEvent = true;
|
17135
|
+
allowHitTest = false;
|
17136
|
+
hitTest(hitPos, currPos) {
|
17137
|
+
return false;
|
17138
|
+
}
|
17123
17139
|
get enable() {
|
17124
17140
|
return this._enable;
|
17125
17141
|
}
|
@@ -17449,6 +17465,9 @@ class NodeItems extends NodeCore {
|
|
17449
17465
|
eventMap = new WeakMap();
|
17450
17466
|
absoluteItems = false;
|
17451
17467
|
containerPropName;
|
17468
|
+
constructor() {
|
17469
|
+
super();
|
17470
|
+
}
|
17452
17471
|
addChild(control, index = -1) {
|
17453
17472
|
if (this.containerPropName) {
|
17454
17473
|
this[this.containerPropName].addChild(control, index);
|
@@ -17520,6 +17539,33 @@ class NodeItems extends NodeCore {
|
|
17520
17539
|
return this.controls.length;
|
17521
17540
|
}
|
17522
17541
|
}
|
17542
|
+
/**
|
17543
|
+
* 子内容采用绝对定位的容器
|
17544
|
+
*/
|
17545
|
+
class AbsolutePanel extends NodeItems {
|
17546
|
+
constructor() {
|
17547
|
+
super();
|
17548
|
+
this.absoluteItems = true;
|
17549
|
+
}
|
17550
|
+
measureOverride(e, availableSize) {
|
17551
|
+
this.controls.forEach(item => {
|
17552
|
+
item.measure(e, availableSize);
|
17553
|
+
});
|
17554
|
+
return super.measureOverride(e, availableSize);
|
17555
|
+
}
|
17556
|
+
arrangeOverride(e, finalSize) {
|
17557
|
+
this.controls.forEach(item => {
|
17558
|
+
const itemRect = {
|
17559
|
+
x: item.x,
|
17560
|
+
y: item.y,
|
17561
|
+
width: item.desiredSize.width,
|
17562
|
+
height: item.desiredSize.height
|
17563
|
+
};
|
17564
|
+
item.arrange(e, itemRect);
|
17565
|
+
});
|
17566
|
+
return super.arrangeOverride(e, finalSize);
|
17567
|
+
}
|
17568
|
+
}
|
17523
17569
|
let currentActiveAppContext = null;
|
17524
17570
|
function getCurrentActiveAppContext() {
|
17525
17571
|
return currentActiveAppContext;
|
@@ -17637,7 +17683,7 @@ function drawBorderline(node, renderCtx) {
|
|
17637
17683
|
if (!node.border) {
|
17638
17684
|
return;
|
17639
17685
|
}
|
17640
|
-
let { x, y,
|
17686
|
+
let { finalRect: { x, y, width, height } } = node;
|
17641
17687
|
const ctx = renderCtx.ctx;
|
17642
17688
|
ctx.save();
|
17643
17689
|
ctx.fillStyle = node.borderColor;
|
@@ -18201,7 +18247,7 @@ class NodeEvent {
|
|
18201
18247
|
};
|
18202
18248
|
mouseleaveRenders.forEach(item => {
|
18203
18249
|
onMouseoutEvent.target = item;
|
18204
|
-
invokeEvent(onMouseoutEvent, '
|
18250
|
+
invokeEvent(onMouseoutEvent, 'mouseout', item, false);
|
18205
18251
|
});
|
18206
18252
|
const onMouseoverEvent = {
|
18207
18253
|
pos: this.appState.pos,
|
@@ -18367,7 +18413,8 @@ class NodeEvent {
|
|
18367
18413
|
width: width,
|
18368
18414
|
height: height
|
18369
18415
|
};
|
18370
|
-
|
18416
|
+
const hitTest = node.allowHitTest ? node.hitTest(hitPos, currRect) : isInsideRectByPosition(currRect, hitPos);
|
18417
|
+
if (hitTest) {
|
18371
18418
|
//有边框和内边距,所以在计算子节点的时候,需要考虑
|
18372
18419
|
const innerPos = {
|
18373
18420
|
x: currRect.x + node.border + node.padding,
|
@@ -18529,6 +18576,13 @@ class ViewPaint {
|
|
18529
18576
|
this.drawHoriLine(x, y, width, textProps.color, 1);
|
18530
18577
|
}
|
18531
18578
|
}
|
18579
|
+
drawText2(text, textProps, x, y) {
|
18580
|
+
this.ctx.save();
|
18581
|
+
this.ctx.fillStyle = textProps.color;
|
18582
|
+
this.ctx.font = `${textProps.fontSize}px ${textProps.fontName}`;
|
18583
|
+
this.ctx.fillText(text, x, y + textProps.fontSize / 7);
|
18584
|
+
this.ctx.restore();
|
18585
|
+
}
|
18532
18586
|
fillCircular(x, y, r, color = 'black') {
|
18533
18587
|
this.ctx.save();
|
18534
18588
|
this.ctx.beginPath();
|
@@ -18543,6 +18597,10 @@ class ViewPaint {
|
|
18543
18597
|
const textMeasure = this.ctx.measureText(text);
|
18544
18598
|
return { width: textMeasure.width, height: textProps.fontSize };
|
18545
18599
|
}
|
18600
|
+
measureText2(text, font) {
|
18601
|
+
this.ctx.font = font.fontSize + 'px ' + font.fontName;
|
18602
|
+
return this.ctx.measureText(text).width;
|
18603
|
+
}
|
18546
18604
|
measureTextUnits(units, textProps) {
|
18547
18605
|
this.ctx.font = textProps.getFont();
|
18548
18606
|
const letterSpace = textProps.letterSpace ?? 0;
|
@@ -18959,6 +19017,11 @@ class SurfaceView extends NodeItems {
|
|
18959
19017
|
* 如果有默认宽度限制,而且支持换行显示,则内容高度等于多行累计高度
|
18960
19018
|
*/
|
18961
19019
|
class LabelNode extends TextBase {
|
19020
|
+
constructor() {
|
19021
|
+
super();
|
19022
|
+
this.border = 1;
|
19023
|
+
this.borderColor = '#000';
|
19024
|
+
}
|
18962
19025
|
_textWrapping = 'no';
|
18963
19026
|
get textWrapping() {
|
18964
19027
|
return this._textWrapping;
|
@@ -18968,34 +19031,54 @@ class LabelNode extends TextBase {
|
|
18968
19031
|
this._textWrapping = value;
|
18969
19032
|
}
|
18970
19033
|
cacheTextRect;
|
18971
|
-
textUnits
|
19034
|
+
//private textUnits!: Array<TextUnits>;
|
19035
|
+
lines = [];
|
18972
19036
|
measureOverride(e, availableSize) {
|
18973
|
-
|
18974
|
-
this.
|
18975
|
-
|
19037
|
+
this.getTextProps();
|
19038
|
+
this.lines = this.getMuiltLines(this.text, e);
|
19039
|
+
// this.textUnits = this.text.split('').map<TextUnits>(char => ({char, actualSize: 0, sourceSize: 0}));
|
19040
|
+
// e.render.measureTextUnits(this.textUnits, textProps);
|
18976
19041
|
//没有宽度限制,测量横向排列的尺寸大小,此时不需要考虑换行
|
18977
|
-
if (Number.isNaN(this._width)) {
|
18978
|
-
|
18979
|
-
|
18980
|
-
|
18981
|
-
|
18982
|
-
|
18983
|
-
|
18984
|
-
|
18985
|
-
|
18986
|
-
}
|
18987
|
-
|
19042
|
+
// if (Number.isNaN(this._width)) {
|
19043
|
+
// // return {
|
19044
|
+
// // width: this.lines[0].textUnits.reduce((prev, curr) => {
|
19045
|
+
// // return prev + curr.sourceSize
|
19046
|
+
// // }, 0), height: this.fontSize
|
19047
|
+
// // };
|
19048
|
+
// return this.measureTextRect(this.lines, {
|
19049
|
+
// width: availableSize.width,
|
19050
|
+
// height: this.getPercentHeight(availableSize.height)
|
19051
|
+
// });
|
19052
|
+
// }
|
19053
|
+
// if (this._textWrapping === 'no') {
|
19054
|
+
// return {width: this.getPercentWidth(availableSize.width), height: this.fontSize};
|
19055
|
+
// }
|
19056
|
+
return this.measureTextRect(this.lines, {
|
18988
19057
|
width: availableSize.width,
|
18989
19058
|
height: this.getPercentHeight(availableSize.height)
|
18990
19059
|
});
|
18991
19060
|
}
|
18992
|
-
|
18993
|
-
|
18994
|
-
|
18995
|
-
|
18996
|
-
|
18997
|
-
|
19061
|
+
getMuiltLines(text, e) {
|
19062
|
+
const lineRects = [];
|
19063
|
+
const lines = this.text.split('\r\n');
|
19064
|
+
for (let i = 0; i < lines.length; i++) {
|
19065
|
+
const units = lines[i].split('').map(char => ({ char, actualSize: 0, sourceSize: 0 }));
|
19066
|
+
e.render.measureTextUnits(units, this.getTextProps());
|
19067
|
+
lineRects.push({ textUnits: units });
|
18998
19068
|
}
|
19069
|
+
return lineRects;
|
19070
|
+
}
|
19071
|
+
arrangeOverride(e, finalSize) {
|
19072
|
+
// if (!Number.isNaN(this._width) && this._textWrapping === 'wrap') {
|
19073
|
+
// this.measureTextRect(this.lines, {
|
19074
|
+
// width: finalSize.width,
|
19075
|
+
// height: finalSize.height
|
19076
|
+
// });
|
19077
|
+
// }
|
19078
|
+
this.measureTextRect(this.lines, {
|
19079
|
+
width: finalSize.width,
|
19080
|
+
height: finalSize.height
|
19081
|
+
});
|
18999
19082
|
return super.arrangeOverride(e, finalSize);
|
19000
19083
|
}
|
19001
19084
|
getTextProps() {
|
@@ -19005,54 +19088,56 @@ class LabelNode extends TextBase {
|
|
19005
19088
|
textProps.color = this.color ?? '#000';
|
19006
19089
|
return textProps;
|
19007
19090
|
}
|
19008
|
-
measureTextRect(
|
19009
|
-
const sumWidth = textUnits.reduce((prev, curr) => {
|
19010
|
-
return curr.sourceSize + prev;
|
19011
|
-
}, 0);
|
19091
|
+
measureTextRect(lines, availableSize, final = false) {
|
19012
19092
|
//总宽度大于可用宽度,换行计算
|
19013
19093
|
const cacheLines = [];
|
19014
19094
|
const { width: limitWidth, height: limitHeight } = availableSize;
|
19015
|
-
let
|
19016
|
-
|
19017
|
-
|
19018
|
-
|
19019
|
-
|
19020
|
-
|
19021
|
-
|
19022
|
-
|
19023
|
-
|
19024
|
-
|
19025
|
-
|
19026
|
-
|
19095
|
+
for (let i = 0; i < lines.length; i++) {
|
19096
|
+
const lineText = lines[i];
|
19097
|
+
let line = { lineUnits: [], x: 0, y: 0, width: 0, height: 0 };
|
19098
|
+
cacheLines.push(line);
|
19099
|
+
for (let j = 0; j < lineText.textUnits.length; j++) {
|
19100
|
+
const unit = lineText.textUnits[j];
|
19101
|
+
//至少每行一个字符
|
19102
|
+
if (line.lineUnits.length > 0 && line.width + unit.sourceSize > limitWidth) {
|
19103
|
+
line = { lineUnits: [], x: 0, y: 0, width: 0, height: 0 };
|
19104
|
+
cacheLines.push(line);
|
19105
|
+
}
|
19106
|
+
line.lineUnits.push(unit);
|
19107
|
+
line.width += unit.sourceSize;
|
19108
|
+
line.height = this.fontSize;
|
19109
|
+
}
|
19027
19110
|
}
|
19028
19111
|
let contentHeight = 0;
|
19112
|
+
let maxLineWidth = 0;
|
19029
19113
|
cacheLines.forEach(line => {
|
19030
19114
|
line.y = contentHeight;
|
19031
19115
|
contentHeight += line.height;
|
19116
|
+
maxLineWidth = Math.max(line.width, maxLineWidth);
|
19032
19117
|
});
|
19033
19118
|
//期望高度
|
19034
19119
|
let desiredHeight = final ? limitHeight : contentHeight;
|
19035
19120
|
this.cacheTextRect = {
|
19036
19121
|
lines: cacheLines,
|
19037
|
-
width:
|
19122
|
+
width: maxLineWidth,
|
19038
19123
|
height: contentHeight,
|
19039
19124
|
desiredHeight,
|
19040
19125
|
desiredWidth: limitWidth
|
19041
19126
|
};
|
19042
19127
|
return {
|
19043
|
-
width:
|
19128
|
+
width: maxLineWidth,
|
19044
19129
|
height: desiredHeight
|
19045
19130
|
};
|
19046
19131
|
}
|
19047
19132
|
render(e) {
|
19048
|
-
const textProp = new TextProps();
|
19049
|
-
textProp.fontName = this.fontName;
|
19050
|
-
textProp.fontSize = this.fontSize;
|
19051
|
-
textProp.color = this.color;
|
19052
|
-
if (this.textWrapping === 'no' || Number.isNaN(this._width)) {
|
19053
|
-
|
19054
|
-
|
19055
|
-
}
|
19133
|
+
// const textProp = new TextProps();
|
19134
|
+
// textProp.fontName = this.fontName;
|
19135
|
+
// textProp.fontSize = this.fontSize;
|
19136
|
+
// textProp.color = this.color;
|
19137
|
+
// if (this.textWrapping === 'no' || Number.isNaN(this._width)) {
|
19138
|
+
// e.render.drawText(this.text, textProp, 0, 0, this.finalRect.width, textProp.fontSize);
|
19139
|
+
// return;
|
19140
|
+
// }
|
19056
19141
|
for (let i = 0; i < this.cacheTextRect.lines.length; i++) {
|
19057
19142
|
const line = this.cacheTextRect.lines[i];
|
19058
19143
|
this.drawLine(e, line);
|
@@ -19068,7 +19153,7 @@ class LabelNode extends TextBase {
|
|
19068
19153
|
render.tran(() => {
|
19069
19154
|
const textProps = this.getTextProps();
|
19070
19155
|
render.ctx.font = textProps.getFont();
|
19071
|
-
render.drawText(line.lineUnits.join(''), textProps, 0, line.y, line.width, line.height);
|
19156
|
+
render.drawText(line.lineUnits.map(item => item.char).join(''), textProps, 0, line.y, line.width, line.height);
|
19072
19157
|
});
|
19073
19158
|
}
|
19074
19159
|
}
|
@@ -19318,8 +19403,8 @@ class ScrollView extends NodeItems {
|
|
19318
19403
|
});
|
19319
19404
|
this.addEventListener('wheel', evt => {
|
19320
19405
|
const { deltaY, deltaX } = evt;
|
19321
|
-
this.horBar.updateScrollByCurrent(deltaX
|
19322
|
-
this.verBar.updateScrollByCurrent(deltaX
|
19406
|
+
this.horBar.updateScrollByCurrent(deltaX, deltaY);
|
19407
|
+
this.verBar.updateScrollByCurrent(deltaX, deltaY);
|
19323
19408
|
});
|
19324
19409
|
}
|
19325
19410
|
scrollTo(x, y) {
|
@@ -20038,7 +20123,7 @@ function pointInPoly(pt, poly) {
|
|
20038
20123
|
* 1.在单页模式下,文档最小宽度为单个文档宽度+合适的外边距
|
20039
20124
|
* 2.在多页模式下,文档最小宽度为单个文档宽度+合适的外边距
|
20040
20125
|
*/
|
20041
|
-
class CanvasTextEditor extends
|
20126
|
+
class CanvasTextEditor extends AbsolutePanel {
|
20042
20127
|
editCanvas;
|
20043
20128
|
editInput;
|
20044
20129
|
contentCtx;
|
@@ -20965,6 +21050,13 @@ class CanvasTextEditor extends NodeItems {
|
|
20965
21050
|
const win = new Window();
|
20966
21051
|
win.width = 1000;
|
20967
21052
|
win.height = 800;
|
21053
|
+
//win.content.addChild(timelineScrollbar)
|
21054
|
+
const rule2 = new RuleControl(this.docCtx);
|
21055
|
+
this.rule = rule2;
|
21056
|
+
rule2.width = 700;
|
21057
|
+
rule2.height = 30;
|
21058
|
+
rule2.x = 20;
|
21059
|
+
rule2.y = 500;
|
20968
21060
|
const surface = new SurfaceView(this.editCanvas, this.editInput);
|
20969
21061
|
this.surfaceView = surface;
|
20970
21062
|
surface.width = 1000;
|
@@ -20976,12 +21068,6 @@ class CanvasTextEditor extends NodeItems {
|
|
20976
21068
|
this.resetViewer();
|
20977
21069
|
});
|
20978
21070
|
surface.addChild(scrollView);
|
20979
|
-
const rule2 = new RuleControl(this.docCtx);
|
20980
|
-
this.rule = rule2;
|
20981
|
-
rule2.width = 700;
|
20982
|
-
rule2.height = 30;
|
20983
|
-
rule2.x = 20;
|
20984
|
-
rule2.y = 500;
|
20985
21071
|
surface.addChild(rule2);
|
20986
21072
|
//surface.addChild(win);
|
20987
21073
|
surface.start();
|
@@ -21056,24 +21142,6 @@ class CanvasTextEditor extends NodeItems {
|
|
21056
21142
|
appCtx.root.setInputPosition(caretPos);
|
21057
21143
|
}
|
21058
21144
|
}
|
21059
|
-
measureOverride(e, availableSize) {
|
21060
|
-
this.controls.forEach(item => {
|
21061
|
-
item.measure(e, availableSize);
|
21062
|
-
});
|
21063
|
-
return super.measureOverride(e, availableSize);
|
21064
|
-
}
|
21065
|
-
arrangeOverride(e, finalSize) {
|
21066
|
-
this.controls.forEach(item => {
|
21067
|
-
const itemRect = {
|
21068
|
-
x: item.x,
|
21069
|
-
y: item.y,
|
21070
|
-
width: item.desiredSize.width,
|
21071
|
-
height: item.desiredSize.height
|
21072
|
-
};
|
21073
|
-
item.arrange(e, itemRect);
|
21074
|
-
});
|
21075
|
-
return super.arrangeOverride(e, finalSize);
|
21076
|
-
}
|
21077
21145
|
}
|
21078
21146
|
|
21079
21147
|
/**
|