@hailin-zheng/editor-core 2.2.33 → 2.2.35

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.js CHANGED
@@ -3979,6 +3979,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3979
3979
  const pageCorner = this.exportPageCornerHTML(event);
3980
3980
  const pageNum = this.exportPageNumHTML(event);
3981
3981
  const copyright = this.exportCopyRight(event);
3982
+ const defs = this.exportDefs();
3982
3983
  return {
3983
3984
  sel: "svg",
3984
3985
  isCompleted: true,
@@ -3993,7 +3994,7 @@ class DocumentRenderObject extends BlockContainerRenderObject {
3993
3994
  },
3994
3995
  },
3995
3996
  children: [
3996
- pageCorner, highlight, selection, ...CommonUtil.toArray(event.getChildNodes(this)), pageNum, copyright
3997
+ defs, pageCorner, highlight, selection, ...CommonUtil.toArray(event.getChildNodes(this)), pageNum, copyright
3997
3998
  ]
3998
3999
  };
3999
4000
  }
@@ -4060,6 +4061,34 @@ class DocumentRenderObject extends BlockContainerRenderObject {
4060
4061
  },
4061
4062
  };
4062
4063
  }
4064
+ exportDefs() {
4065
+ /**
4066
+ * <defs>
4067
+ <filter id="f1" x="0" y="0">
4068
+ <feGaussianBlur stdDeviation="0.5" result="blur" />
4069
+ <feMerge>
4070
+ <feMergeNode in="thicken" />
4071
+ <feMergeNode in="SourceGraphic" />
4072
+ </feMerge>
4073
+ </filter>
4074
+ </defs>
4075
+ */
4076
+ return {
4077
+ sel: 'defs',
4078
+ data: {
4079
+ ns: "http://www.w3.org/2000/svg",
4080
+ props: {
4081
+ innerHTML: `<filter id="t_bold" x="0" y="0">
4082
+ <feGaussianBlur stdDeviation="0.5" result="blur" />
4083
+ <feMerge>
4084
+ <feMergeNode in="thicken" />
4085
+ <feMergeNode in="SourceGraphic" />
4086
+ </feMerge>
4087
+ </filter>`
4088
+ }
4089
+ },
4090
+ };
4091
+ }
4063
4092
  }
