@hailin-zheng/editor-core 2.2.30 → 2.2.32
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 +127 -12
- package/index-cjs.js.map +1 -1
- package/index.js +124 -13
- package/index.js.map +1 -1
- package/med_editor/framework/document-context.d.ts +9 -1
- package/med_editor/framework/element-define.d.ts +3 -3
- package/med_editor/framework/impl/data-element/data-element-base-impl.d.ts +2 -1
- package/med_editor/framework/impl/index.d.ts +1 -0
- package/package.json +1 -1
package/index-cjs.js
CHANGED
@@ -1335,6 +1335,7 @@ class Element {
|
|
1335
1335
|
this.disposed = true;
|
1336
1336
|
this.visibleExpr = null;
|
1337
1337
|
this.effectExpr = null;
|
1338
|
+
this._onChangeEvent.unsubscribe();
|
1338
1339
|
}
|
1339
1340
|
addEvent(event, handle, useCapture = false) {
|
1340
1341
|
if (!this._eventMap) {
|
@@ -4237,7 +4238,7 @@ class DataElementInlineGroup extends InlineGroupInputElement {
|
|
4237
4238
|
// this.expressFn = new Function();
|
4238
4239
|
// }
|
4239
4240
|
}
|
4240
|
-
|
4241
|
+
parserExpr;
|
4241
4242
|
/**
|
4242
4243
|
* 解析表达式
|
4243
4244
|
* @param ele
|
@@ -4250,7 +4251,7 @@ class DataElementInlineGroup extends InlineGroupInputElement {
|
|
4250
4251
|
if (!this.props.expression || !data.options.enableDyExpression)
|
4251
4252
|
return;
|
4252
4253
|
//存在表达式,并且已经解析过,不再做处理
|
4253
|
-
if (this.
|
4254
|
+
if (this.parserExpr)
|
4254
4255
|
return;
|
4255
4256
|
const reactiveMode = data.renderCtx.drawMode !== 'print';
|
4256
4257
|
try {
|
@@ -4259,7 +4260,7 @@ class DataElementInlineGroup extends InlineGroupInputElement {
|
|
4259
4260
|
let compliedCode = parser(this.props.expression, depIdItems);
|
4260
4261
|
compliedCode = addReturn(compliedCode);
|
4261
4262
|
const executeCtx = execute.setExecuteCtx(this);
|
4262
|
-
this.
|
4263
|
+
this.parserExpr = {
|
4263
4264
|
compliedCode,
|
4264
4265
|
func: new Function(`with(this){ ${compliedCode} }`),
|
4265
4266
|
depItems: depEleMap,
|
@@ -4285,20 +4286,20 @@ class DataElementInlineGroup extends InlineGroupInputElement {
|
|
4285
4286
|
try {
|
4286
4287
|
data.onNextView(() => {
|
4287
4288
|
//当前元素可能被删除
|
4288
|
-
const func = this.
|
4289
|
+
const func = this.parserExpr?.func;
|
4289
4290
|
if (!func) {
|
4290
4291
|
return;
|
4291
4292
|
}
|
4292
4293
|
const tempExecuter = execute.create();
|
4293
4294
|
//设置执行上下文,doc或者doc-part
|
4294
|
-
tempExecuter.setExecuteCtx(this.
|
4295
|
-
tempExecuter.setCurrentCtx(this, this.
|
4295
|
+
tempExecuter.setExecuteCtx(this.parserExpr.executeCtx);
|
4296
|
+
tempExecuter.setCurrentCtx(this, this.parserExpr.depItems);
|
4296
4297
|
const fn = func.bind(tempExecuter);
|
4297
4298
|
fn();
|
4298
4299
|
});
|
4299
4300
|
}
|
4300
4301
|
catch (e) {
|
4301
|
-
console.error(e, "表达式执行出错", this.
|
4302
|
+
console.error(e, "表达式执行出错", this.parserExpr.compliedCode);
|
4302
4303
|
}
|
4303
4304
|
});
|
4304
4305
|
});
|
@@ -4317,14 +4318,14 @@ class DataElementInlineGroup extends InlineGroupInputElement {
|
|
4317
4318
|
* @private
|
4318
4319
|
*/
|
4319
4320
|
evalEleExpr(executeCtx) {
|
4320
|
-
if (this.
|
4321
|
+
if (this.parserExpr && this.parserExpr.func) {
|
4321
4322
|
try {
|
4322
|
-
executeCtx.setCurrentCtx(this, this.
|
4323
|
-
const func = this.
|
4323
|
+
executeCtx.setCurrentCtx(this, this.parserExpr.depItems);
|
4324
|
+
const func = this.parserExpr.func.bind(executeCtx);
|
4324
4325
|
func();
|
4325
4326
|
}
|
4326
4327
|
catch (e) {
|
4327
|
-
console.error(e, "表达式执行出错:evalVisibleExpr", this.
|
4328
|
+
console.error(e, "表达式执行出错:evalVisibleExpr", this.parserExpr.compliedCode);
|
4328
4329
|
}
|
4329
4330
|
finally {
|
4330
4331
|
executeCtx.clearCurrentCtx();
|
@@ -4342,6 +4343,11 @@ class DataElementInlineGroup extends InlineGroupInputElement {
|
|
4342
4343
|
}
|
4343
4344
|
this.errorTip = this.validate();
|
4344
4345
|
}
|
4346
|
+
destroy() {
|
4347
|
+
this.visibleExpr = undefined;
|
4348
|
+
this.parserExpr = undefined;
|
4349
|
+
super.destroy();
|
4350
|
+
}
|
4345
4351
|
}
|
4346
4352
|
function getCurrOptions(ele) {
|
4347
4353
|
const doc = ElementUtil.getParent(ele, item => item.type === 'doc');
|
@@ -9362,6 +9368,9 @@ class DataElementList extends DataElementInlineGroup {
|
|
9362
9368
|
this.clearInnerItems();
|
9363
9369
|
return;
|
9364
9370
|
}
|
9371
|
+
if (typeof vals === 'string' && vals) {
|
9372
|
+
vals = vals.split(';');
|
9373
|
+
}
|
9365
9374
|
if (!Array.isArray(vals)) {
|
9366
9375
|
vals = [vals];
|
9367
9376
|
}
|
@@ -11077,6 +11086,97 @@ class SVGFactory extends ElementFactory {
|
|
11077
11086
|
}
|
11078
11087
|
}
|
11079
11088
|
|
11089
|
+
class LineElement extends LeafElement {
|
11090
|
+
constructor() {
|
11091
|
+
super('line');
|
11092
|
+
this.props = new LineProps();
|
11093
|
+
}
|
11094
|
+
createRenderObject() {
|
11095
|
+
const symbol = new LineRenderObject(this);
|
11096
|
+
symbol.rect.height = Math.ceil(14 * TEXT_HEIGHT_FACTOR);
|
11097
|
+
symbol.rect.width = 20;
|
11098
|
+
return symbol;
|
11099
|
+
}
|
11100
|
+
serialize(options) {
|
11101
|
+
return {
|
11102
|
+
type: 'line',
|
11103
|
+
props: this.props.getSerializeProps(options)
|
11104
|
+
};
|
11105
|
+
}
|
11106
|
+
clone() {
|
11107
|
+
const clone = new LineElement();
|
11108
|
+
cloneElementBase(this, clone);
|
11109
|
+
this.props.clone(clone.props);
|
11110
|
+
return clone;
|
11111
|
+
}
|
11112
|
+
}
|
11113
|
+
class LineRenderObject extends LeafRenderObject {
|
11114
|
+
exportSVG(event) {
|
11115
|
+
return ElementUtil.createSvgLine({
|
11116
|
+
x1: this.rect.x,
|
11117
|
+
y1: this.rect.y,
|
11118
|
+
x2: this.rect.x + this.rect.width,
|
11119
|
+
y2: this.rect.y + this.rect.height,
|
11120
|
+
'stroke-width': this.element.props.thickness,
|
11121
|
+
stroke: this.element.props.color,
|
11122
|
+
'stroke-dasharray': this.element.props.type === LineType.Dashed ? '5,5' : ''
|
11123
|
+
});
|
11124
|
+
}
|
11125
|
+
clone() {
|
11126
|
+
const render = new LineRenderObject(this.element);
|
11127
|
+
render.rect = ElementUtil.cloneRect(this.rect);
|
11128
|
+
return render;
|
11129
|
+
}
|
11130
|
+
}
|
11131
|
+
class LineFactory extends ElementFactory {
|
11132
|
+
match(type) {
|
11133
|
+
return type === 'line';
|
11134
|
+
}
|
11135
|
+
createElement(data) {
|
11136
|
+
const ele = new LineElement();
|
11137
|
+
ele.props.width = data.props.width;
|
11138
|
+
ele.props.type = data.props.type ?? LineType.Solid;
|
11139
|
+
ele.props.thickness = data.props.thickness ?? 1;
|
11140
|
+
ele.props.color = data.props.color ?? '#000000';
|
11141
|
+
return ele;
|
11142
|
+
}
|
11143
|
+
}
|
11144
|
+
// 定义线段类型的枚举
|
11145
|
+
var LineType;
|
11146
|
+
(function (LineType) {
|
11147
|
+
LineType["Solid"] = "solid";
|
11148
|
+
LineType["Dashed"] = "dashed";
|
11149
|
+
LineType["Dotted"] = "dotted";
|
11150
|
+
LineType["DashDot"] = "dash-dot";
|
11151
|
+
})(LineType || (LineType = {}));
|
11152
|
+
class LineProps {
|
11153
|
+
width; // 线段的宽度,例如 '50%', '100px'
|
11154
|
+
type = LineType.Solid; // 线段的类型,例如 LineType.Solid
|
11155
|
+
thickness = 1; // 线段的粗细,例如 '2px'
|
11156
|
+
color = '#000000'; // 线段的颜色,例如 '#000000'
|
11157
|
+
clone(dest) {
|
11158
|
+
const clone = dest ?? new LineProps();
|
11159
|
+
clone.width = this.width;
|
11160
|
+
clone.type = this.type;
|
11161
|
+
clone.thickness = this.thickness;
|
11162
|
+
clone.color = this.color;
|
11163
|
+
return clone;
|
11164
|
+
}
|
11165
|
+
getSerializeProps(viewOptions) {
|
11166
|
+
const props = {};
|
11167
|
+
if (this.color !== '#000000') {
|
11168
|
+
props.color = this.color;
|
11169
|
+
}
|
11170
|
+
if (this.type !== LineType.Solid) {
|
11171
|
+
props.type = this.type;
|
11172
|
+
}
|
11173
|
+
if (this.thickness !== 1) {
|
11174
|
+
props.thickness = this.thickness;
|
11175
|
+
}
|
11176
|
+
return props;
|
11177
|
+
}
|
11178
|
+
}
|
11179
|
+
|
11080
11180
|
class ElementSerialize {
|
11081
11181
|
/**
|
11082
11182
|
* 将当前文档对象构建并输出到标准的JSON对象
|
@@ -13831,6 +13931,14 @@ class EditorContext {
|
|
13831
13931
|
getCtx(ele) {
|
13832
13932
|
return new DocumentContext(ele, this.selectionState);
|
13833
13933
|
}
|
13934
|
+
/**
|
13935
|
+
* 注入右键菜单事件处理器
|
13936
|
+
* @param elementType 元素类型
|
13937
|
+
* @param eventName 事件名称
|
13938
|
+
* @param handler 回调处理函数
|
13939
|
+
* @param useCapture 是否为捕获阶段
|
13940
|
+
* @returns
|
13941
|
+
*/
|
13834
13942
|
registerTypeHandlers(elementType, eventName, handler, useCapture = false) {
|
13835
13943
|
if (elementTypeEventHandler.find(item => item.ctx === this && item.elementType === elementType && item.eventName === eventName && item.useCapture === useCapture)) {
|
13836
13944
|
return;
|
@@ -20356,6 +20464,9 @@ class EditorCalendarVNode {
|
|
20356
20464
|
}
|
20357
20465
|
render(position, dataValue, format = 'YYYY-MM-DD HH:mm:ss') {
|
20358
20466
|
format = format ?? 'YYYY-MM-DD HH:mm:ss';
|
20467
|
+
if (dataValue !== this.currentDate) {
|
20468
|
+
this.reset();
|
20469
|
+
}
|
20359
20470
|
if (!this.currentDate && dataValue) {
|
20360
20471
|
const currDataValue = moment__default["default"](dataValue, format);
|
20361
20472
|
this.currYear.value = currDataValue.year();
|
@@ -23188,7 +23299,7 @@ class DocEditor {
|
|
23188
23299
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
23189
23300
|
}
|
23190
23301
|
version() {
|
23191
|
-
return "2.2.
|
23302
|
+
return "2.2.32";
|
23192
23303
|
}
|
23193
23304
|
switchPageHeaderEditor() {
|
23194
23305
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|
@@ -29099,6 +29210,10 @@ exports.IsInSideInlineGroupInputElement = IsInSideInlineGroupInputElement;
|
|
29099
29210
|
exports.KeyboradElementEvent = KeyboradElementEvent;
|
29100
29211
|
exports.LeafElement = LeafElement;
|
29101
29212
|
exports.LeafRenderObject = LeafRenderObject;
|
29213
|
+
exports.LineElement = LineElement;
|
29214
|
+
exports.LineFactory = LineFactory;
|
29215
|
+
exports.LineProps = LineProps;
|
29216
|
+
exports.LineRenderObject = LineRenderObject;
|
29102
29217
|
exports.LostCursorEvent = LostCursorEvent;
|
29103
29218
|
exports.MarginProps = MarginProps;
|
29104
29219
|
exports.MouseElementEvent = MouseElementEvent;
|