From bacfe3c9540ccf0544a0a181b97227b203b45795 Mon Sep 17 00:00:00 2001 From: claudijo Date: Tue, 29 Mar 2022 21:21:41 +0300 Subject: [PATCH] Ensure label component is updated when its text content is changed --- dist/index.cjs.js | 10 +++++++++- dist/index.esm.js | 10 +++++++++- lib/shapes/label.js | 9 +++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/dist/index.cjs.js b/dist/index.cjs.js index d6d9c06..c8291b3 100644 --- a/dist/index.cjs.js +++ b/dist/index.cjs.js @@ -1840,6 +1840,14 @@ var CanvasLabel = /*#__PURE__*/function (_AbstractShape) { } _createClass(CanvasLabel, [{ + key: "textContent", + get: function get() { + return this.getTextualAttribute('textContent', ''); + }, + set: function set(value) { + this.setAttribute('textContent', value); + } + }, { key: "fontSize", get: function get() { return this.getNumericAttribute('fontSize', 10); @@ -2006,7 +2014,7 @@ var CanvasLabel = /*#__PURE__*/function (_AbstractShape) { }], [{ key: "observedAttributes", get: function get() { - return [].concat(_toConsumableArray(AbstractShape.observedAttributes), ['color', 'fontsize', 'fontfamily', 'fontstyle', 'fontweight', 'baseline', 'align', 'maxwidth']); + return [].concat(_toConsumableArray(AbstractShape.observedAttributes), ['color', 'fontsize', 'fontfamily', 'fontstyle', 'fontweight', 'baseline', 'align', 'maxwidth', 'textcontent']); } }]); diff --git a/dist/index.esm.js b/dist/index.esm.js index 4c8b55a..2d65df8 100644 --- a/dist/index.esm.js +++ b/dist/index.esm.js @@ -1832,6 +1832,14 @@ var CanvasLabel = /*#__PURE__*/function (_AbstractShape) { } _createClass(CanvasLabel, [{ + key: "textContent", + get: function get() { + return this.getTextualAttribute('textContent', ''); + }, + set: function set(value) { + this.setAttribute('textContent', value); + } + }, { key: "fontSize", get: function get() { return this.getNumericAttribute('fontSize', 10); @@ -1998,7 +2006,7 @@ var CanvasLabel = /*#__PURE__*/function (_AbstractShape) { }], [{ key: "observedAttributes", get: function get() { - return [].concat(_toConsumableArray(AbstractShape.observedAttributes), ['color', 'fontsize', 'fontfamily', 'fontstyle', 'fontweight', 'baseline', 'align', 'maxwidth']); + return [].concat(_toConsumableArray(AbstractShape.observedAttributes), ['color', 'fontsize', 'fontfamily', 'fontstyle', 'fontweight', 'baseline', 'align', 'maxwidth', 'textcontent']); } }]); diff --git a/lib/shapes/label.js b/lib/shapes/label.js index f6b34c9..234dff6 100644 --- a/lib/shapes/label.js +++ b/lib/shapes/label.js @@ -18,9 +18,18 @@ export class CanvasLabel extends AbstractShape { 'baseline', 'align', 'maxwidth', + 'textcontent', ]; } + get textContent() { + return this.getTextualAttribute('textContent', ''); + } + + set textContent(value) { + this.setAttribute('textContent', value); + } + get fontSize() { return this.getNumericAttribute('fontSize', 10); }