4064
4093
  class DocumentFactory extends ElementFactory {
4065
4094
  match(type) {
@@ -5184,7 +5213,7 @@ class TextGroupRenderObject extends LeafRenderObject {
5184
5213
  //行高处理
5185
5214
  y += (height - props.fontSize) / 2;
5186
5215
  const t = ElementUtil.createSvgText(text, {
5187
- 'font-family': this.element.props.fontName,
5216
+ 'font-family': props.fontName,
5188
5217
  'font-size': fontSize,
5189
5218
  x,
5190
5219
  y,
@@ -5192,38 +5221,85 @@ class TextGroupRenderObject extends LeafRenderObject {
5192
5221
  if (actualFontBoundingBoxAscent === undefined) {
5193
5222
  t.data.attrs['dominant-baseline'] = 'hanging';
5194
5223
  }
5195
- if (this.element.props.fontWeight !== 'normal') {
5196
- t.data.attrs['font-weight'] = this.element.props.fontWeight;
5224
+ if (props.fontWeight !== 'normal') ;
5225
+ if (props.fontStyle !== 'normal') {
5226
+ t.data.attrs['font-style'] = props.fontStyle;
5197
5227
  }
5198
- if (this.element.props.fontStyle !== 'normal') {
5199
- t.data.attrs['font-style'] = this.element.props.fontStyle;
5228
+ if (props.color) {
5229
+ t.data.attrs['fill'] = props.color;
5200
5230
  }
5201
- if (this.element.props.color) {
5202
- t.data.attrs['fill'] = this.element.props.color;
5203
- }
5204
- if (this.element.props.background) {
5231
+ if (props.background) {
5205
5232
  const bgX = event.relativePagePos.x;
5206
5233
  const bgY = event.relativePagePos.y;
5207
- event.highlights.push(ElementUtil.getFillSvgRect(bgX, bgY, this.rect.width, this.rect.height, this.element.props.background));
5234
+ event.highlights.push(ElementUtil.getFillSvgRect(bgX, bgY, this.rect.width, this.rect.height, props.background));
5208
5235
  }
5209
- if (this.element.props.underline) {
5210
- const underHeight = this.element.props.fontSize * 1.2;
5236
+ if (props.underline) {
5237
+ const underHeight = props.fontSize * 1.2;
5211
5238
  const path = `M${event.relativePagePos.x} ${event.relativePagePos.y + underHeight} L${event.relativePagePos.x + this.rect.width} ${event.relativePagePos.y + underHeight}`;
5212
5239
  event.highlights.push(ElementUtil.getStrokeSvgPath(path, '#000', 1));
5213
5240
  }
5214
- if (this.element.props.linethrough) {
5241
+ if (props.linethrough) {
5215
5242
  const path = `M${event.relativePagePos.x} ${event.relativePagePos.y + this.rect.height / 2} L${event.relativePagePos.x + this.rect.width} ${event.relativePagePos.y + this.rect.height / 2}`;
5216
5243
  event.highlights.push(ElementUtil.getStrokeSvgPath(path, '#000', 1));
5217
5244
  }
5218
- if (this.element.props.border) {
5245
+ if (props.border) {
5219
5246
  event.highlights.push(ElementUtil.getStrokeSvgPath(ElementUtil.getRectPath(event.relativePagePos.x, event.relativePagePos.y, this.rect.width, this.rect.height), '#000', 1));
5220
5247
  }
5221
- if (this.element.props.overline) {
5248
+ if (props.overline) {
5222
5249
  const path = `M${event.relativePagePos.x} ${event.relativePagePos.y} L${event.relativePagePos.x + this.rect.width} ${event.relativePagePos.y}`;
5223
5250
  event.highlights.push(ElementUtil.getStrokeSvgPath(path, '#000', 1));
5224
5251
  }
5225
5252
  //处理null-text
5226
5253
  if (this.element.isDecorate && this.element.disableClick && !this.element.parent) ;
5254
+ if (props.fontWeight === "bold") {
5255
+ const blurRate = props.fontSize * 0.5 / 15;
5256
+ const g = {
5257
+ sel: "g",
5258
+ data: {
5259
+ ns: "http://www.w3.org/2000/svg",
5260
+ attrs: {}
5261
+ },
5262
+ children: [
5263
+ {
5264
+ sel: "g",
5265
+ data: {
5266
+ ns: "http://www.w3.org/2000/svg",
5267
+ attrs: {
5268
+ translate: { x: 0, y: 0 }
5269
+ }
5270
+ },
5271
+ children: [
5272
+ { ...t }
5273
+ ]
5274
+ },
5275
+ {
5276
+ sel: "g",
5277
+ data: {
5278
+ ns: "http://www.w3.org/2000/svg",
5279
+ attrs: {
5280
+ translate: { x: blurRate, y: 0 }
5281
+ }
5282
+ },
5283
+ children: [
5284
+ { ...t }
5285
+ ]
5286
+ },
5287
+ {
5288
+ sel: "g",
5289
+ data: {
5290
+ ns: "http://www.w3.org/2000/svg",
5291
+ attrs: {
5292
+ translate: { x: 0, y: blurRate }
5293
+ }
5294
+ },
5295
+ children: [
5296
+ { ...t }
5297
+ ]
5298
+ }
5299
+ ]
5300
+ };
5301
+ return g;
5302
+ }
5227
5303
  return t;
5228
5304
  }
5229
5305
  }
@@ -23385,7 +23461,7 @@ class DocEditor {
23385
23461
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
23386
23462
  }
23387
23463
  version() {
23388
- return "2.2.33";
23464
+ return "2.2.35";
23389
23465
  }
23390
23466
  switchPageHeaderEditor() {
23391
23467
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);