diff --git a/src/item/ChangeFlag.js b/src/item/ChangeFlag.js index 91422abe..a55c0116 100644 --- a/src/item/ChangeFlag.js +++ b/src/item/ChangeFlag.js @@ -28,6 +28,8 @@ var ChangeFlag = { STYLE: 16, // Item attributes: visible, blendMode, locked, name, opacity, clipMask ... ATTRIBUTE: 32, + // Text content + CONTENT: 64, // Clipping in one of the child items CLIPPING: 64 }; @@ -38,5 +40,6 @@ var Change = { GEOMETRY: ChangeFlag.GEOMETRY | ChangeFlag.APPEARANCE, STROKE: ChangeFlag.STROKE | ChangeFlag.APPEARANCE, STYLE: ChangeFlag.STYLE | ChangeFlag.APPEARANCE, - ATTRIBUTE: ChangeFlag.ATTRIBUTE | ChangeFlag.APPEARANCE + ATTRIBUTE: ChangeFlag.ATTRIBUTE | ChangeFlag.APPEARANCE, + CONTENT: ChangeFlag.CONTENT | ChangeFlag.APPEARANCE }; diff --git a/src/text/PointText.js b/src/text/PointText.js index 0e6fd576..5f8d5cc2 100644 --- a/src/text/PointText.js +++ b/src/text/PointText.js @@ -83,7 +83,7 @@ var PointText = this.PointText = TextItem.extend({ }, draw: function(ctx) { - if (this.content == null) + if (!this._content) return; ctx.save(); ctx.font = this._characterStyle.fontSize + 'pt ' + @@ -97,11 +97,11 @@ var PointText = this.PointText = TextItem.extend({ ctx.globalAlpha = this._opacity; if (fillColor) { ctx.fillStyle = fillColor.getCanvasStyle(ctx); - ctx.fillText(this.content, 0, 0); + ctx.fillText(this._content, 0, 0); } if (strokeColor) { ctx.strokeStyle = strokeColor.getCanvasStyle(ctx); - ctx.strokeText(this.content, 0, 0); + ctx.strokeText(this._content, 0, 0); } ctx.restore(); } diff --git a/src/text/TextItem.js b/src/text/TextItem.js index a79b6bbd..5a5c4bd4 100644 --- a/src/text/TextItem.js +++ b/src/text/TextItem.js @@ -30,7 +30,7 @@ var TextItem = this.TextItem = Item.extend({ */ initialize: function() { this.base(); - this.content = ''; + this._content = ''; this._characterStyle = CharacterStyle.create(this); this.setCharacterStyle(this._project.getCurrentStyle()); this._paragraphStyle = ParagraphStyle.create(this); @@ -70,12 +70,21 @@ var TextItem = this.TextItem = Item.extend({ */ _clone: function(copy) { - copy.content = this.content; + copy._content = this._content; copy.setCharacterStyle(this._characterStyle); copy.setParagraphStyle(this._paragraphStyle); return this.base(copy); }, + getContent: function() { + return this._content; + }, + + setContent: function(content) { + this._changed(Change.CONTENT); + this._content = content; + }, + /** * {@grouptitle Style Properties} *