Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(956)

Unified Diff: Source/devtools/front_end/ui/InplaceEditor.js

Issue 658483004: DevTools: fix DOM multiline editing, extract multiline editor API. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/elements/ElementsTreeOutline.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/ui/InplaceEditor.js
diff --git a/Source/devtools/front_end/ui/InplaceEditor.js b/Source/devtools/front_end/ui/InplaceEditor.js
index e875ae7289fa69b7f40da4b815cbacfaa6022486..10cf3a115c434c4212f79d0c2056a0785bc39afd 100644
--- a/Source/devtools/front_end/ui/InplaceEditor.js
+++ b/Source/devtools/front_end/ui/InplaceEditor.js
@@ -10,9 +10,14 @@ WebInspector.InplaceEditor = function()
}
/**
+ * @typedef {{cancel: function(), commit: function(), setWidth: function(number)}}
+ */
+WebInspector.InplaceEditor.Controller;
+
+/**
* @param {!Element} element
* @param {!WebInspector.InplaceEditor.Config=} config
- * @return {?{cancel: function(), commit: function(), setWidth: function(number)}}
+ * @return {?WebInspector.InplaceEditor.Controller}
*/
WebInspector.InplaceEditor.startEditing = function(element, config)
{
@@ -21,6 +26,28 @@ WebInspector.InplaceEditor.startEditing = function(element, config)
return WebInspector.InplaceEditor._defaultInstance.startEditing(element, config);
}
+/**
+ * @param {!Element} element
+ * @param {!WebInspector.InplaceEditor.Config=} config
+ * @return {!Promise.<!WebInspector.InplaceEditor.Controller>}
+ */
+WebInspector.InplaceEditor.startMultilineEditing = function(element, config)
+{
+ return self.runtime.instancePromise(WebInspector.InplaceEditor).then(startEditing);
+
+ /**
+ * @param {!Object} inplaceEditor
+ * @return {!WebInspector.InplaceEditor.Controller|!Promise.<!WebInspector.InplaceEditor.Controller>}
+ */
+ function startEditing(inplaceEditor)
+ {
+ var controller = /** @type {!WebInspector.InplaceEditor} */ (inplaceEditor).startEditing(element, config);
+ if (!controller)
+ return Promise.rejectWithError("Editing is already in progress");
+ return controller;
+ }
+}
+
WebInspector.InplaceEditor.prototype = {
/**
* @return {string}
@@ -74,7 +101,7 @@ WebInspector.InplaceEditor.prototype = {
/**
* @param {!Element} element
* @param {!WebInspector.InplaceEditor.Config=} config
- * @return {?{cancel: function(), commit: function()}}
+ * @return {?WebInspector.InplaceEditor.Controller}
*/
startEditing: function(element, config)
{
@@ -190,7 +217,8 @@ WebInspector.InplaceEditor.prototype = {
var handle = {
cancel: editingCancelled.bind(element),
- commit: editingCommitted.bind(element)
+ commit: editingCommitted.bind(element),
+ setWidth: function() {}
};
this.augmentEditingHandle(editingContext, handle);
return handle;
@@ -246,6 +274,7 @@ WebInspector.InplaceEditor.Config.prototype = {
*/
setMultilineOptions: function(initialValue, mode, theme, lineWrapping, smartIndent)
{
+ this.multiline = true;
this.initialValue = initialValue;
this.mode = mode;
this.theme = theme;
« no previous file with comments | « Source/devtools/front_end/elements/ElementsTreeOutline.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698