@hailin-zheng/editor-core 2.0.54 → 2.1.1
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 +184 -93
- package/index-cjs.js.map +1 -1
- package/index.js +184 -92
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +1 -0
- package/med_editor/framework/document-change.d.ts +8 -0
- package/med_editor/framework/editor-calendar-vnode.d.ts +4 -2
- package/med_editor/framework/element-define.d.ts +1 -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 +28 -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-cjs.js
CHANGED
@@ -7,7 +7,6 @@ var moment = require('moment');
|
|
7
7
|
var acor = require('acorn');
|
8
8
|
var astring = require('astring');
|
9
9
|
var estraverse = require('estraverse');
|
10
|
-
var bwipjs = require('bwip-js');
|
11
10
|
var JsBarcode = require('jsbarcode');
|
12
11
|
var snabbdom = require('snabbdom');
|
13
12
|
|
@@ -34,7 +33,6 @@ function _interopNamespace(e) {
|
|
34
33
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
35
34
|
var acor__namespace = /*#__PURE__*/_interopNamespace(acor);
|
36
35
|
var estraverse__default = /*#__PURE__*/_interopDefaultLegacy(estraverse);
|
37
|
-
var bwipjs__namespace = /*#__PURE__*/_interopNamespace(bwipjs);
|
38
36
|
var JsBarcode__default = /*#__PURE__*/_interopDefaultLegacy(JsBarcode);
|
39
37
|
|
40
38
|
/**
|
@@ -1580,6 +1578,8 @@ class ViewOptions {
|
|
1580
1578
|
ruleHeight = 30;
|
1581
1579
|
//是否打印页眉页脚线
|
1582
1580
|
printHeaderFooterLine = false;
|
1581
|
+
//显示段落回车符号
|
1582
|
+
showEnterSymbol = false;
|
1583
1583
|
get fullPageView() {
|
1584
1584
|
return this._fullPageView;
|
1585
1585
|
}
|
@@ -4334,6 +4334,27 @@ class PSymbolRenderObject extends LeafRenderObject {
|
|
4334
4334
|
}
|
4335
4335
|
render.contentContext.drawText('↩', this.element.textProps, position.x, position.y, 20, this.rect.height);
|
4336
4336
|
}
|
4337
|
+
exportHTML(event) {
|
4338
|
+
if (!event.options.showEnterSymbol || event.mode === 'print') {
|
4339
|
+
return null;
|
4340
|
+
}
|
4341
|
+
return {
|
4342
|
+
sel: 'text',
|
4343
|
+
text: '↵',
|
4344
|
+
data: {
|
4345
|
+
ns: "http://www.w3.org/2000/svg",
|
4346
|
+
attrs: {
|
4347
|
+
//"transform": `translate(0,${(height - props.fontSize) / 2})`,
|
4348
|
+
'dominant-baseline': 'hanging',
|
4349
|
+
'font-family': 'Courier',
|
4350
|
+
'font-size': this.element.defaultHeight,
|
4351
|
+
x: this.rect.x,
|
4352
|
+
y: this.rect.y,
|
4353
|
+
fill: 'green'
|
4354
|
+
}
|
4355
|
+
},
|
4356
|
+
};
|
4357
|
+
}
|
4337
4358
|
//绘制段落符号
|
4338
4359
|
clone() {
|
4339
4360
|
const render = new PSymbolRenderObject(this.element);
|
@@ -8223,30 +8244,13 @@ class DataElementBarcode extends DataElementLeaf {
|
|
8223
8244
|
return this.props.text;
|
8224
8245
|
}
|
8225
8246
|
drawBarcode(renderCtx, pos) {
|
8226
|
-
this.createBarcodeCache();
|
8227
8247
|
renderCtx.contentContext.ctx.drawImage(this.barCodeCanvas, pos.x, pos.y, this.props.width, this.props.height);
|
8228
8248
|
}
|
8229
|
-
createBarcodeCache() {
|
8230
|
-
if (this.cache) {
|
8231
|
-
return;
|
8232
|
-
}
|
8233
|
-
this.cache = true;
|
8234
|
-
if (!this.barCodeCanvas) {
|
8235
|
-
this.barCodeCanvas = document.createElement('canvas');
|
8236
|
-
}
|
8237
|
-
this.barCodeCanvas = bwipjs__namespace.toCanvas(this.barCodeCanvas, {
|
8238
|
-
bcid: this.props.type,
|
8239
|
-
text: this.props.text || "0123456789",
|
8240
|
-
height: 10,
|
8241
|
-
includetext: true,
|
8242
|
-
textxalign: "center", // Always good to set this
|
8243
|
-
});
|
8244
|
-
}
|
8245
8249
|
}
|
8246
8250
|
class DataElementBarcodeRenderObject extends ResizeLeafRenderObject {
|
8247
8251
|
render(e) {
|
8248
|
-
const barcodeEle = this.element;
|
8249
|
-
barcodeEle.drawBarcode(e.render, e.position);
|
8252
|
+
// const barcodeEle = this.element as DataElementBarcode;
|
8253
|
+
// barcodeEle.drawBarcode(e.render, e.position);
|
8250
8254
|
}
|
8251
8255
|
clone() {
|
8252
8256
|
const clone = new DataElementBarcodeRenderObject(this.element);
|
@@ -9120,6 +9124,27 @@ class BreakRenderObject extends LeafRenderObject {
|
|
9120
9124
|
}
|
9121
9125
|
render.contentContext.drawText('↓', this.element.textProps, position.x, position.y, 20, this.rect.height);
|
9122
9126
|
}
|
9127
|
+
exportHTML(event) {
|
9128
|
+
if (!event.options.showEnterSymbol || event.mode === 'print') {
|
9129
|
+
return null;
|
9130
|
+
}
|
9131
|
+
return {
|
9132
|
+
sel: 'text',
|
9133
|
+
text: '↓',
|
9134
|
+
data: {
|
9135
|
+
ns: "http://www.w3.org/2000/svg",
|
9136
|
+
attrs: {
|
9137
|
+
//"transform": `translate(0,${(height - props.fontSize) / 2})`,
|
9138
|
+
'dominant-baseline': 'hanging',
|
9139
|
+
'font-family': 'Courier',
|
9140
|
+
'font-size': this.rect.height,
|
9141
|
+
x: this.rect.x + 4,
|
9142
|
+
y: this.rect.y,
|
9143
|
+
fill: 'green'
|
9144
|
+
}
|
9145
|
+
},
|
9146
|
+
};
|
9147
|
+
}
|
9123
9148
|
clone() {
|
9124
9149
|
const render = new BreakRenderObject(this.element);
|
9125
9150
|
render.rect = ElementUtil.cloneRect(this.rect);
|
@@ -9160,6 +9185,9 @@ class DataElementText extends DataElementInlineGroup {
|
|
9160
9185
|
if (!this.startDecorate) {
|
9161
9186
|
return;
|
9162
9187
|
}
|
9188
|
+
if (val === null || val === undefined) {
|
9189
|
+
val = '';
|
9190
|
+
}
|
9163
9191
|
if (this.getValue() === val) {
|
9164
9192
|
return;
|
9165
9193
|
}
|
@@ -12440,6 +12468,7 @@ class ElementUtil {
|
|
12440
12468
|
};
|
12441
12469
|
}
|
12442
12470
|
static getMousePos(e, scale = 1) {
|
12471
|
+
//scale=1;
|
12443
12472
|
const svgContainer = e.currentTarget;
|
12444
12473
|
const parentRect = svgContainer.getBoundingClientRect();
|
12445
12474
|
const localX = e.clientX - parentRect.x; //+ this.viewOptions.pageOffset.x;
|
@@ -16160,7 +16189,9 @@ class DocumentPaint {
|
|
16160
16189
|
//文档容器总宽度等于内容宽度
|
16161
16190
|
//单页模式,docContainer居中
|
16162
16191
|
this.docContainer.rect.width = viewWidth;
|
16163
|
-
let docLeft = Math.floor((viewWidth - contentWidth) / 2);
|
16192
|
+
//let docLeft = Math.floor((viewWidth - contentWidth) / 2);
|
16193
|
+
//处理由于缩放问题,transform-origin:left-top,因此需要提前计算需要偏移的位置
|
16194
|
+
let docLeft = Math.floor((viewWidth - contentWidth * (this.viewOptions.scale)) / 2);
|
16164
16195
|
docLeft = docLeft < 0 ? 0 : docLeft;
|
16165
16196
|
pages.forEach(item => item.rect.x = docLeft);
|
16166
16197
|
this.docContainer.rect.x = 0;
|
@@ -19167,7 +19198,8 @@ class DocumentChange {
|
|
19167
19198
|
if (!prevEle) {
|
19168
19199
|
const nextEle = ElementUtil.getRecursionNextSiblingElement(control, true, true, this.viewOptions);
|
19169
19200
|
if (nextEle) {
|
19170
|
-
this.selectionState.resetRange(nextEle, 0);
|
19201
|
+
//this.selectionState.resetRange(nextEle, 0);
|
19202
|
+
this.setSelectionStateByDeleteEvent(nextEle, 0, control);
|
19171
19203
|
control.remove();
|
19172
19204
|
return;
|
19173
19205
|
}
|
@@ -19175,24 +19207,48 @@ class DocumentChange {
|
|
19175
19207
|
return;
|
19176
19208
|
}
|
19177
19209
|
if (ElementUtil.isInSameParagraph(control, prevEle)) {
|
19178
|
-
this.selectionState.resetRange(prevEle, -1);
|
19210
|
+
//this.selectionState.resetRange(prevEle, -1);
|
19211
|
+
this.setSelectionStateByDeleteEvent(prevEle, -1, control);
|
19179
19212
|
control.remove();
|
19180
19213
|
return;
|
19181
19214
|
}
|
19182
19215
|
else {
|
19183
19216
|
const nextEle = ElementUtil.getRecursionNextSiblingElement(control, true, true, this.viewOptions);
|
19184
19217
|
if (nextEle && ElementUtil.getPrevSiblingElement(nextEle) === control) {
|
19185
|
-
this.selectionState.resetRange(nextEle, 0);
|
19218
|
+
//this.selectionState.resetRange(nextEle, 0);
|
19219
|
+
this.setSelectionStateByDeleteEvent(nextEle, 0, control);
|
19186
19220
|
control.remove();
|
19187
19221
|
return;
|
19188
19222
|
}
|
19189
19223
|
else {
|
19190
|
-
this.selectionState.resetRange(prevEle, -1);
|
19224
|
+
//this.selectionState.resetRange(prevEle, -1);
|
19225
|
+
this.setSelectionStateByDeleteEvent(prevEle, -1, control);
|
19191
19226
|
control.remove();
|
19192
19227
|
return;
|
19193
19228
|
}
|
19194
19229
|
}
|
19195
19230
|
}
|
19231
|
+
/**
|
19232
|
+
* 处理在表单模式下光标定位的问题
|
19233
|
+
* @param target
|
19234
|
+
* @param targetOffset
|
19235
|
+
* @param deleteTarget
|
19236
|
+
* @private
|
19237
|
+
*/
|
19238
|
+
setSelectionStateByDeleteEvent(target, targetOffset, deleteTarget) {
|
19239
|
+
if (this.viewOptions.docMode === exports.DocMode.FormEdit) {
|
19240
|
+
const dataEle = ElementUtil.getParent(deleteTarget, (item) => item instanceof DataElementInlineGroup);
|
19241
|
+
if (dataEle && ElementUtil.getParent(target, (item) => item instanceof DataElementInlineGroup) === dataEle) {
|
19242
|
+
this.selectionState.resetRange(target, targetOffset);
|
19243
|
+
return;
|
19244
|
+
}
|
19245
|
+
if (dataEle) {
|
19246
|
+
this.selectionState.resetRange(dataEle.startDecorate, 1);
|
19247
|
+
return;
|
19248
|
+
}
|
19249
|
+
}
|
19250
|
+
this.selectionState.resetRange(target, targetOffset);
|
19251
|
+
}
|
19196
19252
|
/**
|
19197
19253
|
* 回车事件
|
19198
19254
|
*/
|
@@ -26172,6 +26228,7 @@ function createSignal(state) {
|
|
26172
26228
|
* 渲染日历虚拟节点处理类
|
26173
26229
|
*/
|
26174
26230
|
class EditorCalendarVNode {
|
26231
|
+
viewOptions;
|
26175
26232
|
currYear;
|
26176
26233
|
currMonth;
|
26177
26234
|
currCalendarMode;
|
@@ -26180,7 +26237,8 @@ class EditorCalendarVNode {
|
|
26180
26237
|
onSetValue = new Subject$1();
|
26181
26238
|
currTime;
|
26182
26239
|
selectedTime;
|
26183
|
-
constructor() {
|
26240
|
+
constructor(viewOptions) {
|
26241
|
+
this.viewOptions = viewOptions;
|
26184
26242
|
this.currYear = createSignal(new Date().getFullYear());
|
26185
26243
|
//月份赋值是按照索引来的,所以要减1
|
26186
26244
|
this.currMonth = createSignal(new Date().getMonth());
|
@@ -26248,29 +26306,49 @@ class EditorCalendarVNode {
|
|
26248
26306
|
hook: {
|
26249
26307
|
insert: (vnode) => {
|
26250
26308
|
const elm = vnode.elm;
|
26251
|
-
|
26252
|
-
|
26253
|
-
|
26254
|
-
|
26255
|
-
|
26256
|
-
elm.style.top = (position.y - elmRect.height) + 'px';
|
26257
|
-
}
|
26258
|
-
if (elmRect.left < parentRect.left) {
|
26259
|
-
elm.style.left = (position.x - 10) + 'px';
|
26260
|
-
}
|
26261
|
-
if (elmRect.right > parentRect.right) {
|
26262
|
-
elm.style.left = (position.x - elmRect.width + 10) + 'px';
|
26263
|
-
}
|
26264
|
-
if (elmRect.top + elmRect.height > parentRect.top + parentRect.height) {
|
26265
|
-
elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
26266
|
-
}
|
26267
|
-
}
|
26309
|
+
this.resizePosition(elm, position);
|
26310
|
+
},
|
26311
|
+
update: (oldVnode, vnode) => {
|
26312
|
+
const elm = vnode.elm;
|
26313
|
+
this.resizePosition(elm, position);
|
26268
26314
|
}
|
26269
26315
|
},
|
26270
26316
|
},
|
26271
26317
|
children: []
|
26272
26318
|
};
|
26273
26319
|
}
|
26320
|
+
resizePosition(elm, position) {
|
26321
|
+
const parent = CommonUtil.findParent(elm, (item) => item.className === 'scroll-container');
|
26322
|
+
const scale = this.viewOptions.scale;
|
26323
|
+
if (parent) {
|
26324
|
+
const parentRect = parent.getBoundingClientRect();
|
26325
|
+
const elmRect = elm.getBoundingClientRect();
|
26326
|
+
// elmRect.width /= scale;
|
26327
|
+
// elmRect.height /= scale;
|
26328
|
+
// parentRect.width /= scale;
|
26329
|
+
// parentRect.height /= scale;
|
26330
|
+
if (elmRect.top < parentRect.top) {
|
26331
|
+
elm.style.top = (position.y - elmRect.height / scale) + 'px';
|
26332
|
+
}
|
26333
|
+
if (elmRect.left < parentRect.left) {
|
26334
|
+
elm.style.left = (position.x - 10) + 'px';
|
26335
|
+
}
|
26336
|
+
if (elmRect.right > parentRect.right) {
|
26337
|
+
elm.style.left = (position.x - elmRect.width / scale + 10) + 'px';
|
26338
|
+
//elm.style.left = parentRect.width - elmRect.width + 'px';
|
26339
|
+
}
|
26340
|
+
if (elmRect.top + elmRect.height > parentRect.top + parentRect.height) {
|
26341
|
+
const newTop = position.y - position.height - elmRect.height;
|
26342
|
+
const oldTop = position.y + 5 + position.height;
|
26343
|
+
//计算前后的高度的差距,然后判断新的值是否在父元素的范围内,如果不在则使用旧的值
|
26344
|
+
if (newTop > 0 && oldTop - newTop < elmRect.top - parentRect.top) {
|
26345
|
+
elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
26346
|
+
}
|
26347
|
+
//elm.style.top = (top - (elmRect.top + elmRect.height - (parentRect.top + parentRect.height))) + 'px';
|
26348
|
+
//elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
26349
|
+
}
|
26350
|
+
}
|
26351
|
+
}
|
26274
26352
|
renderDay() {
|
26275
26353
|
//获取当前月份需要渲染的天数集合
|
26276
26354
|
const days = this.getDays();
|
@@ -27115,8 +27193,13 @@ class DocEditor {
|
|
27115
27193
|
const listVNode = this.renderDataListVNode();
|
27116
27194
|
const dropContainer = {
|
27117
27195
|
sel: 'div.drop-container',
|
27118
|
-
data: {
|
27119
|
-
|
27196
|
+
data: {
|
27197
|
+
style: {
|
27198
|
+
'transform-origin': '0 0',
|
27199
|
+
'transform': `scale(${this.viewOptions.scale})`
|
27200
|
+
}
|
27201
|
+
},
|
27202
|
+
children: [inputVNode, listVNode.render(), calendarFunc.render(), menuFunc.render()]
|
27120
27203
|
};
|
27121
27204
|
return {
|
27122
27205
|
sel: 'div.svg-container',
|
@@ -27154,17 +27237,7 @@ class DocEditor {
|
|
27154
27237
|
}
|
27155
27238
|
}
|
27156
27239
|
},
|
27157
|
-
children: [
|
27158
|
-
{
|
27159
|
-
sel: 'div.scale-container', data: {
|
27160
|
-
style: {
|
27161
|
-
transform: 'scale(' + this.viewOptions.scale + ')',
|
27162
|
-
transformOrigin: 'left top'
|
27163
|
-
}
|
27164
|
-
},
|
27165
|
-
children: [docContentVNode, inputVNode, dropContainer]
|
27166
|
-
}
|
27167
|
-
]
|
27240
|
+
children: [docContentVNode, dropContainer]
|
27168
27241
|
}, ruleFunc.refreshRuleSvg().render()
|
27169
27242
|
]
|
27170
27243
|
};
|
@@ -27270,8 +27343,8 @@ class DocEditor {
|
|
27270
27343
|
this.contentChanged.next();
|
27271
27344
|
}
|
27272
27345
|
this.updateSelection();
|
27273
|
-
this.onShouldRender.next();
|
27274
27346
|
this.setCursor();
|
27347
|
+
this.onShouldRender.next();
|
27275
27348
|
//this.refreshView();
|
27276
27349
|
}
|
27277
27350
|
/**
|
@@ -27415,12 +27488,12 @@ class DocEditor {
|
|
27415
27488
|
*/
|
27416
27489
|
docClickHandle(evt) {
|
27417
27490
|
this.hiddenInput();
|
27418
|
-
this.setCursor();
|
27419
|
-
this.updateSelection();
|
27491
|
+
// this.setCursor();
|
27492
|
+
// this.updateSelection();
|
27493
|
+
this.refreshDocument();
|
27420
27494
|
this.onClickEvent.next(evt);
|
27421
27495
|
if (this.menusData) {
|
27422
27496
|
this.menusData = null;
|
27423
|
-
this.onChange();
|
27424
27497
|
}
|
27425
27498
|
}
|
27426
27499
|
/**
|
@@ -27509,7 +27582,9 @@ class DocEditor {
|
|
27509
27582
|
elementEvent.source = startControl;
|
27510
27583
|
DocumentEvent.invokeEvent('ElementContextMenu', startControl, elementEvent, 'All');
|
27511
27584
|
//const position = {x: evt.offsetX + 10, y: evt.offsetY, translateY: this.viewOptions.pageOffset.y};
|
27512
|
-
const pos = ElementUtil.getMousePos(evt);
|
27585
|
+
const pos = ElementUtil.getMousePos(evt, this.viewOptions.scale);
|
27586
|
+
pos.x += 10;
|
27587
|
+
pos.y -= 10;
|
27513
27588
|
this.menusData = {
|
27514
27589
|
position: pos,
|
27515
27590
|
menus: elementEvent.menus
|
@@ -27550,11 +27625,11 @@ class DocEditor {
|
|
27550
27625
|
this.updateRenderCtx();
|
27551
27626
|
this.flushToSchedule();
|
27552
27627
|
this.documentPaint.layoutPages();
|
27553
|
-
const sub = this.afterNodePatch.subscribe(() => {
|
27554
|
-
|
27555
|
-
|
27556
|
-
|
27557
|
-
})
|
27628
|
+
// const sub = this.afterNodePatch.subscribe(() => {
|
27629
|
+
// sub.unsubscribe();
|
27630
|
+
// const scrollDOM = this.svgContainer.querySelector('.scroll-container') as HTMLElement;
|
27631
|
+
// scrollDOM.scrollLeft = (scrollDOM.scrollWidth - scrollDOM.getBoundingClientRect().width) / 2;
|
27632
|
+
// })
|
27558
27633
|
return scale;
|
27559
27634
|
}
|
27560
27635
|
updateRenderCtx() {
|
@@ -28084,7 +28159,10 @@ class DocEditor {
|
|
28084
28159
|
style: {
|
28085
28160
|
height: '0px',
|
28086
28161
|
position: 'relative',
|
28162
|
+
width: '0px',
|
28087
28163
|
'user-select': 'none',
|
28164
|
+
transform: 'scale(' + this.viewOptions.scale + ')',
|
28165
|
+
'transform-origin': '0 0'
|
28088
28166
|
},
|
28089
28167
|
on: this.documentEvent.getEventListener()
|
28090
28168
|
},
|
@@ -28263,30 +28341,11 @@ class DocEditor {
|
|
28263
28341
|
hook: {
|
28264
28342
|
insert: (vnode) => {
|
28265
28343
|
const elm = vnode.elm;
|
28266
|
-
|
28267
|
-
|
28268
|
-
|
28269
|
-
|
28270
|
-
|
28271
|
-
elm.style.top = (position.y - elmRect.height) + 'px';
|
28272
|
-
}
|
28273
|
-
if (elmRect.left < parentRect.left) {
|
28274
|
-
elm.style.left = (position.x - 10) + 'px';
|
28275
|
-
}
|
28276
|
-
if (elmRect.right > parentRect.right) {
|
28277
|
-
elm.style.left = (position.x - elmRect.width + 10) + 'px';
|
28278
|
-
}
|
28279
|
-
if (elmRect.top + elmRect.height > parentRect.top + parentRect.height) {
|
28280
|
-
const newTop = position.y - position.height - elmRect.height;
|
28281
|
-
const oldTop = position.y + 5 + position.height;
|
28282
|
-
//计算前后的高度的差距,然后判断新的值是否在父元素的范围内,如果不在则使用旧的值
|
28283
|
-
if (oldTop - newTop < elmRect.top - parentRect.top) {
|
28284
|
-
elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
28285
|
-
}
|
28286
|
-
//elm.style.top = (top - (elmRect.top + elmRect.height - (parentRect.top + parentRect.height))) + 'px';
|
28287
|
-
//elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
28288
|
-
}
|
28289
|
-
}
|
28344
|
+
editor.resizePosition(elm, position);
|
28345
|
+
},
|
28346
|
+
update: (oldVnode, vnode) => {
|
28347
|
+
const elm = vnode.elm;
|
28348
|
+
editor.resizePosition(elm, position);
|
28290
28349
|
}
|
28291
28350
|
},
|
28292
28351
|
},
|
@@ -28305,8 +28364,40 @@ class DocEditor {
|
|
28305
28364
|
}
|
28306
28365
|
};
|
28307
28366
|
}
|
28367
|
+
resizePosition(elm, position) {
|
28368
|
+
const parent = CommonUtil.findParent(elm, (item) => item.className === 'scroll-container');
|
28369
|
+
const scale = this.viewOptions.scale;
|
28370
|
+
if (parent) {
|
28371
|
+
const parentRect = parent.getBoundingClientRect();
|
28372
|
+
const elmRect = elm.getBoundingClientRect();
|
28373
|
+
// elmRect.width /= scale;
|
28374
|
+
// elmRect.height /= scale;
|
28375
|
+
// parentRect.width /= scale;
|
28376
|
+
// parentRect.height /= scale;
|
28377
|
+
if (elmRect.top < parentRect.top) {
|
28378
|
+
elm.style.top = (position.y - elmRect.height / scale) + 'px';
|
28379
|
+
}
|
28380
|
+
if (elmRect.left < parentRect.left) {
|
28381
|
+
elm.style.left = (position.x - 10) + 'px';
|
28382
|
+
}
|
28383
|
+
if (elmRect.right > parentRect.right) {
|
28384
|
+
elm.style.left = (position.x - elmRect.width / scale + 10) + 'px';
|
28385
|
+
//elm.style.left = parentRect.width - elmRect.width + 'px';
|
28386
|
+
}
|
28387
|
+
if (elmRect.top + elmRect.height > parentRect.top + parentRect.height) {
|
28388
|
+
const newTop = position.y - position.height - elmRect.height;
|
28389
|
+
const oldTop = position.y + 5 + position.height;
|
28390
|
+
//计算前后的高度的差距,然后判断新的值是否在父元素的范围内,如果不在则使用旧的值
|
28391
|
+
if (newTop > 0 && oldTop - newTop < elmRect.top - parentRect.top) {
|
28392
|
+
elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
28393
|
+
}
|
28394
|
+
//elm.style.top = (top - (elmRect.top + elmRect.height - (parentRect.top + parentRect.height))) + 'px';
|
28395
|
+
//elm.style.top = (position.y - position.height - elmRect.height) + 'px';
|
28396
|
+
}
|
28397
|
+
}
|
28398
|
+
}
|
28308
28399
|
renderCalendar() {
|
28309
|
-
const calendar = new EditorCalendarVNode();
|
28400
|
+
const calendar = new EditorCalendarVNode(this.viewOptions);
|
28310
28401
|
const editor = this;
|
28311
28402
|
calendar.onSetValue.subscribe((value) => {
|
28312
28403
|
const dataEle = editor.getCurrentDataElement();
|
@@ -28392,7 +28483,7 @@ class DocEditor {
|
|
28392
28483
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
28393
28484
|
}
|
28394
28485
|
version() {
|
28395
|
-
return "2.
|
28486
|
+
return "2.1.1";
|
28396
28487
|
}
|
28397
28488
|
}
|
28398
28489
|
|