@hailin-zheng/editor-core 2.1.0 → 2.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.
- package/README.md +1 -1756
- package/index-cjs.js +343 -98
- package/index-cjs.js.map +1 -1
- package/index.js +343 -97
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +1 -0
- package/med_editor/framework/common-util.d.ts +1 -0
- package/med_editor/framework/document-change.d.ts +8 -0
- package/med_editor/framework/document-svg.d.ts +6 -0
- package/med_editor/framework/editor-calendar-vnode.d.ts +4 -2
- package/med_editor/framework/element-define.d.ts +2 -0
- package/med_editor/framework/element-util.d.ts +0 -10
- package/med_editor/framework/impl/data-element/data-element-barcode.d.ts +0 -1
- package/med_editor/framework/impl/media-formula/permanent-teeth.d.ts +32 -0
- package/med_editor/framework/impl/symbol/br-symbol-impl.d.ts +2 -1
- package/med_editor/framework/impl/symbol/p-symbol-impl.d.ts +2 -1
- package/package.json +1 -2
package/index.js
CHANGED
@@ -3,7 +3,6 @@ import moment from 'moment';
|
|
3
3
|
import * as acor from 'acorn';
|
4
4
|
import { generate } from 'astring';
|
5
5
|
import estraverse from 'estraverse';
|
6
|
-
import * as bwipjs from 'bwip-js';
|
7
6
|
import JsBarcode from 'jsbarcode';
|
8
7
|
import { toVNode, init as init$1, styleModule, classModule, attributesModule, eventListenersModule } from 'snabbdom';
|
9
8
|
|
@@ -652,6 +651,23 @@ class CommonUtil {
|
|
652
651
|
}
|
653
652
|
return this.findParent(curr.parentElement, predicate);
|
654
653
|
}
|
654
|
+
static isIntersect(rect1, rect2) {
|
655
|
+
const left1 = rect1.x;
|
656
|
+
const top1 = rect1.y;
|
657
|
+
const right1 = rect1.x + rect1.width;
|
658
|
+
const bottom1 = rect1.y + rect1.height;
|
659
|
+
const left2 = rect2.x;
|
660
|
+
const top2 = rect2.y;
|
661
|
+
const right2 = rect2.x + rect2.width;
|
662
|
+
const bottom2 = rect2.y + rect2.height;
|
663
|
+
if (left1 >= right2 || left2 >= right1) {
|
664
|
+
return false;
|
665
|
+
}
|
666
|
+
if (top1 >= bottom2 || top2 >= bottom1) {
|
667
|
+
return false;
|
668
|
+
}
|
669
|
+
return true;
|
670
|
+
}
|
655
671
|
}
|
656
672
|
|
657
673
|
const docOpsMap = new Map();
|
@@ -1518,6 +1534,8 @@ class ViewOptions {
|
|
1518
1534
|
paraSymbolColor = 'rgb(128,128,128)';
|
1519
1535
|
dataGroupColor = 'rgb(0,80,179)';
|
1520
1536
|
defaultLineHeight = 1;
|
1537
|
+
//虚拟视图模式,处理可视区域内的元素
|
1538
|
+
virtualViewMode = false;
|
1521
1539
|
//新增-留痕块文本颜色
|
1522
1540
|
trackInsColor = '#ff4d4f';
|
1523
1541
|
//删除-留痕块文本颜色
|
@@ -1550,6 +1568,8 @@ class ViewOptions {
|
|
1550
1568
|
ruleHeight = 30;
|
1551
1569
|
//是否打印页眉页脚线
|
1552
1570
|
printHeaderFooterLine = false;
|
1571
|
+
//显示段落回车符号
|
1572
|
+
showEnterSymbol = false;
|
1553
1573
|
get fullPageView() {
|
1554
1574
|
return this._fullPageView;
|
1555
1575
|
}
|
@@ -4304,6 +4324,27 @@ class PSymbolRenderObject extends LeafRenderObject {
|
|
4304
4324
|
}
|
4305
4325
|
render.contentContext.drawText('↩', this.element.textProps, position.x, position.y, 20, this.rect.height);
|
4306
4326
|
}
|
4327
|
+
exportHTML(event) {
|
4328
|
+
if (!event.options.showEnterSymbol || event.mode === 'print') {
|
4329
|
+
return null;
|
4330
|
+
}
|
4331
|
+
return {
|
4332
|
+
sel: 'text',
|
4333
|
+
text: '↵',
|
4334
|
+
data: {
|
4335
|
+
ns: "http://www.w3.org/2000/svg",
|
4336
|
+
attrs: {
|
4337
|
+
//"transform": `translate(0,${(height - props.fontSize) / 2})`,
|
4338
|
+
'dominant-baseline': 'hanging',
|
4339
|
+
'font-family': 'Courier',
|
4340
|
+
'font-size': this.element.defaultHeight,
|
4341
|
+
x: this.rect.x,
|
4342
|
+
y: this.rect.y,
|
4343
|
+
fill: 'green'
|
4344
|
+
}
|
4345
|
+
},
|
4346
|
+
};
|
4347
|
+
}
|
4307
4348
|
//绘制段落符号
|
4308
4349
|
clone() {
|
4309
4350
|
const render = new PSymbolRenderObject(this.element);
|
@@ -8193,30 +8234,13 @@ class DataElementBarcode extends DataElementLeaf {
|
|
8193
8234
|
return this.props.text;
|
8194
8235
|
}
|
8195
8236
|
drawBarcode(renderCtx, pos) {
|
8196
|
-
this.createBarcodeCache();
|
8197
8237
|
renderCtx.contentContext.ctx.drawImage(this.barCodeCanvas, pos.x, pos.y, this.props.width, this.props.height);
|
8198
8238
|
}
|
8199
|
-
createBarcodeCache() {
|
8200
|
-
if (this.cache) {
|
8201
|
-
return;
|
8202
|
-
}
|
8203
|
-
this.cache = true;
|
8204
|
-
if (!this.barCodeCanvas) {
|
8205
|
-
this.barCodeCanvas = document.createElement('canvas');
|
8206
|
-
}
|
8207
|
-
this.barCodeCanvas = bwipjs.toCanvas(this.barCodeCanvas, {
|
8208
|
-
bcid: this.props.type,
|
8209
|
-
text: this.props.text || "0123456789",
|
8210
|
-
height: 10,
|
8211
|
-
includetext: true,
|
8212
|
-
textxalign: "center", // Always good to set this
|
8213
|
-
});
|
8214
|
-
}
|
8215
8239
|
}
|
8216
8240
|
class DataElementBarcodeRenderObject extends ResizeLeafRenderObject {
|
8217
8241
|
render(e) {
|
8218
|
-
const barcodeEle = this.element;
|
8219
|
-
barcodeEle.drawBarcode(e.render, e.position);
|
8242
|
+
// const barcodeEle = this.element as DataElementBarcode;
|
8243
|
+
// barcodeEle.drawBarcode(e.render, e.position);
|
8220
8244
|
}
|
8221
8245
|
clone() {
|
8222
8246
|
const clone = new DataElementBarcodeRenderObject(this.element);
|
@@ -9090,6 +9114,27 @@ class BreakRenderObject extends LeafRenderObject {
|
|
9090
9114
|
}
|
9091
9115
|
render.contentContext.drawText('↓', this.element.textProps, position.x, position.y, 20, this.rect.height);
|
9092
9116
|
}
|
9117
|
+
exportHTML(event) {
|
9118
|
+
if (!event.options.showEnterSymbol || event.mode === 'print') {
|
9119
|
+
return null;
|
9120
|
+
}
|
9121
|
+
return {
|
9122
|
+
sel: 'text',
|
9123
|
+
text: '↓',
|
9124
|
+
data: {
|
9125
|
+
ns: "http://www.w3.org/2000/svg",
|
9126
|
+
attrs: {
|
9127
|
+
//"transform": `translate(0,${(height - props.fontSize) / 2})`,
|
9128
|
+
'dominant-baseline': 'hanging',
|
9129
|
+
'font-family': 'Courier',
|
9130
|
+
'font-size': this.rect.height,
|
9131
|
+
x: this.rect.x + 4,
|
9132
|
+
y: this.rect.y,
|
9133
|
+
fill: 'green'
|
9134
|
+
}
|
9135
|
+
},
|
9136
|
+
};
|
9137
|
+
}
|
9093
9138
|
clone() {
|
9094
9139
|
const render = new BreakRenderObject(this.element);
|
9095
9140
|
render.rect = ElementUtil.cloneRect(this.rect);
|
@@ -9130,6 +9175,9 @@ class DataElementText extends DataElementInlineGroup {
|
|
9130
9175
|
if (!this.startDecorate) {
|
9131
9176
|
return;
|
9132
9177
|
}
|
9178
|
+
if (val === null || val === undefined) {
|
9179
|
+
val = '';
|
9180
|
+
}
|
9133
9181
|
if (this.getValue() === val) {
|
9134
9182
|
return;
|
9135
9183
|
}
|
@@ -12410,6 +12458,7 @@ class ElementUtil {
|
|
12410
12458
|
};
|
12411
12459
|
}
|
12412
12460
|
static getMousePos(e, scale = 1) {
|
12461
|
+
//scale=1;
|
12413
12462
|
const svgContainer = e.currentTarget;
|
12414
12463
|
const parentRect = svgContainer.getBoundingClientRect();
|
12415
12464
|
const localX = e.clientX - parentRect.x; //+ this.viewOptions.pageOffset.x;
|
@@ -16126,11 +16175,13 @@ class DocumentPaint {
|
|
16126
16175
|
this.docContainer.clear();
|
16127
16176
|
const { pageLayoutMode, viewSettings: { width: viewWidth } } = this.viewOptions;
|
16128
16177
|
//文档内容区宽度
|
16129
|
-
const contentWidth = this.viewOptions
|
16178
|
+
const { contentWidth, scale } = this.viewOptions;
|
16130
16179
|
//文档容器总宽度等于内容宽度
|
16131
16180
|
//单页模式,docContainer居中
|
16132
16181
|
this.docContainer.rect.width = viewWidth;
|
16133
|
-
let docLeft = Math.floor((viewWidth - contentWidth) / 2);
|
16182
|
+
//let docLeft = Math.floor((viewWidth - contentWidth) / 2);
|
16183
|
+
//处理由于缩放问题,transform-origin:left-top,因此需要提前计算需要偏移的位置
|
16184
|
+
let docLeft = Math.floor((viewWidth - contentWidth * scale) / 2) / scale;
|
16134
16185
|
docLeft = docLeft < 0 ? 0 : docLeft;
|
16135
16186
|
pages.forEach(item => item.rect.x = docLeft);
|
16136
16187
|
this.docContainer.rect.x = 0;
|
@@ -16281,6 +16332,132 @@ class PageBreakFactory extends ElementFactory {
|
|
16281
16332
|
}
|
16282
16333
|
}
|
16283
16334
|
|
16335
|
+
const fontSize = 12;
|
16336
|
+
const verPadding = 2;
|
16337
|
+
/**
|
16338
|
+
* 恒牙牙位图
|
16339
|
+
*/
|
16340
|
+
class PermanentTeethElement extends LeafElement {
|
16341
|
+
constructor() {
|
16342
|
+
super('permanent-teeth');
|
16343
|
+
this.props = new PermanentTeethProps();
|
16344
|
+
this.props.topLeft = '87654321';
|
16345
|
+
this.props.topRight = '12345678';
|
16346
|
+
this.props.bottomLeft = '87654321';
|
16347
|
+
this.props.bottomRight = '12345678';
|
16348
|
+
}
|
16349
|
+
clone(data) {
|
16350
|
+
const clone = new PermanentTeethElement();
|
16351
|
+
clone.props = this.props.clone();
|
16352
|
+
return clone;
|
16353
|
+
}
|
16354
|
+
createRenderObject(data) {
|
16355
|
+
const clone = new PermanentTeethRenderObject(this);
|
16356
|
+
clone.rect.width = 150;
|
16357
|
+
//字体大小*2+上下间距2*2
|
16358
|
+
clone.rect.height = fontSize * 2 + verPadding * 2;
|
16359
|
+
//clone.rect= ElementUtil.cloneRect(this.rect);
|
16360
|
+
return clone;
|
16361
|
+
}
|
16362
|
+
serialize(viewOptions) {
|
16363
|
+
return {
|
16364
|
+
type: this.type,
|
16365
|
+
props: this.props.getSerializeProps(viewOptions)
|
16366
|
+
};
|
16367
|
+
}
|
16368
|
+
}
|
16369
|
+
class PermanentTeethRenderObject extends LeafRenderObject {
|
16370
|
+
render(e) {
|
16371
|
+
}
|
16372
|
+
clone() {
|
16373
|
+
const clone = new PermanentTeethRenderObject(this.element);
|
16374
|
+
clone.rect = ElementUtil.cloneRect(this.rect);
|
16375
|
+
return clone;
|
16376
|
+
}
|
16377
|
+
// measure(): { width: number, height: number } {
|
16378
|
+
// const ele = this.element;
|
16379
|
+
//
|
16380
|
+
// }
|
16381
|
+
exportHTML(event) {
|
16382
|
+
const ele = this.element;
|
16383
|
+
const g = super.exportHTML(event);
|
16384
|
+
const contentHorPadding = 4;
|
16385
|
+
g.children = [];
|
16386
|
+
// g.children.push(ElementUtil.getFillSvgPath(`M 0 ${this.rect.height / 2} h${this.rect.width}`, '#000', 1));
|
16387
|
+
// g.children.push(ElementUtil.getFillSvgPath(`M ${this.rect.width / 2} 0 v${this.rect.height}`, '#000', 1));
|
16388
|
+
//
|
16389
|
+
g.children.push(ElementUtil.getFillSvgRect(0, this.rect.height / 2, this.rect.width, 1, '#000'));
|
16390
|
+
g.children.push(ElementUtil.getFillSvgRect(this.rect.width / 2, 0, 1, this.rect.height, '#000'));
|
16391
|
+
const getSvgText = (text, x, y) => {
|
16392
|
+
return {
|
16393
|
+
sel: 'text',
|
16394
|
+
text: text,
|
16395
|
+
data: {
|
16396
|
+
ns: "http://www.w3.org/2000/svg",
|
16397
|
+
attrs: {
|
16398
|
+
'dominant-baseline': 'hanging',
|
16399
|
+
'font-family': 'Arial',
|
16400
|
+
'font-size': fontSize,
|
16401
|
+
x,
|
16402
|
+
y,
|
16403
|
+
}
|
16404
|
+
},
|
16405
|
+
};
|
16406
|
+
};
|
16407
|
+
const topLeftWidth = event.renderCtx.mainContext.measureTextWidth(ele.props.topLeft, {
|
16408
|
+
fontSize: fontSize,
|
16409
|
+
fontName: 'Arial'
|
16410
|
+
});
|
16411
|
+
const bottomLeftWidth = event.renderCtx.mainContext.measureTextWidth(ele.props.bottomLeft, {
|
16412
|
+
fontSize: fontSize,
|
16413
|
+
fontName: 'Arial'
|
16414
|
+
});
|
16415
|
+
g.children.push(getSvgText(ele.props.topLeft, this.rect.width / 2 - topLeftWidth - contentHorPadding, verPadding));
|
16416
|
+
g.children.push(getSvgText(ele.props.topRight, this.rect.width / 2 + contentHorPadding, verPadding));
|
16417
|
+
g.children.push(getSvgText(ele.props.bottomLeft, this.rect.width / 2 - bottomLeftWidth - contentHorPadding, this.rect.height - fontSize + verPadding));
|
16418
|
+
g.children.push(getSvgText(ele.props.bottomRight, this.rect.width / 2 + contentHorPadding, this.rect.height - fontSize + verPadding));
|
16419
|
+
return g;
|
16420
|
+
}
|
16421
|
+
}
|
16422
|
+
class PermanentTeethFactory extends ElementFactory {
|
16423
|
+
match(type) {
|
16424
|
+
return type === 'permanent-teeth';
|
16425
|
+
}
|
16426
|
+
createElement(data) {
|
16427
|
+
const ele = new PermanentTeethElement();
|
16428
|
+
ele.props.bottomLeft = data.props?.bottomLeft ?? '';
|
16429
|
+
ele.props.bottomRight = data.props?.bottomRight ?? '';
|
16430
|
+
ele.props.topLeft = data.props?.topLeft ?? '';
|
16431
|
+
ele.props.topRight = data.props?.topRight ?? '';
|
16432
|
+
return ele;
|
16433
|
+
}
|
16434
|
+
}
|
16435
|
+
/**
|
16436
|
+
* 恒牙牙位图属性
|
16437
|
+
*/
|
16438
|
+
class PermanentTeethProps extends INotifyPropertyChanged {
|
16439
|
+
topLeft;
|
16440
|
+
topRight;
|
16441
|
+
bottomLeft;
|
16442
|
+
bottomRight;
|
16443
|
+
getSerializeProps(viewOptions) {
|
16444
|
+
return {
|
16445
|
+
topLeft: this.topLeft,
|
16446
|
+
topRight: this.topRight,
|
16447
|
+
bottomLeft: this.bottomLeft,
|
16448
|
+
bottomRight: this.bottomRight,
|
16449
|
+
};
|
16450
|
+
}
|
16451
|
+
clone(dest) {
|
16452
|
+
dest = dest || new PermanentTeethProps();
|
16453
|
+
dest.topLeft = this.topLeft;
|
16454
|
+
dest.topRight = this.topRight;
|
16455
|
+
dest.bottomLeft = this.bottomLeft;
|
16456
|
+
dest.bottomRight = this.bottomRight;
|
16457
|
+
return dest;
|
16458
|
+
}
|
16459
|
+
}
|
16460
|
+
|
16284
16461
|
class ElementReader {
|
16285
16462
|
docCtx;
|
16286
16463
|
constructor(docCtx) {
|
@@ -16322,6 +16499,7 @@ class ElementReader {
|
|
16322
16499
|
this.addFactory(DocumentBodyPartFactory);
|
16323
16500
|
this.addFactory(PageBreakFactory);
|
16324
16501
|
this.addFactory(TabFactory);
|
16502
|
+
this.addFactory(PermanentTeethFactory);
|
16325
16503
|
// this.registerReadFunc<TrackRunProps>('ins-run', (data) => {
|
16326
16504
|
// const props = new TrackRunProps(data.type);
|
16327
16505
|
// props.userId = data.userId;
|
@@ -17015,6 +17193,7 @@ class DocumentEvent {
|
|
17015
17193
|
docEvent.shift = evt.shiftKey;
|
17016
17194
|
docEvent.ctrl = evt.ctrlKey;
|
17017
17195
|
this.ismousedown = false;
|
17196
|
+
this.mousedownPos = { x: docEvent.globalX, y: docEvent.globalY };
|
17018
17197
|
//console.log('松开了')
|
17019
17198
|
this.edgeRenderInfo = null;
|
17020
17199
|
}
|
@@ -19137,7 +19316,8 @@ class DocumentChange {
|
|
19137
19316
|
if (!prevEle) {
|
19138
19317
|
const nextEle = ElementUtil.getRecursionNextSiblingElement(control, true, true, this.viewOptions);
|
19139
19318
|
if (nextEle) {
|
19140
|
-
this.selectionState.resetRange(nextEle, 0);
|
19319
|
+
//this.selectionState.resetRange(nextEle, 0);
|
19320
|
+
this.setSelectionStateByDeleteEvent(nextEle, 0, control);
|
19141
19321
|
control.remove();
|
19142
19322
|
return;
|
19143
19323
|
}
|
@@ -19145,24 +19325,48 @@ class DocumentChange {
|
|
19145
19325
|
return;
|
19146
19326
|
}
|
19147
19327
|
if (ElementUtil.isInSameParagraph(control, prevEle)) {
|
19148
|
-
this.selectionState.resetRange(prevEle, -1);
|
19328
|
+
//this.selectionState.resetRange(prevEle, -1);
|
19329
|
+
this.setSelectionStateByDeleteEvent(prevEle, -1, control);
|
19149
19330
|
control.remove();
|
19150
19331
|
return;
|
19151
19332
|
}
|
19152
19333
|
else {
|
19153
19334
|
const nextEle = ElementUtil.getRecursionNextSiblingElement(control, true, true, this.viewOptions);
|
19154
19335
|
if (nextEle && ElementUtil.getPrevSiblingElement(nextEle) === control) {
|
19155
|
-
this.selectionState.resetRange(nextEle, 0);
|
19336
|
+
//this.selectionState.resetRange(nextEle, 0);
|
19337
|
+
this.setSelectionStateByDeleteEvent(nextEle, 0, control);
|
19156
19338
|
control.remove();
|
19157
19339
|
return;
|
19158
19340
|
}
|
19159
19341
|
else {
|
19160
|
-
this.selectionState.resetRange(prevEle, -1);
|
19342
|
+
//this.selectionState.resetRange(prevEle, -1);
|
19343
|
+
this.setSelectionStateByDeleteEvent(prevEle, -1, control);
|
19161
19344
|
control.remove();
|
19162
19345
|
return;
|
19163
19346
|
}
|
19164
19347
|
}
|
19165
19348
|
}
|
19349
|
+
/**
|
19350
|
+
* 处理在表单模式下光标定位的问题
|
19351
|
+
* @param target
|
19352
|
+
* @param targetOffset
|
19353
|
+
* @param deleteTarget
|
19354
|
+
* @private
|
19355
|
+
*/
|
19356
|
+
setSelectionStateByDeleteEvent(target, targetOffset, deleteTarget) {
|
19357
|
+
if (this.viewOptions.docMode === DocMode.FormEdit) {
|
19358
|
+
const dataEle = ElementUtil.getParent(deleteTarget, (item) => item instanceof DataElementInlineGroup);
|
19359
|
+
if (dataEle && ElementUtil.getParent(target, (item) => item instanceof DataElementInlineGroup) === dataEle) {
|
19360
|
+
this.selectionState.resetRange(target, targetOffset);
|
19361
|
+
return;
|
19362
|
+
}
|
19363
|
+
if (dataEle) {
|
19364
|
+
this.selectionState.resetRange(dataEle.startDecorate, 1);
|
19365
|
+
return;
|
19366
|
+
}
|
19367
|
+
}
|
19368
|
+
this.selectionState.resetRange(target, targetOffset);
|
19369
|
+
}
|
19166
19370
|
/**
|
19167
19371
|
* 回车事件
|
19168
19372
|
*/
|
@@ -20888,7 +21092,7 @@ class DocumentSvg {
|
|
20888
21092
|
}
|
20889
21093
|
getHTMLVNode(docRenders) {
|
20890
21094
|
this.counterMap = {};
|
20891
|
-
const pageNodes = docRenders.map(item => {
|
21095
|
+
const pageNodes = docRenders.filter(item => this.checkInViewBox(item)).map(item => {
|
20892
21096
|
const pageSvg = this.getPageSvgVNode(item);
|
20893
21097
|
const pageUnit = {
|
20894
21098
|
sel: 'div.page-unit',
|
@@ -20913,6 +21117,24 @@ class DocumentSvg {
|
|
20913
21117
|
});
|
20914
21118
|
return pageNodes;
|
20915
21119
|
}
|
21120
|
+
/**
|
21121
|
+
* 判断当前元素是否在视窗内
|
21122
|
+
* @param rect
|
21123
|
+
* @private
|
21124
|
+
*/
|
21125
|
+
checkInViewBox(item) {
|
21126
|
+
if (!this.viewOptions.virtualViewMode || this.mode === 'print') {
|
21127
|
+
return true;
|
21128
|
+
}
|
21129
|
+
const viewBoxRect = {
|
21130
|
+
x: this.viewOptions.pageOffset.x,
|
21131
|
+
y: this.viewOptions.pageOffset.y,
|
21132
|
+
width: this.viewOptions.viewSettings.width,
|
21133
|
+
height: this.viewOptions.viewSettings.height
|
21134
|
+
};
|
21135
|
+
const eleRect = item.rect;
|
21136
|
+
return CommonUtil.isIntersect(viewBoxRect, eleRect);
|
21137
|
+
}
|
20916
21138
|
getPageSvgVNode(item) {
|
20917
21139
|
this.highlights = [];
|
20918
21140
|
const rects = [];
|
@@ -26142,6 +26364,7 @@ function createSignal(state) {
|
|
26142
26364
|
* 渲染日历虚拟节点处理类
|
26143
26365
|
*/
|
26144
26366
|
class EditorCalendarVNode {
|
26367
|
+
viewOptions;
|
26145
26368
|
currYear;
|
26146
26369
|
currMonth;
|
26147
26370
|
currCalendarMode;
|
@@ -26150,7 +26373,8 @@ class EditorCalendarVNode {
|
|
26150
26373
|
onSetValue = new Subject$1();
|
26151
26374
|
currTime;
|
26152
26375
|
selectedTime;
|
26153
|
-
constructor() {
|
26376
|
+
constructor(viewOptions) {
|
26377
|
+
this.viewOptions = viewOptions;
|
26154
26378
|
this.currYear = createSignal(new Date().getFullYear());
|
26155
26379
|
//月份赋值是按照索引来的,所以要减1
|
26156
26380
|
this.currMonth = createSignal(new Date().getMonth());
|
@@ -26218,36 +26442,49 @@ class EditorCalendarVNode {
|
|
26218
26442
|
hook: {
|
26219
26443
|
insert: (vnode) => {
|
26220
26444
|
const elm = vnode.elm;
|
26221
|
-
|
26222
|
-
|
26223
|
-
|
26224
|
-
|
26225
|
-
|
26226
|
-
elm.style.top = (position.y - elmRect.height) + 'px';
|
26227
|
-
}
|
26228
|
-
if (elmRect.left < parentRect.left) {
|
26229
|
-
elm.style.left = (position.x - 10) + 'px';
|
26230
|
-
}
|
26231
|
-
if (elmRect.right > parentRect.right) {
|
26232
|
-
elm.style.left = (position.x - elmRect.width + 10) + 'px';
|
26233
|
-
}
|
26234
|
-
if (elmRect.top + elmRect.height > parentRect.top + parentRect.height) {
|
26235
|
-
const newTop = position.y - position.height - elmRect.height;
|
26236
|
-
const oldTop = position.y + 5 + position.height;
|
26237
|
-
//计算前后的高度的差距,然后判断新的值是否在父元素的范围内,如果不在则使用旧的值
|
26238
|
-
if (oldTop - newTop < elmRect.top - parentRect.top) {
|
26239
|
-
elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
26240
|
-
}
|
26241
|
-
//elm.style.top = (top - (elmRect.top + elmRect.height - (parentRect.top + parentRect.height))) + 'px';
|
26242
|
-
//elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
26243
|
-
}
|
26244
|
-
}
|
26445
|
+
this.resizePosition(elm, position);
|
26446
|
+
},
|
26447
|
+
update: (oldVnode, vnode) => {
|
26448
|
+
const elm = vnode.elm;
|
26449
|
+
this.resizePosition(elm, position);
|
26245
26450
|
}
|
26246
26451
|
},
|
26247
26452
|
},
|
26248
26453
|
children: []
|
26249
26454
|
};
|
26250
26455
|
}
|
26456
|
+
resizePosition(elm, position) {
|
26457
|
+
const parent = CommonUtil.findParent(elm, (item) => item.className === 'scroll-container');
|
26458
|
+
const scale = this.viewOptions.scale;
|
26459
|
+
if (parent) {
|
26460
|
+
const parentRect = parent.getBoundingClientRect();
|
26461
|
+
const elmRect = elm.getBoundingClientRect();
|
26462
|
+
// elmRect.width /= scale;
|
26463
|
+
// elmRect.height /= scale;
|
26464
|
+
// parentRect.width /= scale;
|
26465
|
+
// parentRect.height /= scale;
|
26466
|
+
if (elmRect.top < parentRect.top) {
|
26467
|
+
elm.style.top = (position.y - elmRect.height / scale) + 'px';
|
26468
|
+
}
|
26469
|
+
if (elmRect.left < parentRect.left) {
|
26470
|
+
elm.style.left = (position.x - 10) + 'px';
|
26471
|
+
}
|
26472
|
+
if (elmRect.right > parentRect.right) {
|
26473
|
+
elm.style.left = (position.x - elmRect.width / scale + 10) + 'px';
|
26474
|
+
//elm.style.left = parentRect.width - elmRect.width + 'px';
|
26475
|
+
}
|
26476
|
+
if (elmRect.top + elmRect.height > parentRect.top + parentRect.height) {
|
26477
|
+
const newTop = position.y - position.height - elmRect.height;
|
26478
|
+
const oldTop = position.y + 5 + position.height;
|
26479
|
+
//计算前后的高度的差距,然后判断新的值是否在父元素的范围内,如果不在则使用旧的值
|
26480
|
+
if (newTop > 0 && oldTop - newTop < elmRect.top - parentRect.top) {
|
26481
|
+
elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
26482
|
+
}
|
26483
|
+
//elm.style.top = (top - (elmRect.top + elmRect.height - (parentRect.top + parentRect.height))) + 'px';
|
26484
|
+
//elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
26485
|
+
}
|
26486
|
+
}
|
26487
|
+
}
|
26251
26488
|
renderDay() {
|
26252
26489
|
//获取当前月份需要渲染的天数集合
|
26253
26490
|
const days = this.getDays();
|
@@ -27092,8 +27329,13 @@ class DocEditor {
|
|
27092
27329
|
const listVNode = this.renderDataListVNode();
|
27093
27330
|
const dropContainer = {
|
27094
27331
|
sel: 'div.drop-container',
|
27095
|
-
data: {
|
27096
|
-
|
27332
|
+
data: {
|
27333
|
+
style: {
|
27334
|
+
'transform-origin': '0 0',
|
27335
|
+
'transform': `scale(${this.viewOptions.scale})`
|
27336
|
+
}
|
27337
|
+
},
|
27338
|
+
children: [inputVNode, listVNode.render(), calendarFunc.render(), menuFunc.render()]
|
27097
27339
|
};
|
27098
27340
|
return {
|
27099
27341
|
sel: 'div.svg-container',
|
@@ -27131,18 +27373,7 @@ class DocEditor {
|
|
27131
27373
|
}
|
27132
27374
|
}
|
27133
27375
|
},
|
27134
|
-
children: [
|
27135
|
-
{
|
27136
|
-
sel: 'div.scale-container', data: {
|
27137
|
-
style: {
|
27138
|
-
transform: 'scale(' + this.viewOptions.scale + ')',
|
27139
|
-
transformOrigin: 'right top',
|
27140
|
-
width: this.viewOptions.docPageSettings.width + 'px',
|
27141
|
-
}
|
27142
|
-
},
|
27143
|
-
children: [docContentVNode, inputVNode, dropContainer]
|
27144
|
-
}
|
27145
|
-
]
|
27376
|
+
children: [docContentVNode, dropContainer]
|
27146
27377
|
}, ruleFunc.refreshRuleSvg().render()
|
27147
27378
|
]
|
27148
27379
|
};
|
@@ -27530,11 +27761,11 @@ class DocEditor {
|
|
27530
27761
|
this.updateRenderCtx();
|
27531
27762
|
this.flushToSchedule();
|
27532
27763
|
this.documentPaint.layoutPages();
|
27533
|
-
const sub = this.afterNodePatch.subscribe(() => {
|
27534
|
-
|
27535
|
-
|
27536
|
-
|
27537
|
-
})
|
27764
|
+
// const sub = this.afterNodePatch.subscribe(() => {
|
27765
|
+
// sub.unsubscribe();
|
27766
|
+
// const scrollDOM = this.svgContainer.querySelector('.scroll-container') as HTMLElement;
|
27767
|
+
// scrollDOM.scrollLeft = (scrollDOM.scrollWidth - scrollDOM.getBoundingClientRect().width) / 2;
|
27768
|
+
// })
|
27538
27769
|
return scale;
|
27539
27770
|
}
|
27540
27771
|
updateRenderCtx() {
|
@@ -28066,6 +28297,8 @@ class DocEditor {
|
|
28066
28297
|
position: 'relative',
|
28067
28298
|
width: '0px',
|
28068
28299
|
'user-select': 'none',
|
28300
|
+
transform: 'scale(' + this.viewOptions.scale + ')',
|
28301
|
+
'transform-origin': '0 0'
|
28069
28302
|
},
|
28070
28303
|
on: this.documentEvent.getEventListener()
|
28071
28304
|
},
|
@@ -28244,30 +28477,11 @@ class DocEditor {
|
|
28244
28477
|
hook: {
|
28245
28478
|
insert: (vnode) => {
|
28246
28479
|
const elm = vnode.elm;
|
28247
|
-
|
28248
|
-
|
28249
|
-
|
28250
|
-
|
28251
|
-
|
28252
|
-
elm.style.top = (position.y - elmRect.height) + 'px';
|
28253
|
-
}
|
28254
|
-
if (elmRect.left < parentRect.left) {
|
28255
|
-
elm.style.left = (position.x - 10) + 'px';
|
28256
|
-
}
|
28257
|
-
if (elmRect.right > parentRect.right) {
|
28258
|
-
elm.style.left = (position.x - elmRect.width + 10) + 'px';
|
28259
|
-
}
|
28260
|
-
if (elmRect.top + elmRect.height > parentRect.top + parentRect.height) {
|
28261
|
-
const newTop = position.y - position.height - elmRect.height;
|
28262
|
-
const oldTop = position.y + 5 + position.height;
|
28263
|
-
//计算前后的高度的差距,然后判断新的值是否在父元素的范围内,如果不在则使用旧的值
|
28264
|
-
if (oldTop - newTop < elmRect.top - parentRect.top) {
|
28265
|
-
elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
28266
|
-
}
|
28267
|
-
//elm.style.top = (top - (elmRect.top + elmRect.height - (parentRect.top + parentRect.height))) + 'px';
|
28268
|
-
//elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
28269
|
-
}
|
28270
|
-
}
|
28480
|
+
editor.resizePosition(elm, position);
|
28481
|
+
},
|
28482
|
+
update: (oldVnode, vnode) => {
|
28483
|
+
const elm = vnode.elm;
|
28484
|
+
editor.resizePosition(elm, position);
|
28271
28485
|
}
|
28272
28486
|
},
|
28273
28487
|
},
|
@@ -28286,8 +28500,40 @@ class DocEditor {
|
|
28286
28500
|
}
|
28287
28501
|
};
|
28288
28502
|
}
|
28503
|
+
resizePosition(elm, position) {
|
28504
|
+
const parent = CommonUtil.findParent(elm, (item) => item.className === 'scroll-container');
|
28505
|
+
const scale = this.viewOptions.scale;
|
28506
|
+
if (parent) {
|
28507
|
+
const parentRect = parent.getBoundingClientRect();
|
28508
|
+
const elmRect = elm.getBoundingClientRect();
|
28509
|
+
// elmRect.width /= scale;
|
28510
|
+
// elmRect.height /= scale;
|
28511
|
+
// parentRect.width /= scale;
|
28512
|
+
// parentRect.height /= scale;
|
28513
|
+
if (elmRect.top < parentRect.top) {
|
28514
|
+
elm.style.top = (position.y - elmRect.height / scale) + 'px';
|
28515
|
+
}
|
28516
|
+
if (elmRect.left < parentRect.left) {
|
28517
|
+
elm.style.left = (position.x - 10) + 'px';
|
28518
|
+
}
|
28519
|
+
if (elmRect.right > parentRect.right) {
|
28520
|
+
elm.style.left = (position.x - elmRect.width / scale + 10) + 'px';
|
28521
|
+
//elm.style.left = parentRect.width - elmRect.width + 'px';
|
28522
|
+
}
|
28523
|
+
if (elmRect.top + elmRect.height > parentRect.top + parentRect.height) {
|
28524
|
+
const newTop = position.y - position.height - elmRect.height;
|
28525
|
+
const oldTop = position.y + 5 + position.height;
|
28526
|
+
//计算前后的高度的差距,然后判断新的值是否在父元素的范围内,如果不在则使用旧的值
|
28527
|
+
if (newTop > 0 && oldTop - newTop < elmRect.top - parentRect.top) {
|
28528
|
+
elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
28529
|
+
}
|
28530
|
+
//elm.style.top = (top - (elmRect.top + elmRect.height - (parentRect.top + parentRect.height))) + 'px';
|
28531
|
+
//elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
28532
|
+
}
|
28533
|
+
}
|
28534
|
+
}
|
28289
28535
|
renderCalendar() {
|
28290
|
-
const calendar = new EditorCalendarVNode();
|
28536
|
+
const calendar = new EditorCalendarVNode(this.viewOptions);
|
28291
28537
|
const editor = this;
|
28292
28538
|
calendar.onSetValue.subscribe((value) => {
|
28293
28539
|
const dataEle = editor.getCurrentDataElement();
|
@@ -28373,7 +28619,7 @@ class DocEditor {
|
|
28373
28619
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
28374
28620
|
}
|
28375
28621
|
version() {
|
28376
|
-
return "2.1.
|
28622
|
+
return "2.1.2";
|
28377
28623
|
}
|
28378
28624
|
}
|
28379
28625
|
|