@hailin-zheng/editor-core 2.1.1 → 2.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/index-cjs.js +174 -4
- package/index-cjs.js.map +1 -1
- package/index.js +174 -4
- package/index.js.map +1 -1
- package/med_editor/framework/common-util.d.ts +1 -0
- package/med_editor/framework/document-svg.d.ts +6 -0
- package/med_editor/framework/element-define.d.ts +1 -0
- package/med_editor/framework/impl/media-formula/permanent-teeth.d.ts +19 -15
- package/package.json +1 -1
package/index-cjs.js
CHANGED
@@ -680,6 +680,23 @@ class CommonUtil {
|
|
680
680
|
}
|
681
681
|
return this.findParent(curr.parentElement, predicate);
|
682
682
|
}
|
683
|
+
static isIntersect(rect1, rect2) {
|
684
|
+
const left1 = rect1.x;
|
685
|
+
const top1 = rect1.y;
|
686
|
+
const right1 = rect1.x + rect1.width;
|
687
|
+
const bottom1 = rect1.y + rect1.height;
|
688
|
+
const left2 = rect2.x;
|
689
|
+
const top2 = rect2.y;
|
690
|
+
const right2 = rect2.x + rect2.width;
|
691
|
+
const bottom2 = rect2.y + rect2.height;
|
692
|
+
if (left1 >= right2 || left2 >= right1) {
|
693
|
+
return false;
|
694
|
+
}
|
695
|
+
if (top1 >= bottom2 || top2 >= bottom1) {
|
696
|
+
return false;
|
697
|
+
}
|
698
|
+
return true;
|
699
|
+
}
|
683
700
|
}
|
684
701
|
|
685
702
|
const docOpsMap = new Map();
|
@@ -1546,6 +1563,8 @@ class ViewOptions {
|
|
1546
1563
|
paraSymbolColor = 'rgb(128,128,128)';
|
1547
1564
|
dataGroupColor = 'rgb(0,80,179)';
|
1548
1565
|
defaultLineHeight = 1;
|
1566
|
+
//虚拟视图模式,处理可视区域内的元素
|
1567
|
+
virtualViewMode = false;
|
1549
1568
|
//新增-留痕块文本颜色
|
1550
1569
|
trackInsColor = '#ff4d4f';
|
1551
1570
|
//删除-留痕块文本颜色
|
@@ -16185,13 +16204,13 @@ class DocumentPaint {
|
|
16185
16204
|
this.docContainer.clear();
|
16186
16205
|
const { pageLayoutMode, viewSettings: { width: viewWidth } } = this.viewOptions;
|
16187
16206
|
//文档内容区宽度
|
16188
|
-
const contentWidth = this.viewOptions
|
16207
|
+
const { contentWidth, scale } = this.viewOptions;
|
16189
16208
|
//文档容器总宽度等于内容宽度
|
16190
16209
|
//单页模式,docContainer居中
|
16191
16210
|
this.docContainer.rect.width = viewWidth;
|
16192
16211
|
//let docLeft = Math.floor((viewWidth - contentWidth) / 2);
|
16193
16212
|
//处理由于缩放问题,transform-origin:left-top,因此需要提前计算需要偏移的位置
|
16194
|
-
let docLeft = Math.floor((viewWidth - contentWidth *
|
16213
|
+
let docLeft = Math.floor((viewWidth - contentWidth * scale) / 2) / scale;
|
16195
16214
|
docLeft = docLeft < 0 ? 0 : docLeft;
|
16196
16215
|
pages.forEach(item => item.rect.x = docLeft);
|
16197
16216
|
this.docContainer.rect.x = 0;
|
@@ -16342,6 +16361,132 @@ class PageBreakFactory extends ElementFactory {
|
|
16342
16361
|
}
|
16343
16362
|
}
|
16344
16363
|
|
16364
|
+
const fontSize = 12;
|
16365
|
+
const verPadding = 2;
|
16366
|
+
/**
|
16367
|
+
* 恒牙牙位图
|
16368
|
+
*/
|
16369
|
+
class PermanentTeethElement extends LeafElement {
|
16370
|
+
constructor() {
|
16371
|
+
super('permanent-teeth');
|
16372
|
+
this.props = new PermanentTeethProps();
|
16373
|
+
this.props.topLeft = '';
|
16374
|
+
this.props.topRight = '';
|
16375
|
+
this.props.bottomLeft = '';
|
16376
|
+
this.props.bottomRight = '';
|
16377
|
+
}
|
16378
|
+
clone(data) {
|
16379
|
+
const clone = new PermanentTeethElement();
|
16380
|
+
clone.props = this.props.clone();
|
16381
|
+
return clone;
|
16382
|
+
}
|
16383
|
+
createRenderObject(data) {
|
16384
|
+
const clone = new PermanentTeethRenderObject(this);
|
16385
|
+
clone.rect.width = 150;
|
16386
|
+
//字体大小*2+上下间距2*2
|
16387
|
+
clone.rect.height = fontSize * 2 + verPadding * 2;
|
16388
|
+
//clone.rect= ElementUtil.cloneRect(this.rect);
|
16389
|
+
return clone;
|
16390
|
+
}
|
16391
|
+
serialize(viewOptions) {
|
16392
|
+
return {
|
16393
|
+
type: this.type,
|
16394
|
+
props: this.props.getSerializeProps(viewOptions)
|
16395
|
+
};
|
16396
|
+
}
|
16397
|
+
}
|
16398
|
+
class PermanentTeethRenderObject extends LeafRenderObject {
|
16399
|
+
render(e) {
|
16400
|
+
}
|
16401
|
+
clone() {
|
16402
|
+
const clone = new PermanentTeethRenderObject(this.element);
|
16403
|
+
clone.rect = ElementUtil.cloneRect(this.rect);
|
16404
|
+
return clone;
|
16405
|
+
}
|
16406
|
+
// measure(): { width: number, height: number } {
|
16407
|
+
// const ele = this.element;
|
16408
|
+
//
|
16409
|
+
// }
|
16410
|
+
exportHTML(event) {
|
16411
|
+
const ele = this.element;
|
16412
|
+
const g = super.exportHTML(event);
|
16413
|
+
const contentHorPadding = 4;
|
16414
|
+
g.children = [];
|
16415
|
+
// g.children.push(ElementUtil.getFillSvgPath(`M 0 ${this.rect.height / 2} h${this.rect.width}`, '#000', 1));
|
16416
|
+
// g.children.push(ElementUtil.getFillSvgPath(`M ${this.rect.width / 2} 0 v${this.rect.height}`, '#000', 1));
|
16417
|
+
//
|
16418
|
+
g.children.push(ElementUtil.getFillSvgRect(0, this.rect.height / 2, this.rect.width, 1, '#000'));
|
16419
|
+
g.children.push(ElementUtil.getFillSvgRect(this.rect.width / 2, 0, 1, this.rect.height, '#000'));
|
16420
|
+
const getSvgText = (text, x, y) => {
|
16421
|
+
return {
|
16422
|
+
sel: 'text',
|
16423
|
+
text: text,
|
16424
|
+
data: {
|
16425
|
+
ns: "http://www.w3.org/2000/svg",
|
16426
|
+
attrs: {
|
16427
|
+
'dominant-baseline': 'hanging',
|
16428
|
+
'font-family': 'Arial',
|
16429
|
+
'font-size': fontSize,
|
16430
|
+
x,
|
16431
|
+
y,
|
16432
|
+
}
|
16433
|
+
},
|
16434
|
+
};
|
16435
|
+
};
|
16436
|
+
const topLeftWidth = event.renderCtx.mainContext.measureTextWidth(ele.props.topLeft, {
|
16437
|
+
fontSize: fontSize,
|
16438
|
+
fontName: 'Arial'
|
16439
|
+
});
|
16440
|
+
const bottomLeftWidth = event.renderCtx.mainContext.measureTextWidth(ele.props.bottomLeft, {
|
16441
|
+
fontSize: fontSize,
|
16442
|
+
fontName: 'Arial'
|
16443
|
+
});
|
16444
|
+
g.children.push(getSvgText(ele.props.topLeft, this.rect.width / 2 - topLeftWidth - contentHorPadding, verPadding));
|
16445
|
+
g.children.push(getSvgText(ele.props.topRight, this.rect.width / 2 + contentHorPadding, verPadding));
|
16446
|
+
g.children.push(getSvgText(ele.props.bottomLeft, this.rect.width / 2 - bottomLeftWidth - contentHorPadding, this.rect.height - fontSize + verPadding));
|
16447
|
+
g.children.push(getSvgText(ele.props.bottomRight, this.rect.width / 2 + contentHorPadding, this.rect.height - fontSize + verPadding));
|
16448
|
+
return g;
|
16449
|
+
}
|
16450
|
+
}
|
16451
|
+
class PermanentTeethFactory extends ElementFactory {
|
16452
|
+
match(type) {
|
16453
|
+
return type === 'permanent-teeth';
|
16454
|
+
}
|
16455
|
+
createElement(data) {
|
16456
|
+
const ele = new PermanentTeethElement();
|
16457
|
+
ele.props.bottomLeft = data.props?.bottomLeft ?? '';
|
16458
|
+
ele.props.bottomRight = data.props?.bottomRight ?? '';
|
16459
|
+
ele.props.topLeft = data.props?.topLeft ?? '';
|
16460
|
+
ele.props.topRight = data.props?.topRight ?? '';
|
16461
|
+
return ele;
|
16462
|
+
}
|
16463
|
+
}
|
16464
|
+
/**
|
16465
|
+
* 恒牙牙位图属性
|
16466
|
+
*/
|
16467
|
+
class PermanentTeethProps extends INotifyPropertyChanged {
|
16468
|
+
topLeft;
|
16469
|
+
topRight;
|
16470
|
+
bottomLeft;
|
16471
|
+
bottomRight;
|
16472
|
+
getSerializeProps(viewOptions) {
|
16473
|
+
return {
|
16474
|
+
topLeft: this.topLeft,
|
16475
|
+
topRight: this.topRight,
|
16476
|
+
bottomLeft: this.bottomLeft,
|
16477
|
+
bottomRight: this.bottomRight,
|
16478
|
+
};
|
16479
|
+
}
|
16480
|
+
clone(dest) {
|
16481
|
+
dest = dest || new PermanentTeethProps();
|
16482
|
+
dest.topLeft = this.topLeft;
|
16483
|
+
dest.topRight = this.topRight;
|
16484
|
+
dest.bottomLeft = this.bottomLeft;
|
16485
|
+
dest.bottomRight = this.bottomRight;
|
16486
|
+
return dest;
|
16487
|
+
}
|
16488
|
+
}
|
16489
|
+
|
16345
16490
|
class ElementReader {
|
16346
16491
|
docCtx;
|
16347
16492
|
constructor(docCtx) {
|
@@ -16383,6 +16528,7 @@ class ElementReader {
|
|
16383
16528
|
this.addFactory(DocumentBodyPartFactory);
|
16384
16529
|
this.addFactory(PageBreakFactory);
|
16385
16530
|
this.addFactory(TabFactory);
|
16531
|
+
this.addFactory(PermanentTeethFactory);
|
16386
16532
|
// this.registerReadFunc<TrackRunProps>('ins-run', (data) => {
|
16387
16533
|
// const props = new TrackRunProps(data.type);
|
16388
16534
|
// props.userId = data.userId;
|
@@ -17076,6 +17222,7 @@ class DocumentEvent {
|
|
17076
17222
|
docEvent.shift = evt.shiftKey;
|
17077
17223
|
docEvent.ctrl = evt.ctrlKey;
|
17078
17224
|
this.ismousedown = false;
|
17225
|
+
this.mousedownPos = { x: docEvent.globalX, y: docEvent.globalY };
|
17079
17226
|
//console.log('松开了')
|
17080
17227
|
this.edgeRenderInfo = null;
|
17081
17228
|
}
|
@@ -20974,7 +21121,7 @@ class DocumentSvg {
|
|
20974
21121
|
}
|
20975
21122
|
getHTMLVNode(docRenders) {
|
20976
21123
|
this.counterMap = {};
|
20977
|
-
const pageNodes = docRenders.map(item => {
|
21124
|
+
const pageNodes = docRenders.filter(item => this.checkInViewBox(item)).map(item => {
|
20978
21125
|
const pageSvg = this.getPageSvgVNode(item);
|
20979
21126
|
const pageUnit = {
|
20980
21127
|
sel: 'div.page-unit',
|
@@ -20999,6 +21146,29 @@ class DocumentSvg {
|
|
20999
21146
|
});
|
21000
21147
|
return pageNodes;
|
21001
21148
|
}
|
21149
|
+
/**
|
21150
|
+
* 判断当前元素是否在视窗内
|
21151
|
+
* @param rect
|
21152
|
+
* @private
|
21153
|
+
*/
|
21154
|
+
checkInViewBox(item) {
|
21155
|
+
if (!this.viewOptions.virtualViewMode || this.mode === 'print') {
|
21156
|
+
return true;
|
21157
|
+
}
|
21158
|
+
const { scale } = this.viewOptions;
|
21159
|
+
const viewBoxRect = {
|
21160
|
+
x: this.viewOptions.pageOffset.x,
|
21161
|
+
y: this.viewOptions.pageOffset.y,
|
21162
|
+
width: this.viewOptions.viewSettings.width,
|
21163
|
+
height: this.viewOptions.viewSettings.height
|
21164
|
+
};
|
21165
|
+
const eleRect = { ...item.rect };
|
21166
|
+
eleRect.x = eleRect.x * scale;
|
21167
|
+
eleRect.y = eleRect.y * scale;
|
21168
|
+
eleRect.width = eleRect.width * scale;
|
21169
|
+
eleRect.height = eleRect.height * scale;
|
21170
|
+
return CommonUtil.isIntersect(viewBoxRect, eleRect);
|
21171
|
+
}
|
21002
21172
|
getPageSvgVNode(item) {
|
21003
21173
|
this.highlights = [];
|
21004
21174
|
const rects = [];
|
@@ -28483,7 +28653,7 @@ class DocEditor {
|
|
28483
28653
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
28484
28654
|
}
|
28485
28655
|
version() {
|
28486
|
-
return "2.1.
|
28656
|
+
return "2.1.3";
|
28487
28657
|
}
|
28488
28658
|
}
|
28489
28659
|
|