tzk/tzk/editions/tzk/tiddlers/$__sib_js_excise-private-chunk.js
Soren I. Bjornstad 14cc96a907 check in editions directory
Although this is automatically generated, it represents a critical part
of the content of the edition which cannot be created from the content
in the repository (it's generated from a private directory on my
computer), so at this point it is appropriate to check it in.
2021-09-21 12:27:23 -05:00

40 lines
1.2 KiB
JavaScript

/*\
title: $:/sib/js/excise-private-chunk.js
type: application/javascript
module-type: texteditoroperation
Text editor operation to excise the selection to a new private-chunk tiddler.
SIB 2021-05-21: Copied from the standard excise operation and modified as needed.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports["excisePrivateChunk"] = function(event, operation) {
var editTiddler = this.wiki.getTiddler(this.editTitle),
editTiddlerTitle = this.editTitle;
if(editTiddler && editTiddler.fields["draft.of"]) {
editTiddlerTitle = editTiddler.fields["draft.of"];
}
var excisionTitle = this.wiki.generateNewTitle(editTiddlerTitle + "/p");
this.wiki.addTiddler(new $tw.Tiddler(
this.wiki.getCreationFields(),
this.wiki.getModificationFields(),
{
title: excisionTitle,
text: operation.selection,
tags: "PrivateChunk"
}
));
operation.replacement = "{{" + excisionTitle + "||PrivateChunk}}";
operation.cutStart = operation.selStart;
operation.cutEnd = operation.selEnd;
operation.newSelStart = operation.selStart;
operation.newSelEnd = operation.selStart + operation.replacement.length;
};
})();