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

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

Issue 2372663004: DevTools: Replace multiline InplaceEditor with CodeMirrorTextEditor (Closed)
Patch Set: Created 4 years, 3 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
Index: third_party/WebKit/Source/devtools/front_end/ui/InplaceEditor.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/InplaceEditor.js b/third_party/WebKit/Source/devtools/front_end/ui/InplaceEditor.js
index 4e5edea77088178d21ba36e5c5e2c267efc34d6e..9a0cf68a0deaed4891994673f2ca352ddb1e9753 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/InplaceEditor.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/InplaceEditor.js
@@ -10,7 +10,7 @@ WebInspector.InplaceEditor = function()
}
/**
- * @typedef {{cancel: function(), commit: function(), setWidth: function(number)}}
+ * @typedef {{cancel: function(), commit: function()}}
*/
WebInspector.InplaceEditor.Controller;
@@ -26,28 +26,6 @@ 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.extension(WebInspector.InplaceEditor).instance().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.reject(new Error("Editing is already in progress"));
- return controller;
- }
-}
-
WebInspector.InplaceEditor.prototype = {
/**
* @return {string}
@@ -114,7 +92,6 @@ WebInspector.InplaceEditor.prototype = {
var cancelledCallback = config.cancelHandler;
var pasteCallback = config.pasteHandler;
var context = config.context;
- var isMultiline = config.multiline || false;
var moveDirection = "";
var self = this;
@@ -128,7 +105,7 @@ WebInspector.InplaceEditor.prototype = {
this.setUpEditor(editingContext);
- editingContext.oldText = isMultiline ? config.initialValue : this.editorContent(editingContext);
+ editingContext.oldText = this.editorContent(editingContext);
/**
* @param {!Event=} e
@@ -136,15 +113,14 @@ WebInspector.InplaceEditor.prototype = {
function blurEventListener(e) {
if (config.blurHandler && !config.blurHandler(element, e))
return;
- if (!isMultiline || !e || !e.relatedTarget || !e.relatedTarget.isSelfOrDescendant(element))
- editingCommitted.call(element);
+ editingCommitted.call(element);
}
function cleanUpAfterEditing()
{
WebInspector.markBeingEdited(element, false);
- element.removeEventListener("blur", blurEventListener, isMultiline);
+ element.removeEventListener("blur", blurEventListener, false);
element.removeEventListener("keydown", keyDownEventListener, true);
if (pasteCallback)
element.removeEventListener("paste", pasteEventListener, true);
@@ -178,11 +154,11 @@ WebInspector.InplaceEditor.prototype = {
var isMetaOrCtrl = WebInspector.isMac() ?
event.metaKey && !event.shiftKey && !event.ctrlKey && !event.altKey :
event.ctrlKey && !event.shiftKey && !event.metaKey && !event.altKey;
- if (isEnterKey(event) && (event.isMetaOrCtrlForTest || !isMultiline || isMetaOrCtrl))
+ if (isEnterKey(event))
return "commit";
else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.code || event.key === "Escape")
return "cancel";
- else if (!isMultiline && event.key === "Tab")
+ else if (event.key === "Tab")
return "move-" + (event.shiftKey ? "backward" : "forward");
return "";
}
@@ -222,15 +198,14 @@ WebInspector.InplaceEditor.prototype = {
handleEditingResult(result, event);
}
- element.addEventListener("blur", blurEventListener, isMultiline);
+ element.addEventListener("blur", blurEventListener, false);
element.addEventListener("keydown", keyDownEventListener, true);
if (pasteCallback)
element.addEventListener("paste", pasteEventListener, true);
var handle = {
cancel: editingCancelled.bind(element),
- commit: editingCommitted.bind(element),
- setWidth: function() {}
+ commit: editingCommitted.bind(element)
};
this.augmentEditingHandle(editingContext, handle);
return handle;
@@ -258,11 +233,6 @@ WebInspector.InplaceEditor.Config = function(commitHandler, cancelHandler, conte
this.pasteHandler;
/**
- * @type {boolean|undefined}
- */
- this.multiline;
-
- /**
* @type {function(!Event):string|undefined}
*/
this.postKeydownFinishHandler;
@@ -275,23 +245,6 @@ WebInspector.InplaceEditor.Config.prototype = {
},
/**
- * @param {string} initialValue
- * @param {!Object} mode
- * @param {string} theme
- * @param {boolean=} lineWrapping
- * @param {boolean=} smartIndent
- */
- setMultilineOptions: function(initialValue, mode, theme, lineWrapping, smartIndent)
- {
- this.multiline = true;
- this.initialValue = initialValue;
- this.mode = mode;
- this.theme = theme;
- this.lineWrapping = lineWrapping;
- this.smartIndent = smartIndent;
- },
-
- /**
* @param {function(!Event):string} postKeydownFinishHandler
*/
setPostKeydownFinishHandler: function(postKeydownFinishHandler)

Powered by Google App Engine
This is Rietveld 408576698