1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-20 02:44:23 +00:00
TiddlyWiki5/core/modules/editor/operations/text/make-link.js

30 lines
801 B
JavaScript
Raw Normal View History

/*\
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;
};
})();