From bef3242075b6d962b7963b9c9c7042c39198fc8f Mon Sep 17 00:00:00 2001 From: Jermolene Date: Fri, 29 Jun 2018 15:09:51 +0100 Subject: [PATCH] New text editor operation: save selection to a tiddler --- .../editor/operations/text/save-selection.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 core/modules/editor/operations/text/save-selection.js diff --git a/core/modules/editor/operations/text/save-selection.js b/core/modules/editor/operations/text/save-selection.js new file mode 100644 index 000000000..484e6ff3c --- /dev/null +++ b/core/modules/editor/operations/text/save-selection.js @@ -0,0 +1,23 @@ +/*\ +title: $:/core/modules/editor/operations/text/save-selection.js +type: application/javascript +module-type: texteditoroperation + +Text editor operation to save the current selection in a specified tiddler + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports["save-selection"] = function(event,operation) { + var tiddler = event.paramObject.tiddler, + field = event.paramObject.field || "text"; + if(tiddler && field) { + this.wiki.setText(tiddler,field,null,operation.text.substring(operation.selStart,operation.selEnd)); + } +}; + +})();