@hailin-zheng/editor-core 2.1.16 → 2.1.17

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
@@ -8269,8 +8269,9 @@ class DataElementBarcode extends DataElementLeaf {
8269
8269
  }
8270
8270
  createRenderObject() {
8271
8271
  const render = new DataElementBarcodeRenderObject(this);
8272
- render.rect.width = this.props.width + 2;
8273
- render.rect.height = this.props.height + 2;
8272
+ const { width, height } = render.measureSize();
8273
+ render.rect.width = width + 2;
8274
+ render.rect.height = height + 2;
8274
8275
  return render;
8275
8276
  }
8276
8277
  serialize(options) {
@@ -8341,11 +8342,27 @@ class DataElementBarcodeRenderObject extends ResizeLeafRenderObject {
8341
8342
  else {
8342
8343
  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
8343
8344
  JsBarcode(svg, this.element.props.text);
8345
+ const width = Number.parseInt(svg.getAttribute('width').replace('px', ''));
8346
+ const height = Number.parseInt(svg.getAttribute('height').replace('px', ''));
8347
+ svg.setAttribute('width', this.element.props.width + 'px');
8348
+ svg.setAttribute('height', height * (this.element.props.width / width) + 'px');
8344
8349
  const vNode = toVNode(svg);
8345
8350
  t.children = [vNode];
8346
8351
  }
8347
8352
  return t;
8348
8353
  }
8354
+ measureSize() {
8355
+ if (this.element.props.type === 'qrcode') {
8356
+ return { width: this.element.props.width, height: this.element.props.height };
8357
+ }
8358
+ else {
8359
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
8360
+ JsBarcode(svg, this.element.props.text);
8361
+ const width = Number.parseInt(svg.getAttribute('width').replace('px', ''));
8362
+ const height = Number.parseInt(svg.getAttribute('height').replace('px', ''));
8363
+ return { width: this.element.props.width, height: height * (this.element.props.width / width) };
8364
+ }
8365
+ }
8349
8366
  toSvgString(qr, border, lightColor, darkColor) {
8350
8367
  let parts = [];
8351
8368
  for (let y = 0; y < qr.size; y++) {
@@ -28788,7 +28805,7 @@ class DocEditor {
28788
28805
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
28789
28806
  }
28790
28807
  version() {
28791
- return "2.1.16";
28808
+ return "2.1.17";
28792
28809
  }
28793
28810
  switchPageHeaderEditor() {
28794
28811
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);