@hailin-zheng/editor-core 2.2.41 → 2.2.42
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/editor.css +41 -0
- package/index-cjs.js +241 -119
- package/index-cjs.js.map +1 -1
- package/index.js +241 -119
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +3 -2
- package/med_editor/framework/util/common-util.d.ts +1 -0
- package/med_editor/framework/vnode/editor-list-vnode.d.ts +18 -0
- package/package.json +1 -1
package/editor.css
CHANGED
@@ -261,6 +261,47 @@
|
|
261
261
|
font-size: 12px;
|
262
262
|
}
|
263
263
|
|
264
|
+
.data-list-footer {
|
265
|
+
border-top: 1px solid;
|
266
|
+
display: flex;
|
267
|
+
align-items: center;
|
268
|
+
height: 30px;
|
269
|
+
font-size: 12px;
|
270
|
+
}
|
271
|
+
|
272
|
+
.data-list-arrow{
|
273
|
+
position: absolute;
|
274
|
+
background: #0050b3;
|
275
|
+
width: 20px;
|
276
|
+
height: 20px;
|
277
|
+
cursor: default;
|
278
|
+
display: flex;
|
279
|
+
justify-content: center;
|
280
|
+
}
|
281
|
+
|
282
|
+
.data-list-arrow::after{
|
283
|
+
content: '▾';
|
284
|
+
font-size: 20px;
|
285
|
+
color: #fff;
|
286
|
+
}
|
287
|
+
|
288
|
+
.data-list-footer-btn {
|
289
|
+
padding: 4px 6px;
|
290
|
+
margin: 2px 6px;
|
291
|
+
font-size: 14px;
|
292
|
+
cursor: default;
|
293
|
+
user-select: none;
|
294
|
+
border: 1px solid black;
|
295
|
+
}
|
296
|
+
|
297
|
+
.data-list-footer-btn:hover {
|
298
|
+
outline: 1px solid rgb(118, 142, 222);
|
299
|
+
}
|
300
|
+
|
301
|
+
.data-list-footer-btn:active {
|
302
|
+
outline: 1px solid rgb(95, 19, 216);
|
303
|
+
}
|
304
|
+
|
264
305
|
.editor-calendar-footer-right-btn {
|
265
306
|
padding: 2px 3px;
|
266
307
|
cursor: default;
|
package/index-cjs.js
CHANGED
@@ -907,6 +907,25 @@ class CommonUtil {
|
|
907
907
|
const keyCombination = modifiers.length > 0 ? `${modifiers}+${key}` : key;
|
908
908
|
return keyCombination;
|
909
909
|
}
|
910
|
+
static resizePosition(elm, position, scale) {
|
911
|
+
const parent = CommonUtil.findParent(elm, (item) => item.className === 'scroll-container');
|
912
|
+
if (parent) {
|
913
|
+
const parentRect = parent.getBoundingClientRect();
|
914
|
+
const elmRect = elm.getBoundingClientRect();
|
915
|
+
parseInt(elm.style.top);
|
916
|
+
// elmRect.width /= scale;
|
917
|
+
// elmRect.height /= scale;
|
918
|
+
// parentRect.width /= scale;
|
919
|
+
// parentRect.height /= scale;
|
920
|
+
if (elmRect.top < parentRect.top) {
|
921
|
+
elm.style.top = (position.y - elmRect.height / scale) + 'px';
|
922
|
+
}
|
923
|
+
if (elmRect.left < parentRect.left) {
|
924
|
+
elm.style.left = (position.x - 10) + 'px';
|
925
|
+
}
|
926
|
+
return;
|
927
|
+
}
|
928
|
+
}
|
910
929
|
}
|
911
930
|
|
912
931
|
const docOpsMap = new Map();
|
@@ -21932,6 +21951,220 @@ class SearchPanel {
|
|
21932
21951
|
}
|
21933
21952
|
}
|
21934
21953
|
|
21954
|
+
class EditorListVNode {
|
21955
|
+
editor;
|
21956
|
+
currentEle;
|
21957
|
+
currentOpenStatus;
|
21958
|
+
currentOptions = [];
|
21959
|
+
changed;
|
21960
|
+
constructor(editor) {
|
21961
|
+
this.editor = editor;
|
21962
|
+
this.currentOpenStatus = createSignal('init');
|
21963
|
+
this.changed = createSignal(null);
|
21964
|
+
}
|
21965
|
+
clear() {
|
21966
|
+
this.currentEle = null;
|
21967
|
+
this.currentOptions.length = 0;
|
21968
|
+
this.currentOpenStatus.value = 'init';
|
21969
|
+
}
|
21970
|
+
init() {
|
21971
|
+
const editor = this.editor;
|
21972
|
+
const dataEle = editor.getCurrentDataElement();
|
21973
|
+
//不是下拉数据元
|
21974
|
+
if (!dataEle || !(dataEle instanceof DataElementList) || !dataEle.props.editable) {
|
21975
|
+
this.clear();
|
21976
|
+
return;
|
21977
|
+
}
|
21978
|
+
if (this.currentEle && this.currentEle !== dataEle) {
|
21979
|
+
this.clear();
|
21980
|
+
}
|
21981
|
+
if (this.currentEle === dataEle) {
|
21982
|
+
return;
|
21983
|
+
}
|
21984
|
+
this.currentEle = dataEle;
|
21985
|
+
const options = dataEle.props.options.map((item) => ({ checked: false, ...item }));
|
21986
|
+
const values = dataEle.getValue().split(";");
|
21987
|
+
options.filter((item) => values.includes(item.code + '')).forEach((item) => (item.checked = true));
|
21988
|
+
this.currentOptions.push(...options);
|
21989
|
+
this.currentOpenStatus.value = 'open';
|
21990
|
+
}
|
21991
|
+
render() {
|
21992
|
+
// const editor = this.editor;
|
21993
|
+
// if (editor.viewOptions.docMode === DocMode.View || !editor.selectionState.editable || editor['documentEvent'].ismousedown) {
|
21994
|
+
// return null;
|
21995
|
+
// }
|
21996
|
+
// this.init();
|
21997
|
+
// const dataEle = editor.getCurrentDataElement();
|
21998
|
+
// if (dataEle && dataEle instanceof DataElementList && dataEle.props.editable) {
|
21999
|
+
// const position = editor.getDataElementPosition(dataEle.startDecorate) as Rect;
|
22000
|
+
// const options = dataEle.props.options.map((item) => ({ checked: false, ...item }));
|
22001
|
+
// const values = dataEle.getValue().split(";");
|
22002
|
+
// options.filter((item) => values.includes(item.code + '')).forEach((item) => (item.checked = true));
|
22003
|
+
// const multiSelect = dataEle.props.multiSelect;
|
22004
|
+
// } else {
|
22005
|
+
// return null;
|
22006
|
+
// }
|
22007
|
+
this.init();
|
22008
|
+
if (!this.currentEle) {
|
22009
|
+
return null;
|
22010
|
+
}
|
22011
|
+
const editor = this.editor;
|
22012
|
+
const multiSelect = this.currentEle.props.multiSelect;
|
22013
|
+
const position = editor.getDataElementPosition(this.currentEle.startDecorate);
|
22014
|
+
const onChangeHandler = (code) => {
|
22015
|
+
if (!multiSelect) {
|
22016
|
+
this.currentOptions.forEach((item) => {
|
22017
|
+
if (item.code === code && code !== null) {
|
22018
|
+
if (this.currentEle.props.required) {
|
22019
|
+
item.checked = true;
|
22020
|
+
}
|
22021
|
+
else {
|
22022
|
+
item.checked = !item.checked;
|
22023
|
+
}
|
22024
|
+
}
|
22025
|
+
else {
|
22026
|
+
item.checked = false;
|
22027
|
+
}
|
22028
|
+
});
|
22029
|
+
onSave();
|
22030
|
+
}
|
22031
|
+
else {
|
22032
|
+
this.currentOptions.forEach((item) => {
|
22033
|
+
if (item.code === code && code !== null) {
|
22034
|
+
item.checked = !item.checked;
|
22035
|
+
}
|
22036
|
+
});
|
22037
|
+
}
|
22038
|
+
this.changed.onChange();
|
22039
|
+
// const values = options.filter(item => item.checked).map(item => item.code);
|
22040
|
+
// dataEle.setValue(values);
|
22041
|
+
// editor.setDataElemEndFocus(dataEle);
|
22042
|
+
// if (!multiSelect) {
|
22043
|
+
// editor.selectionState.resetRange(dataEle.endDecorate, 1);
|
22044
|
+
// }
|
22045
|
+
};
|
22046
|
+
const onSave = () => {
|
22047
|
+
const values = this.currentOptions.filter(item => item.checked).map(item => item.code);
|
22048
|
+
this.currentEle.setValue(values);
|
22049
|
+
editor.setDataElemEndFocus(this.currentEle);
|
22050
|
+
if (!multiSelect) {
|
22051
|
+
editor.selectionState.resetRange(this.currentEle.endDecorate, 1);
|
22052
|
+
}
|
22053
|
+
};
|
22054
|
+
const itemsVNode = this.currentOptions.map(item => {
|
22055
|
+
const ckbVNode = {
|
22056
|
+
sel: multiSelect ? 'div.editor-list-checkbox' : 'div.editor-list-radiobox',
|
22057
|
+
data: {}
|
22058
|
+
};
|
22059
|
+
if (item.checked) {
|
22060
|
+
ckbVNode.sel += '.checked';
|
22061
|
+
//ckbVNode.data.attrs['checked'] = true;
|
22062
|
+
}
|
22063
|
+
return {
|
22064
|
+
sel: 'div', data: {
|
22065
|
+
on: {
|
22066
|
+
click: () => {
|
22067
|
+
onChangeHandler(item.code);
|
22068
|
+
}
|
22069
|
+
}
|
22070
|
+
}, children: [ckbVNode, {
|
22071
|
+
sel: 'label',
|
22072
|
+
data: {},
|
22073
|
+
text: item.value
|
22074
|
+
}]
|
22075
|
+
};
|
22076
|
+
});
|
22077
|
+
const downArrowVNode = {
|
22078
|
+
sel: 'div.data-list-arrow',
|
22079
|
+
data: {
|
22080
|
+
style: {
|
22081
|
+
left: '-28px',
|
22082
|
+
top: (-position.height - 5) + 'px'
|
22083
|
+
},
|
22084
|
+
on: {
|
22085
|
+
click: () => {
|
22086
|
+
if (this.currentOpenStatus.value === 'open') {
|
22087
|
+
this.currentOpenStatus.value = 'close';
|
22088
|
+
}
|
22089
|
+
else if (this.currentOpenStatus.value === 'close') {
|
22090
|
+
this.currentOpenStatus.value = 'open';
|
22091
|
+
}
|
22092
|
+
}
|
22093
|
+
}
|
22094
|
+
},
|
22095
|
+
children: []
|
22096
|
+
};
|
22097
|
+
const footerVNode = {
|
22098
|
+
sel: 'div.data-list-footer',
|
22099
|
+
data: {},
|
22100
|
+
children: [{
|
22101
|
+
sel: 'div.data-list-footer-btn',
|
22102
|
+
data: {
|
22103
|
+
on: {
|
22104
|
+
click: () => {
|
22105
|
+
this.currentOpenStatus.value = 'close';
|
22106
|
+
onSave();
|
22107
|
+
}
|
22108
|
+
}
|
22109
|
+
},
|
22110
|
+
text: '确定'
|
22111
|
+
},
|
22112
|
+
{
|
22113
|
+
sel: 'div.data-list-footer-btn',
|
22114
|
+
data: {
|
22115
|
+
on: {
|
22116
|
+
click: () => {
|
22117
|
+
this.currentOpenStatus.value = 'close';
|
22118
|
+
}
|
22119
|
+
}
|
22120
|
+
},
|
22121
|
+
text: '取消'
|
22122
|
+
}, {
|
22123
|
+
sel: 'div.data-list-footer-btn',
|
22124
|
+
data: {
|
22125
|
+
on: {
|
22126
|
+
click: () => {
|
22127
|
+
this.currentEle.setValue(null);
|
22128
|
+
editor.selectionState.resetRange(this.currentEle.endDecorate, 1);
|
22129
|
+
}
|
22130
|
+
}
|
22131
|
+
},
|
22132
|
+
text: '清除'
|
22133
|
+
}
|
22134
|
+
]
|
22135
|
+
};
|
22136
|
+
return {
|
22137
|
+
sel: 'div.data-list-container',
|
22138
|
+
data: {
|
22139
|
+
style: {
|
22140
|
+
position: 'absolute',
|
22141
|
+
left: (position.x) + 'px',
|
22142
|
+
top: position.y + 5 + position.height + 'px',
|
22143
|
+
},
|
22144
|
+
hook: {
|
22145
|
+
insert: (vnode) => {
|
22146
|
+
const elm = vnode.elm;
|
22147
|
+
CommonUtil.resizePosition(elm, position, editor.viewOptions.scale);
|
22148
|
+
},
|
22149
|
+
update: (oldVnode, vnode) => {
|
22150
|
+
const elm = vnode.elm;
|
22151
|
+
CommonUtil.resizePosition(elm, position, editor.viewOptions.scale);
|
22152
|
+
}
|
22153
|
+
},
|
22154
|
+
},
|
22155
|
+
children: [
|
22156
|
+
multiSelect ? downArrowVNode : undefined,
|
22157
|
+
this.currentOpenStatus.value === 'open' ? {
|
22158
|
+
sel: 'div#data-list.data-list',
|
22159
|
+
data: {},
|
22160
|
+
children: [...itemsVNode]
|
22161
|
+
} : undefined,
|
22162
|
+
this.currentOpenStatus.value === 'open' && multiSelect ? footerVNode : undefined
|
22163
|
+
]
|
22164
|
+
};
|
22165
|
+
}
|
22166
|
+
}
|
22167
|
+
|
21935
22168
|
class DocEditor {
|
21936
22169
|
svgContainer;
|
21937
22170
|
//设置vue 不允许代理
|
@@ -22059,6 +22292,7 @@ class DocEditor {
|
|
22059
22292
|
const calendarFunc = this.renderCalendar();
|
22060
22293
|
const menuFunc = this.renderContextmenu();
|
22061
22294
|
const suggestionFunc = this.renderSuggestions();
|
22295
|
+
const listVNode = this.renderDataListVNode();
|
22062
22296
|
const ruleFunc = new DocRule(this.docCtx);
|
22063
22297
|
const onSizeChange = () => {
|
22064
22298
|
this.adjustPageLayout();
|
@@ -22090,7 +22324,6 @@ class DocEditor {
|
|
22090
22324
|
on: this.documentInput.getEventListener()
|
22091
22325
|
}
|
22092
22326
|
};
|
22093
|
-
const listVNode = this.renderDataListVNode();
|
22094
22327
|
const dropContainer = {
|
22095
22328
|
sel: 'div.absolute-container',
|
22096
22329
|
data: {
|
@@ -22254,7 +22487,9 @@ class DocEditor {
|
|
22254
22487
|
* 载入文档
|
22255
22488
|
* @param data json对象、json字符串、DocumentElement对象
|
22256
22489
|
*/
|
22257
|
-
loadDoc(data) {
|
22490
|
+
loadDoc(data, options) {
|
22491
|
+
options = options || {};
|
22492
|
+
options.autoScrollToTop = options.autoScrollToTop ?? true;
|
22258
22493
|
suppressTracking(() => {
|
22259
22494
|
this.noEffectChange(() => {
|
22260
22495
|
this.adjustPageLayout();
|
@@ -22262,7 +22497,7 @@ class DocEditor {
|
|
22262
22497
|
this.refreshDocument();
|
22263
22498
|
this.historyMange.clear();
|
22264
22499
|
this.documentEvent.clear();
|
22265
|
-
this.scrollToPosition({ x: 0, y: 0 });
|
22500
|
+
options.autoScrollToTop && this.scrollToPosition({ x: 0, y: 0 });
|
22266
22501
|
});
|
22267
22502
|
});
|
22268
22503
|
}
|
@@ -23331,126 +23566,13 @@ class DocEditor {
|
|
23331
23566
|
* @private
|
23332
23567
|
*/
|
23333
23568
|
renderDataListVNode() {
|
23334
|
-
const
|
23569
|
+
const dataList = new EditorListVNode(this);
|
23335
23570
|
return {
|
23336
23571
|
render() {
|
23337
|
-
|
23338
|
-
return null;
|
23339
|
-
}
|
23340
|
-
const dataEle = editor.getCurrentDataElement();
|
23341
|
-
if (dataEle && dataEle instanceof DataElementList && dataEle.props.editable) {
|
23342
|
-
const position = editor.getDataElementPosition(dataEle.startDecorate);
|
23343
|
-
const options = dataEle.props.options.map((item) => ({ checked: false, ...item }));
|
23344
|
-
const values = dataEle.getValue().split(";");
|
23345
|
-
options.filter((item) => values.includes(item.code + '')).forEach((item) => (item.checked = true));
|
23346
|
-
const multiSelect = dataEle.props.multiSelect;
|
23347
|
-
const onChangeHandler = (code) => {
|
23348
|
-
if (!multiSelect) {
|
23349
|
-
options.forEach((item) => {
|
23350
|
-
if (item.code === code && code !== null) {
|
23351
|
-
if (dataEle.props.required) {
|
23352
|
-
item.checked = true;
|
23353
|
-
}
|
23354
|
-
else {
|
23355
|
-
item.checked = !item.checked;
|
23356
|
-
}
|
23357
|
-
}
|
23358
|
-
else {
|
23359
|
-
item.checked = false;
|
23360
|
-
}
|
23361
|
-
});
|
23362
|
-
}
|
23363
|
-
else {
|
23364
|
-
options.forEach((item) => {
|
23365
|
-
if (item.code === code && code !== null) {
|
23366
|
-
item.checked = !item.checked;
|
23367
|
-
}
|
23368
|
-
});
|
23369
|
-
}
|
23370
|
-
const values = options.filter(item => item.checked).map(item => item.code);
|
23371
|
-
dataEle.setValue(values);
|
23372
|
-
editor.setDataElemEndFocus(dataEle);
|
23373
|
-
if (!multiSelect) {
|
23374
|
-
editor.selectionState.resetRange(dataEle.endDecorate, 1);
|
23375
|
-
}
|
23376
|
-
};
|
23377
|
-
const itemsVNode = options.map(item => {
|
23378
|
-
const ckbVNode = {
|
23379
|
-
sel: multiSelect ? 'div.editor-list-checkbox' : 'div.editor-list-radiobox',
|
23380
|
-
data: {}
|
23381
|
-
};
|
23382
|
-
if (item.checked) {
|
23383
|
-
ckbVNode.sel += '.checked';
|
23384
|
-
//ckbVNode.data.attrs['checked'] = true;
|
23385
|
-
}
|
23386
|
-
return {
|
23387
|
-
sel: 'div', data: {
|
23388
|
-
on: {
|
23389
|
-
click: () => {
|
23390
|
-
onChangeHandler(item.code);
|
23391
|
-
}
|
23392
|
-
}
|
23393
|
-
}, children: [ckbVNode, {
|
23394
|
-
sel: 'label',
|
23395
|
-
data: {},
|
23396
|
-
text: item.value
|
23397
|
-
}]
|
23398
|
-
};
|
23399
|
-
});
|
23400
|
-
return {
|
23401
|
-
sel: 'div.data-list-container',
|
23402
|
-
data: {
|
23403
|
-
style: {
|
23404
|
-
position: 'absolute',
|
23405
|
-
left: (position.x) + 'px',
|
23406
|
-
top: position.y + 5 + position.height + 'px',
|
23407
|
-
},
|
23408
|
-
hook: {
|
23409
|
-
insert: (vnode) => {
|
23410
|
-
const elm = vnode.elm;
|
23411
|
-
editor.resizePosition(elm, position);
|
23412
|
-
},
|
23413
|
-
update: (oldVnode, vnode) => {
|
23414
|
-
const elm = vnode.elm;
|
23415
|
-
editor.resizePosition(elm, position);
|
23416
|
-
}
|
23417
|
-
},
|
23418
|
-
},
|
23419
|
-
children: [
|
23420
|
-
{
|
23421
|
-
sel: 'div#data-list.data-list',
|
23422
|
-
data: {},
|
23423
|
-
children: [...itemsVNode]
|
23424
|
-
}
|
23425
|
-
]
|
23426
|
-
};
|
23427
|
-
}
|
23428
|
-
else {
|
23429
|
-
return null;
|
23430
|
-
}
|
23572
|
+
return dataList.render();
|
23431
23573
|
}
|
23432
23574
|
};
|
23433
23575
|
}
|
23434
|
-
resizePosition(elm, position) {
|
23435
|
-
const parent = CommonUtil.findParent(elm, (item) => item.className === 'scroll-container');
|
23436
|
-
const scale = this.viewOptions.scale;
|
23437
|
-
if (parent) {
|
23438
|
-
const parentRect = parent.getBoundingClientRect();
|
23439
|
-
const elmRect = elm.getBoundingClientRect();
|
23440
|
-
parseInt(elm.style.top);
|
23441
|
-
// elmRect.width /= scale;
|
23442
|
-
// elmRect.height /= scale;
|
23443
|
-
// parentRect.width /= scale;
|
23444
|
-
// parentRect.height /= scale;
|
23445
|
-
if (elmRect.top < parentRect.top) {
|
23446
|
-
elm.style.top = (position.y - elmRect.height / scale) + 'px';
|
23447
|
-
}
|
23448
|
-
if (elmRect.left < parentRect.left) {
|
23449
|
-
elm.style.left = (position.x - 10) + 'px';
|
23450
|
-
}
|
23451
|
-
return;
|
23452
|
-
}
|
23453
|
-
}
|
23454
23576
|
renderCalendar() {
|
23455
23577
|
const calendar = new EditorCalendarVNode(this.viewOptions);
|
23456
23578
|
const editor = this;
|
@@ -23557,7 +23679,7 @@ class DocEditor {
|
|
23557
23679
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
23558
23680
|
}
|
23559
23681
|
version() {
|
23560
|
-
return "2.2.
|
23682
|
+
return "2.2.42";
|
23561
23683
|
}
|
23562
23684
|
switchPageHeaderEditor() {
|
23563
23685
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|