text-container.js (1360B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 const nodeConstants = require("resource://devtools/shared/dom-node-constants.js"); 8 const TextEditor = require("resource://devtools/client/inspector/markup/views/text-editor.js"); 9 const MarkupContainer = require("resource://devtools/client/inspector/markup/views/markup-container.js"); 10 11 /** 12 * An implementation of MarkupContainer for text node and comment nodes. 13 * Allows basic text editing in a textarea. 14 */ 15 class MarkupTextContainer extends MarkupContainer { 16 /** 17 * @param {MarkupView} markupView 18 * The markup view that owns this container. 19 * @param {NodeFront} node 20 * The node to display. 21 */ 22 constructor(markupView, node) { 23 super(); 24 this.initialize(markupView, node, "textcontainer"); 25 26 if (node.nodeType == nodeConstants.TEXT_NODE) { 27 this.editor = new TextEditor(this, node, "text"); 28 } else if (node.nodeType == nodeConstants.COMMENT_NODE) { 29 this.editor = new TextEditor(this, node, "comment"); 30 } else { 31 throw new Error("Invalid node for MarkupTextContainer"); 32 } 33 34 this.tagLine.appendChild(this.editor.elt); 35 } 36 } 37 38 module.exports = MarkupTextContainer;