mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2026-03-14 18:51:28 -07:00
* fix: apply automatic eslint fixes * lint: allow hashbang comment for tiddlywiki.js * lint: first back of manual lint fixes for unused vars * lint: added more fixes for unused vars * lint: missed files * lint: updated eslint config with selected rules from #9669
52 lines
1.1 KiB
JavaScript
52 lines
1.1 KiB
JavaScript
/*\
|
|
title: $:/plugins/tiddlywiki/text-slicer/modules/commands/slice.js
|
|
type: application/javascript
|
|
module-type: command
|
|
|
|
Command to slice a specified tiddler
|
|
|
|
\*/
|
|
|
|
"use strict";
|
|
|
|
var textSlicer = require("$:/plugins/tiddlywiki/text-slicer/modules/slicer.js");
|
|
|
|
exports.info = {
|
|
name: "slice",
|
|
synchronous: false
|
|
};
|
|
|
|
var Command = function(params,commander,callback) {
|
|
this.params = params;
|
|
this.commander = commander;
|
|
this.callback = callback;
|
|
};
|
|
|
|
Command.prototype.execute = function() {
|
|
if(this.params.length < 1) {
|
|
return "Missing parameters";
|
|
}
|
|
var self = this,
|
|
wiki = this.commander.wiki,
|
|
sourceTitle = this.params[0],
|
|
destTitle = this.params[1],
|
|
slicerRules = this.params[2],
|
|
outputMode = this.params[3];
|
|
new textSlicer.Slicer({
|
|
sourceTiddlerTitle: sourceTitle,
|
|
baseTiddlerTitle: destTitle,
|
|
slicerRules: slicerRules,
|
|
outputMode: outputMode,
|
|
wiki: wiki,
|
|
callback: function(err,tiddlers) {
|
|
if(err) {
|
|
return self.callback(err);
|
|
}
|
|
wiki.addTiddlers(tiddlers);
|
|
self.callback();
|
|
}
|
|
});
|
|
return null;
|
|
};
|
|
|
|
exports.Command = Command;
|