@hailin-zheng/editor-core 2.0.13 → 2.0.15
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 +91 -48
- package/index-cjs.js.map +1 -1
- package/index.js +91 -48
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +4 -2
- package/med_editor/framework/document-template.d.ts +9 -0
- package/package.json +1 -1
- package/med_editor/framework/document-restriction.d.ts +0 -17
package/index.js
CHANGED
@@ -4780,45 +4780,23 @@ class TextGroupRenderObject extends LeafRenderObject {
|
|
4780
4780
|
if (this.element.props.background) {
|
4781
4781
|
const bgX = event.relativePagePos.x;
|
4782
4782
|
const bgY = event.relativePagePos.y;
|
4783
|
-
event.highlights.push(
|
4784
|
-
sel: 'path',
|
4785
|
-
data: {
|
4786
|
-
ns: "http://www.w3.org/2000/svg",
|
4787
|
-
attrs: {
|
4788
|
-
d: `M${bgX} ${bgY} h${width} v${this.rect.height} h-${width}z`,
|
4789
|
-
fill: this.element.props.background,
|
4790
|
-
}
|
4791
|
-
}
|
4792
|
-
});
|
4783
|
+
event.highlights.push(ElementUtil.getFillSvgRect(bgX, bgY, this.rect.width, this.rect.height, this.element.props.background));
|
4793
4784
|
}
|
4794
4785
|
if (this.element.props.underline) {
|
4795
4786
|
const underHeight = this.element.props.fontSize * 1.2;
|
4796
|
-
event.
|
4797
|
-
|
4798
|
-
data: {
|
4799
|
-
ns: "http://www.w3.org/2000/svg",
|
4800
|
-
attrs: {
|
4801
|
-
d: `M${event.relativePagePos.x} ${event.relativePagePos.y + underHeight} L${event.relativePagePos.x + this.rect.width} ${event.relativePagePos.y + underHeight}`,
|
4802
|
-
stroke: '#000',
|
4803
|
-
'stroke-width': 1,
|
4804
|
-
fill: 'none'
|
4805
|
-
}
|
4806
|
-
}
|
4807
|
-
});
|
4787
|
+
const path = `M${event.relativePagePos.x} ${event.relativePagePos.y + underHeight} L${event.relativePagePos.x + this.rect.width} ${event.relativePagePos.y + underHeight}`;
|
4788
|
+
event.highlights.push(ElementUtil.getStrokeSvgPath(path, '#000', 1));
|
4808
4789
|
}
|
4809
4790
|
if (this.element.props.linethrough) {
|
4810
|
-
event.
|
4811
|
-
|
4812
|
-
|
4813
|
-
|
4814
|
-
|
4815
|
-
|
4816
|
-
|
4817
|
-
|
4818
|
-
|
4819
|
-
}
|
4820
|
-
}
|
4821
|
-
});
|
4791
|
+
const path = `M${event.relativePagePos.x} ${event.relativePagePos.y + this.rect.height / 2} L${event.relativePagePos.x + this.rect.width} ${event.relativePagePos.y + this.rect.height / 2}`;
|
4792
|
+
event.highlights.push(ElementUtil.getStrokeSvgPath(path, '#000', 1));
|
4793
|
+
}
|
4794
|
+
if (this.element.props.border) {
|
4795
|
+
event.highlights.push(ElementUtil.getStrokeSvgPath(ElementUtil.getRectPath(event.relativePagePos.x, event.relativePagePos.y, this.rect.width, this.rect.height), '#000', 1));
|
4796
|
+
}
|
4797
|
+
if (this.element.props.overline) {
|
4798
|
+
const path = `M${event.relativePagePos.x} ${event.relativePagePos.y} L${event.relativePagePos.x + this.rect.width} ${event.relativePagePos.y}`;
|
4799
|
+
event.highlights.push(ElementUtil.getStrokeSvgPath(path, '#000', 1));
|
4822
4800
|
}
|
4823
4801
|
return t;
|
4824
4802
|
}
|
@@ -19799,17 +19777,81 @@ function printNodes(printNodes, options, printEvent = null) {
|
|
19799
19777
|
|
19800
19778
|
class DocumentTemplate {
|
19801
19779
|
static createA4Doc() {
|
19780
|
+
return DocumentTemplate.createDoc('A4');
|
19781
|
+
}
|
19782
|
+
static createDoc(name = 'A4') {
|
19802
19783
|
const doc = new DocumentElement();
|
19803
19784
|
doc.props = new DocumentProps();
|
19804
|
-
|
19805
|
-
doc.props.
|
19806
|
-
doc.props.
|
19785
|
+
const paper = DocumentTemplate.getPaper(name);
|
19786
|
+
doc.props.width = paper.width;
|
19787
|
+
doc.props.height = paper.height;
|
19788
|
+
doc.props.padding = new PaddingProps(paper.top, paper.bottom, paper.left, paper.right);
|
19807
19789
|
doc.addChild(new DocumentHeaderElement());
|
19808
19790
|
doc.addChild(new DocumentBodyElement());
|
19809
19791
|
doc.addChild(new DocumentFooterElement());
|
19810
19792
|
return doc;
|
19811
19793
|
}
|
19812
|
-
|
19794
|
+
static getPaper(name) {
|
19795
|
+
let top = 25.4, bottom = 25.4, left = 19.1, right = 19.1;
|
19796
|
+
const paper = PageSize.find(item => item.name.toUpperCase() === name.toUpperCase());
|
19797
|
+
if (paper) {
|
19798
|
+
if (top + bottom + 30 > paper.height) {
|
19799
|
+
top = bottom = 0;
|
19800
|
+
}
|
19801
|
+
if (left + right + 30 > paper.width) {
|
19802
|
+
left = right = 0;
|
19803
|
+
}
|
19804
|
+
return {
|
19805
|
+
width: paper.width,
|
19806
|
+
height: paper.height,
|
19807
|
+
top, left, right, bottom
|
19808
|
+
};
|
19809
|
+
}
|
19810
|
+
return { width: PageSize[0].width, height: PageSize[0].height, top, left, right, bottom };
|
19811
|
+
}
|
19812
|
+
}
|
19813
|
+
const PageSize = [
|
19814
|
+
{ name: 'A4', width: 210, height: 297 },
|
19815
|
+
{ name: 'A5', width: 148, height: 210 },
|
19816
|
+
{ name: 'A6', width: 105, height: 148 },
|
19817
|
+
{ name: 'B5', width: 176, height: 250 },
|
19818
|
+
{ name: 'B6', width: 125, height: 176 },
|
19819
|
+
{ name: 'Letter', width: 216, height: 279 },
|
19820
|
+
{ name: 'Legal', width: 216, height: 356 },
|
19821
|
+
{ name: 'Executive', width: 184, height: 267 },
|
19822
|
+
{ name: 'Folio', width: 210, height: 330 },
|
19823
|
+
{ name: 'Quarto', width: 215, height: 275 },
|
19824
|
+
{ name: '10x15cm', width: 100, height: 150 },
|
19825
|
+
{ name: '13x18cm', width: 130, height: 180 },
|
19826
|
+
{ name: '15x20cm', width: 150, height: 200 },
|
19827
|
+
{ name: '20x25cm', width: 200, height: 250 },
|
19828
|
+
{ name: '20x30cm', width: 200, height: 300 },
|
19829
|
+
{ name: '25x35cm', width: 250, height: 350 },
|
19830
|
+
{ name: '30x40cm', width: 300, height: 400 },
|
19831
|
+
{ name: 'A0', width: 841, height: 1189 },
|
19832
|
+
{ name: 'A1', width: 594, height: 841 },
|
19833
|
+
{ name: 'A2', width: 420, height: 594 },
|
19834
|
+
{ name: 'A3', width: 297, height: 420 },
|
19835
|
+
{ name: 'A7', width: 74, height: 105 },
|
19836
|
+
{ name: 'A8', width: 52, height: 74 },
|
19837
|
+
{ name: 'A9', width: 37, height: 52 },
|
19838
|
+
{ name: 'A10', width: 26, height: 37 },
|
19839
|
+
{ name: 'B0', width: 1000, height: 1414 },
|
19840
|
+
{ name: 'B1', width: 707, height: 1000 },
|
19841
|
+
{ name: 'B2', width: 500, height: 707 },
|
19842
|
+
{ name: 'B3', width: 353, height: 500 },
|
19843
|
+
{ name: 'B4', width: 250, height: 353 },
|
19844
|
+
{ name: 'B7', width: 88, height: 125 },
|
19845
|
+
{ name: 'B8', width: 62, height: 88 },
|
19846
|
+
{ name: 'B9', width: 44, height: 62 },
|
19847
|
+
{ name: 'B10', width: 31, height: 44 },
|
19848
|
+
{ name: 'C5E', width: 163, height: 229 },
|
19849
|
+
{ name: 'Comm10E', width: 105, height: 241 },
|
19850
|
+
{ name: 'DLE', width: 110, height: 220 },
|
19851
|
+
{ name: 'Folio', width: 210, height: 330 },
|
19852
|
+
{ name: 'Ledger', width: 432, height: 279 },
|
19853
|
+
{ name: 'Tabloid', width: 279, height: 432 }
|
19854
|
+
];
|
19813
19855
|
|
19814
19856
|
/**
|
19815
19857
|
* 处理文档批注
|
@@ -26973,7 +27015,7 @@ class DocEditor {
|
|
26973
27015
|
return null;
|
26974
27016
|
}
|
26975
27017
|
const dataEle = ElementUtil.getParent(startControl, validateDataEle);
|
26976
|
-
if (IsInSideDataElement(startControl, startOffset)) {
|
27018
|
+
if (dataEle instanceof DataElementLeaf || IsInSideDataElement(startControl, startOffset)) {
|
26977
27019
|
return dataEle;
|
26978
27020
|
}
|
26979
27021
|
else {
|
@@ -26981,8 +27023,7 @@ class DocEditor {
|
|
26981
27023
|
}
|
26982
27024
|
}
|
26983
27025
|
else if (!collapsed && ancestorCommonControl) {
|
26984
|
-
|
26985
|
-
return dataEle;
|
27026
|
+
return ElementUtil.getParent(startControl, validateDataEle);
|
26986
27027
|
}
|
26987
27028
|
return null;
|
26988
27029
|
}
|
@@ -27123,10 +27164,11 @@ class DocEditor {
|
|
27123
27164
|
/**
|
27124
27165
|
* 新建文档
|
27125
27166
|
* @param doc
|
27167
|
+
* @param name
|
27126
27168
|
*/
|
27127
|
-
createNewDoc(doc = null) {
|
27169
|
+
createNewDoc(doc = null, name = 'A4') {
|
27128
27170
|
//this.docCtx.clear();
|
27129
|
-
const newDoc = doc ?? DocumentTemplate.
|
27171
|
+
const newDoc = doc ?? DocumentTemplate.createDoc(name);
|
27130
27172
|
// this.elementReader.setDocument(newDoc);
|
27131
27173
|
// this.refreshDocument('content');
|
27132
27174
|
this.loadDoc(ElementSerialize.serialize(newDoc, this.viewOptions));
|
@@ -27350,12 +27392,13 @@ class DocEditor {
|
|
27350
27392
|
this.resetViewer('force');
|
27351
27393
|
this.selectionState.clear();
|
27352
27394
|
}
|
27353
|
-
/**
|
27354
|
-
* 设置纸张大小,单位为毫米(mm)
|
27355
|
-
* @param width
|
27356
|
-
* @param height
|
27357
|
-
*/
|
27358
27395
|
setPaperSize(width, height) {
|
27396
|
+
if (typeof width === 'string') {
|
27397
|
+
const paperSize = DocumentTemplate.getPaper(width);
|
27398
|
+
width = paperSize.width;
|
27399
|
+
height = paperSize.height;
|
27400
|
+
}
|
27401
|
+
height = height;
|
27359
27402
|
const docProps = this.docCtx.document.props;
|
27360
27403
|
docProps.width = width;
|
27361
27404
|
docProps.height = height;
|