1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-08 13:04:21 +00:00
TiddlyWiki5/core/modules/editor/operations/text/make-link.js
Jermolene 7224fea961 Introduce "link" editor toolbar button
As proposed by Alex Hough
2016-04-29 18:54:44 +01:00

30 lines
801 B
JavaScript

/*\
title: $:/core/modules/editor/operations/text/make-link.js
type: application/javascript
module-type: texteditoroperation
Text editor operation to make a link
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports["make-link"] = function(event,operation) {
if(operation.selection) {
operation.replacement = "[[" + operation.selection + "|" + event.paramObject.text + "]]";
operation.cutStart = operation.selStart;
operation.cutEnd = operation.selEnd;
} else {
operation.replacement = "[[" + event.paramObject.text + "]]";
operation.cutStart = operation.selStart;
operation.cutEnd = operation.selEnd;
}
operation.newSelStart = operation.selStart + operation.replacement.length;
operation.newSelEnd = operation.newSelStart;
};
})();