@hailin-zheng/editor-core 2.2.37 → 2.2.38
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 +105 -10
- package/index-cjs.js.map +1 -1
- package/index.js +104 -11
- package/index.js.map +1 -1
- package/med_editor/framework/document-change.d.ts +5 -0
- package/med_editor/framework/element-define.d.ts +1 -0
- package/med_editor/framework/element-serialize.d.ts +5 -2
- package/med_editor/framework/render-define.d.ts +13 -0
- package/med_editor/framework/vnode/editor-calendar-vnode.d.ts +1 -0
- package/package.json +1 -1
package/index-cjs.js
CHANGED
@@ -329,6 +329,33 @@ class RenderObject {
|
|
329
329
|
};
|
330
330
|
}
|
331
331
|
}
|
332
|
+
const NS = "http://www.w3.org/2000/svg";
|
333
|
+
function HLNode(sel, attrs, child) {
|
334
|
+
attrs = attrs || {};
|
335
|
+
if (typeof child === 'string') {
|
336
|
+
return {
|
337
|
+
sel,
|
338
|
+
data: {
|
339
|
+
ns: NS,
|
340
|
+
...attrs
|
341
|
+
},
|
342
|
+
text: child
|
343
|
+
};
|
344
|
+
}
|
345
|
+
else {
|
346
|
+
const node = {
|
347
|
+
sel,
|
348
|
+
data: {
|
349
|
+
ns: NS,
|
350
|
+
...attrs
|
351
|
+
}
|
352
|
+
};
|
353
|
+
if (child && child.length > 0) {
|
354
|
+
node.children = child;
|
355
|
+
}
|
356
|
+
return node;
|
357
|
+
}
|
358
|
+
}
|
332
359
|
/**
|
333
360
|
* 叶子节点渲染元素
|
334
361
|
*/
|
@@ -1919,6 +1946,8 @@ class ViewOptions {
|
|
1919
1946
|
shapeRendering = 'auto';
|
1920
1947
|
//是否开启快速测量
|
1921
1948
|
enableFastMeasure = false;
|
1949
|
+
//数据组双击选择模式
|
1950
|
+
dataGroupDblClickMode = 'default';
|
1922
1951
|
get fullPageView() {
|
1923
1952
|
return this._fullPageView;
|
1924
1953
|
}
|
@@ -11294,7 +11323,11 @@ class ElementSerialize {
|
|
11294
11323
|
* @param element
|
11295
11324
|
* @param viewOptions
|
11296
11325
|
*/
|
11297
|
-
static serialize(element, viewOptions) {
|
11326
|
+
static serialize(element, viewOptions, serializeOptions) {
|
11327
|
+
serializeOptions = serializeOptions || {};
|
11328
|
+
if (serializeOptions.excludeDel && element instanceof TrackRunElement && element.type === exports.TrackRunTypeEnum.Deleted) {
|
11329
|
+
return null;
|
11330
|
+
}
|
11298
11331
|
const result = element.serialize(viewOptions);
|
11299
11332
|
if (!result) {
|
11300
11333
|
return null;
|
@@ -11336,7 +11369,10 @@ class ElementSerialize {
|
|
11336
11369
|
}
|
11337
11370
|
return result;
|
11338
11371
|
}
|
11339
|
-
static serializeString(element, options
|
11372
|
+
static serializeString(element, options) {
|
11373
|
+
options = options || {};
|
11374
|
+
options.includeRunDel = options.includeRunDel || false;
|
11375
|
+
options.dataEleValueMode = options.dataEleValueMode || 'text';
|
11340
11376
|
if (!options.includeRunDel && element instanceof TrackRunElement && element.type === exports.TrackRunTypeEnum.Deleted) {
|
11341
11377
|
return '';
|
11342
11378
|
}
|
@@ -11350,6 +11386,9 @@ class ElementSerialize {
|
|
11350
11386
|
return '\n';
|
11351
11387
|
}
|
11352
11388
|
if (element instanceof BranchElement) {
|
11389
|
+
if (element instanceof DataElementInlineGroup && options.dataEleValueMode === 'value') {
|
11390
|
+
return element.getValue();
|
11391
|
+
}
|
11353
11392
|
const items = [];
|
11354
11393
|
for (let i = 0; i < element.length; i++) {
|
11355
11394
|
const item = element.getChild(i);
|
@@ -11434,7 +11473,8 @@ class ElementSerialize {
|
|
11434
11473
|
const selectedStructs = this.getSelectedStruct(ss, viewOptions);
|
11435
11474
|
if (selectedStructs) {
|
11436
11475
|
//return JSON.stringify(this.serialize(selectedStructs, viewOptions));
|
11437
|
-
|
11476
|
+
const serOptions = { excludeDel: true };
|
11477
|
+
return JSON.stringify(selectedStructs.map(item => this.serialize(item, viewOptions, serOptions)).filter(item => item));
|
11438
11478
|
}
|
11439
11479
|
else {
|
11440
11480
|
return '';
|
@@ -19306,6 +19346,8 @@ class DocumentChange {
|
|
19306
19346
|
console.log('粘贴反序列化数据失败', item);
|
19307
19347
|
}
|
19308
19348
|
});
|
19349
|
+
//清理track-run数据
|
19350
|
+
this.cleanTrackRun(pasteEles);
|
19309
19351
|
if (!pasteEles.length) {
|
19310
19352
|
return;
|
19311
19353
|
}
|
@@ -19339,6 +19381,39 @@ class DocumentChange {
|
|
19339
19381
|
this.selectionState.resetRange(lastEle, -1);
|
19340
19382
|
}
|
19341
19383
|
}
|
19384
|
+
/**
|
19385
|
+
* 整理数据:如果复制的数据包含留痕,需要把留痕的块替换为里面的文本内容
|
19386
|
+
* @param eles
|
19387
|
+
*/
|
19388
|
+
cleanTrackRun(eles) {
|
19389
|
+
if (Array.isArray(eles)) {
|
19390
|
+
for (let i = 0; i < eles.length; i++) {
|
19391
|
+
const ele = eles[i];
|
19392
|
+
if (ele instanceof TrackRunElement) {
|
19393
|
+
const children = ElementUtil.getChildrenElements(ele).map(item => item.clone(true));
|
19394
|
+
eles.splice(i, 1, ...children);
|
19395
|
+
i--;
|
19396
|
+
continue;
|
19397
|
+
}
|
19398
|
+
this.cleanTrackRun(ele);
|
19399
|
+
}
|
19400
|
+
}
|
19401
|
+
else {
|
19402
|
+
if (eles instanceof BranchElement) {
|
19403
|
+
for (let j = 0; j < eles.length; j++) {
|
19404
|
+
const ele = eles.getChild(j);
|
19405
|
+
if (ele instanceof TrackRunElement) {
|
19406
|
+
const children = ElementUtil.getChildrenElements(ele).map(item => item.clone(true));
|
19407
|
+
children.forEach(item => ele.addChild(item, ele.getIndex()));
|
19408
|
+
eles.removeChild(ele);
|
19409
|
+
j--;
|
19410
|
+
continue;
|
19411
|
+
}
|
19412
|
+
this.cleanTrackRun(ele);
|
19413
|
+
}
|
19414
|
+
}
|
19415
|
+
}
|
19416
|
+
}
|
19342
19417
|
/**
|
19343
19418
|
* 处理表单模式下的粘贴事件
|
19344
19419
|
* @param data 要粘贴的元素
|
@@ -19349,6 +19424,14 @@ class DocumentChange {
|
|
19349
19424
|
// if (pasteString) {
|
19350
19425
|
// this.pastePlainText(pasteString);
|
19351
19426
|
// }
|
19427
|
+
//留痕模式下不支持粘贴格式
|
19428
|
+
if (this.viewOptions.enableTrackChanges) {
|
19429
|
+
const pasteString = data.map(item => ElementSerialize.serializeString(item)).join('');
|
19430
|
+
if (pasteString) {
|
19431
|
+
this.pastePlainText(pasteString);
|
19432
|
+
}
|
19433
|
+
return;
|
19434
|
+
}
|
19352
19435
|
const { startControl, startOffset } = this.selectionState;
|
19353
19436
|
const lastEle = this.insertElement(startControl, startOffset, data);
|
19354
19437
|
this.selectionState.clear();
|
@@ -20615,10 +20698,13 @@ class EditorCalendarVNode {
|
|
20615
20698
|
this.currMonth.value = new Date().getMonth();
|
20616
20699
|
this.currCalendarMode.value = 'day';
|
20617
20700
|
this.selectedDate.value = moment__default["default"]().format('YYYY-MM-DD');
|
20618
|
-
this.currentDate = '';
|
20619
20701
|
this.currTime.value = null;
|
20620
20702
|
this.selectedTime.value = null;
|
20621
20703
|
}
|
20704
|
+
clear() {
|
20705
|
+
this.reset();
|
20706
|
+
this.currentDate = '';
|
20707
|
+
}
|
20622
20708
|
render(position, dataValue, format = 'YYYY-MM-DD HH:mm:ss') {
|
20623
20709
|
format = format ?? 'YYYY-MM-DD HH:mm:ss';
|
20624
20710
|
if (dataValue !== this.currentDate) {
|
@@ -20633,9 +20719,7 @@ class EditorCalendarVNode {
|
|
20633
20719
|
this.currTime.value = currDataValue.format('HH:mm:ss');
|
20634
20720
|
this.selectedTime.value = this.currTime.value;
|
20635
20721
|
}
|
20636
|
-
if (!this.currentDate)
|
20637
|
-
this.currentDate = moment__default["default"]().format('YYYY-MM-DD');
|
20638
|
-
}
|
20722
|
+
if (!this.currentDate) ;
|
20639
20723
|
if (!this.currTime.value) {
|
20640
20724
|
this.currTime.value = moment__default["default"]().format('HH:mm:ss');
|
20641
20725
|
this.selectedTime.value = this.currTime.value;
|
@@ -21084,7 +21168,7 @@ class EditorCalendarVNode {
|
|
21084
21168
|
}
|
21085
21169
|
getDays() {
|
21086
21170
|
const days = [];
|
21087
|
-
const nowStr = moment__default["default"](
|
21171
|
+
const nowStr = moment__default["default"]().format('YYYY-MM-DD');
|
21088
21172
|
//获取本月的第一天日期
|
21089
21173
|
const firstDay = moment__default["default"]().set({ 'year': this.currYear.value, 'month': this.currMonth.value, 'date': 1 });
|
21090
21174
|
firstDay.locale('zh-cn');
|
@@ -22366,6 +22450,8 @@ class DocEditor {
|
|
22366
22450
|
docDblClickHandle(evt) {
|
22367
22451
|
//1.如果在数据元中双击,则默认选中数据元内部的所有内容
|
22368
22452
|
const currDataEle = this.getCurrentDataElement();
|
22453
|
+
//双击是否全选数据组内容
|
22454
|
+
const currDataGroup = this.viewOptions.dataGroupDblClickMode === 'selectall' ? this.getCurrentDataGroupElement() : null;
|
22369
22455
|
if (currDataEle && currDataEle instanceof DataElementInlineGroup && currDataEle.length > 2 && this.selectionState.startControl instanceof TextGroupElement) {
|
22370
22456
|
const range = new SelectionRange();
|
22371
22457
|
range.setStart(currDataEle.startDecorate, 1);
|
@@ -22373,6 +22459,13 @@ class DocEditor {
|
|
22373
22459
|
this.selectionState.addRange(range);
|
22374
22460
|
this.flushToSchedule();
|
22375
22461
|
}
|
22462
|
+
else if (currDataGroup && this.selectionState.startControl instanceof TextGroupElement) {
|
22463
|
+
const range = new SelectionRange();
|
22464
|
+
range.setStart(currDataGroup.startDecorate, 1);
|
22465
|
+
range.setEnd(currDataGroup.endDecorate, 0);
|
22466
|
+
this.selectionState.addRange(range);
|
22467
|
+
this.flushToSchedule();
|
22468
|
+
}
|
22376
22469
|
else {
|
22377
22470
|
//2.默认选词
|
22378
22471
|
const res = getFocusTextSegment(this.selectionState);
|
@@ -23368,7 +23461,7 @@ class DocEditor {
|
|
23368
23461
|
}
|
23369
23462
|
return calendar.render(position, currVal);
|
23370
23463
|
}
|
23371
|
-
calendar.
|
23464
|
+
calendar.clear();
|
23372
23465
|
return null;
|
23373
23466
|
}
|
23374
23467
|
};
|
@@ -23448,7 +23541,7 @@ class DocEditor {
|
|
23448
23541
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
23449
23542
|
}
|
23450
23543
|
version() {
|
23451
|
-
return "2.2.
|
23544
|
+
return "2.2.38";
|
23452
23545
|
}
|
23453
23546
|
switchPageHeaderEditor() {
|
23454
23547
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|
@@ -29346,6 +29439,7 @@ exports.FillNullSpaceElement = FillNullSpaceElement;
|
|
29346
29439
|
exports.FillNullSpaceRenderObject = FillNullSpaceRenderObject;
|
29347
29440
|
exports.GetTrackTipsEvent = GetTrackTipsEvent;
|
29348
29441
|
exports.GotCursorEvent = GotCursorEvent;
|
29442
|
+
exports.HLNode = HLNode;
|
29349
29443
|
exports.IDispose = IDispose;
|
29350
29444
|
exports.INotifyPropertyChanged = INotifyPropertyChanged;
|
29351
29445
|
exports.InlineBlockContainer = InlineBlockContainer;
|
@@ -29369,6 +29463,7 @@ exports.MarginProps = MarginProps;
|
|
29369
29463
|
exports.MouseElementEvent = MouseElementEvent;
|
29370
29464
|
exports.MousedownElementEvent = MousedownElementEvent;
|
29371
29465
|
exports.MultiBlockLineRenderObject = MultiBlockLineRenderObject;
|
29466
|
+
exports.NS = NS;
|
29372
29467
|
exports.OnceSubject = OnceSubject;
|
29373
29468
|
exports.PSymbolElement = PSymbolElement;
|
29374
29469
|
exports.PSymbolRenderObject = PSymbolRenderObject;
|