Making a new text operation make-transclusion

Folks,

I have attempted to clone the tiddler $:/core/modules/editor/operations/text/make-link.js to create a new editor operation to put in a modified version of the editor toolbar button $:/core/ui/EditorToolbar/link new tiddler attached, named $:/PSaT/EditorToolbar/transclude.

The following is the new module-type texteditoroperation
make-transclusion-editor-toolbar-button.json (5.8 KB)

/*\
$:/PSaT/EditorToolbar/transclude/make-transclusion.js
type: application/javascript
module-type: texteditoroperation

Text editor operation to make a transclusion

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

exports["make-transclusion"] = 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;
};

})();
  • Note how I changed [[ toi {{, | to || and ]] to }} in two places.
  • Despite save and reload it is not working

Anyone with javascript experience may be able to tell me if this is valid syntax?

  • To I need to escape these characters?, and how would I?

People with TiddlyWiki core knowledge may be able to tell me;

  • Are there any other necessary changes to make this work?

Thank in Advance.

[Edited] Because this Editor Toolbar button needs both the selection and the found title to transform the result I believe it can’t be done using other actions, thus the original texteditoroperation $:/core/modules/editor/operations/text/make-link.js was created.