@hailin-zheng/editor-core 2.2.37 → 2.2.39
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 +110 -10
- package/index-cjs.js.map +1 -1
- package/index.js +109 -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-event-define.d.ts +1 -1
- 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 '';
|
@@ -17870,6 +17910,11 @@ class DocumentInput {
|
|
17870
17910
|
this.onPasteEvent.next(evt);
|
17871
17911
|
},
|
17872
17912
|
cut: (evt) => {
|
17913
|
+
const event = new CopyElementEvent(this.docCtx);
|
17914
|
+
event.sourceEvent = evt;
|
17915
|
+
if (DocumentEvent.invokeEvent('ElementCut', this.docCtx.selectionState.startControl, event, 'All')) {
|
17916
|
+
return;
|
17917
|
+
}
|
17873
17918
|
this.onCutEvent.next(evt);
|
17874
17919
|
}
|
17875
17920
|
};
|
@@ -19306,6 +19351,8 @@ class DocumentChange {
|
|
19306
19351
|
console.log('粘贴反序列化数据失败', item);
|
19307
19352
|
}
|
19308
19353
|
});
|
19354
|
+
//清理track-run数据
|
19355
|
+
this.cleanTrackRun(pasteEles);
|
19309
19356
|
if (!pasteEles.length) {
|
19310
19357
|
return;
|
19311
19358
|
}
|
@@ -19339,6 +19386,39 @@ class DocumentChange {
|
|
19339
19386
|
this.selectionState.resetRange(lastEle, -1);
|
19340
19387
|
}
|
19341
19388
|
}
|
19389
|
+
/**
|
19390
|
+
* 整理数据:如果复制的数据包含留痕,需要把留痕的块替换为里面的文本内容
|
19391
|
+
* @param eles
|
19392
|
+
*/
|
19393
|
+
cleanTrackRun(eles) {
|
19394
|
+
if (Array.isArray(eles)) {
|
19395
|
+
for (let i = 0; i < eles.length; i++) {
|
19396
|
+
const ele = eles[i];
|
19397
|
+
if (ele instanceof TrackRunElement) {
|
19398
|
+
const children = ElementUtil.getChildrenElements(ele).map(item => item.clone(true));
|
19399
|
+
eles.splice(i, 1, ...children);
|
19400
|
+
i--;
|
19401
|
+
continue;
|
19402
|
+
}
|
19403
|
+
this.cleanTrackRun(ele);
|
19404
|
+
}
|
19405
|
+
}
|
19406
|
+
else {
|
19407
|
+
if (eles instanceof BranchElement) {
|
19408
|
+
for (let j = 0; j < eles.length; j++) {
|
19409
|
+
const ele = eles.getChild(j);
|
19410
|
+
if (ele instanceof TrackRunElement) {
|
19411
|
+
const children = ElementUtil.getChildrenElements(ele).map(item => item.clone(true));
|
19412
|
+
children.forEach(item => ele.addChild(item, ele.getIndex()));
|
19413
|
+
eles.removeChild(ele);
|
19414
|
+
j--;
|
19415
|
+
continue;
|
19416
|
+
}
|
19417
|
+
this.cleanTrackRun(ele);
|
19418
|
+
}
|
19419
|
+
}
|
19420
|
+
}
|
19421
|
+
}
|
19342
19422
|
/**
|
19343
19423
|
* 处理表单模式下的粘贴事件
|
19344
19424
|
* @param data 要粘贴的元素
|
@@ -19349,6 +19429,14 @@ class DocumentChange {
|
|
19349
19429
|
// if (pasteString) {
|
19350
19430
|
// this.pastePlainText(pasteString);
|
19351
19431
|
// }
|
19432
|
+
//留痕模式下不支持粘贴格式
|
19433
|
+
if (this.viewOptions.enableTrackChanges) {
|
19434
|
+
const pasteString = data.map(item => ElementSerialize.serializeString(item)).join('');
|
19435
|
+
if (pasteString) {
|
19436
|
+
this.pastePlainText(pasteString);
|
19437
|
+
}
|
19438
|
+
return;
|
19439
|
+
}
|
19352
19440
|
const { startControl, startOffset } = this.selectionState;
|
19353
19441
|
const lastEle = this.insertElement(startControl, startOffset, data);
|
19354
19442
|
this.selectionState.clear();
|
@@ -20615,10 +20703,13 @@ class EditorCalendarVNode {
|
|
20615
20703
|
this.currMonth.value = new Date().getMonth();
|
20616
20704
|
this.currCalendarMode.value = 'day';
|
20617
20705
|
this.selectedDate.value = moment__default["default"]().format('YYYY-MM-DD');
|
20618
|
-
this.currentDate = '';
|
20619
20706
|
this.currTime.value = null;
|
20620
20707
|
this.selectedTime.value = null;
|
20621
20708
|
}
|
20709
|
+
clear() {
|
20710
|
+
this.reset();
|
20711
|
+
this.currentDate = '';
|
20712
|
+
}
|
20622
20713
|
render(position, dataValue, format = 'YYYY-MM-DD HH:mm:ss') {
|
20623
20714
|
format = format ?? 'YYYY-MM-DD HH:mm:ss';
|
20624
20715
|
if (dataValue !== this.currentDate) {
|
@@ -20633,9 +20724,7 @@ class EditorCalendarVNode {
|
|
20633
20724
|
this.currTime.value = currDataValue.format('HH:mm:ss');
|
20634
20725
|
this.selectedTime.value = this.currTime.value;
|
20635
20726
|
}
|
20636
|
-
if (!this.currentDate)
|
20637
|
-
this.currentDate = moment__default["default"]().format('YYYY-MM-DD');
|
20638
|
-
}
|
20727
|
+
if (!this.currentDate) ;
|
20639
20728
|
if (!this.currTime.value) {
|
20640
20729
|
this.currTime.value = moment__default["default"]().format('HH:mm:ss');
|
20641
20730
|
this.selectedTime.value = this.currTime.value;
|
@@ -21084,7 +21173,7 @@ class EditorCalendarVNode {
|
|
21084
21173
|
}
|
21085
21174
|
getDays() {
|
21086
21175
|
const days = [];
|
21087
|
-
const nowStr = moment__default["default"](
|
21176
|
+
const nowStr = moment__default["default"]().format('YYYY-MM-DD');
|
21088
21177
|
//获取本月的第一天日期
|
21089
21178
|
const firstDay = moment__default["default"]().set({ 'year': this.currYear.value, 'month': this.currMonth.value, 'date': 1 });
|
21090
21179
|
firstDay.locale('zh-cn');
|
@@ -22366,6 +22455,8 @@ class DocEditor {
|
|
22366
22455
|
docDblClickHandle(evt) {
|
22367
22456
|
//1.如果在数据元中双击,则默认选中数据元内部的所有内容
|
22368
22457
|
const currDataEle = this.getCurrentDataElement();
|
22458
|
+
//双击是否全选数据组内容
|
22459
|
+
const currDataGroup = this.viewOptions.dataGroupDblClickMode === 'selectall' ? this.getCurrentDataGroupElement() : null;
|
22369
22460
|
if (currDataEle && currDataEle instanceof DataElementInlineGroup && currDataEle.length > 2 && this.selectionState.startControl instanceof TextGroupElement) {
|
22370
22461
|
const range = new SelectionRange();
|
22371
22462
|
range.setStart(currDataEle.startDecorate, 1);
|
@@ -22373,6 +22464,13 @@ class DocEditor {
|
|
22373
22464
|
this.selectionState.addRange(range);
|
22374
22465
|
this.flushToSchedule();
|
22375
22466
|
}
|
22467
|
+
else if (currDataGroup && this.selectionState.startControl instanceof TextGroupElement) {
|
22468
|
+
const range = new SelectionRange();
|
22469
|
+
range.setStart(currDataGroup.startDecorate, 1);
|
22470
|
+
range.setEnd(currDataGroup.endDecorate, 0);
|
22471
|
+
this.selectionState.addRange(range);
|
22472
|
+
this.flushToSchedule();
|
22473
|
+
}
|
22376
22474
|
else {
|
22377
22475
|
//2.默认选词
|
22378
22476
|
const res = getFocusTextSegment(this.selectionState);
|
@@ -23368,7 +23466,7 @@ class DocEditor {
|
|
23368
23466
|
}
|
23369
23467
|
return calendar.render(position, currVal);
|
23370
23468
|
}
|
23371
|
-
calendar.
|
23469
|
+
calendar.clear();
|
23372
23470
|
return null;
|
23373
23471
|
}
|
23374
23472
|
};
|
@@ -23448,7 +23546,7 @@ class DocEditor {
|
|
23448
23546
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
23449
23547
|
}
|
23450
23548
|
version() {
|
23451
|
-
return "2.2.
|
23549
|
+
return "2.2.39";
|
23452
23550
|
}
|
23453
23551
|
switchPageHeaderEditor() {
|
23454
23552
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|
@@ -29346,6 +29444,7 @@ exports.FillNullSpaceElement = FillNullSpaceElement;
|
|
29346
29444
|
exports.FillNullSpaceRenderObject = FillNullSpaceRenderObject;
|
29347
29445
|
exports.GetTrackTipsEvent = GetTrackTipsEvent;
|
29348
29446
|
exports.GotCursorEvent = GotCursorEvent;
|
29447
|
+
exports.HLNode = HLNode;
|
29349
29448
|
exports.IDispose = IDispose;
|
29350
29449
|
exports.INotifyPropertyChanged = INotifyPropertyChanged;
|
29351
29450
|
exports.InlineBlockContainer = InlineBlockContainer;
|
@@ -29369,6 +29468,7 @@ exports.MarginProps = MarginProps;
|
|
29369
29468
|
exports.MouseElementEvent = MouseElementEvent;
|
29370
29469
|
exports.MousedownElementEvent = MousedownElementEvent;
|
29371
29470
|
exports.MultiBlockLineRenderObject = MultiBlockLineRenderObject;
|
29471
|
+
exports.NS = NS;
|
29372
29472
|
exports.OnceSubject = OnceSubject;
|
29373
29473
|
exports.PSymbolElement = PSymbolElement;
|
29374
29474
|
exports.PSymbolRenderObject = PSymbolRenderObject;
|