| | |
| | |
| | |
| | |
| |
|
| | const uid = require('../util/uid'); |
| | const xmlEscape = require('../util/xml-escape'); |
| |
|
| | class Comment { |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | constructor (id, text, x, y, width, height, minimized) { |
| | this.id = id || uid(); |
| | this.text = text; |
| | this.x = x; |
| | this.y = y; |
| | this.width = Math.max(Number(width), Comment.MIN_WIDTH); |
| | this.height = Math.max(Number(height), Comment.MIN_HEIGHT); |
| | this.minimized = minimized || false; |
| | this.blockId = null; |
| | } |
| |
|
| | toXML () { |
| | return `<comment id="${this.id}" x="${this.x}" y="${ |
| | this.y}" w="${this.width}" h="${this.height}" pinned="${ |
| | this.blockId !== null}" minimized="${this.minimized}">${xmlEscape(this.text)}</comment>`; |
| | } |
| |
|
| | |
| | static get MIN_WIDTH () { |
| | return 20; |
| | } |
| |
|
| | static get MIN_HEIGHT () { |
| | return 20; |
| | } |
| |
|
| | static get DEFAULT_WIDTH () { |
| | return 100; |
| | } |
| |
|
| | static get DEFAULT_HEIGHT () { |
| | return 100; |
| | } |
| |
|
| | } |
| |
|
| | module.exports = Comment; |
| |
|