mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-28 16:23:15 +00:00
Text-slicer improvements
# Allow the slicer to be used as a command # Sort the document preview column
This commit is contained in:
parent
1d30ee955c
commit
c4244e8f04
|
@ -0,0 +1,8 @@
|
||||||
|
title: $:/language/Help/slice
|
||||||
|
description: Slice a hierarchical document into individual tiddlers
|
||||||
|
|
||||||
|
Slices the specified tiddler
|
||||||
|
|
||||||
|
```
|
||||||
|
--slice <title>
|
||||||
|
```
|
44
plugins/tiddlywiki/text-slicer/modules/commands/slice.js
Normal file
44
plugins/tiddlywiki/text-slicer/modules/commands/slice.js
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/*\
|
||||||
|
title: $:/plugins/tiddlywiki/text-slicer/modules/commands/slice.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: command
|
||||||
|
|
||||||
|
Command to slice a specified tiddler
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var widget = require("$:/core/modules/widgets/widget.js");
|
||||||
|
|
||||||
|
exports.info = {
|
||||||
|
name: "slice",
|
||||||
|
synchronous: true
|
||||||
|
};
|
||||||
|
|
||||||
|
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,
|
||||||
|
tiddlerTitle = this.params[0],
|
||||||
|
slicer = new $tw.Slicer(wiki,tiddlerTitle);
|
||||||
|
slicer.sliceTiddler(tiddlerTitle)
|
||||||
|
slicer.outputTiddlers();
|
||||||
|
slicer.destroy();
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.Command = Command;
|
||||||
|
|
||||||
|
})();
|
|
@ -1,7 +1,7 @@
|
||||||
/*\
|
/*\
|
||||||
title: $:/plugins/tiddlywiki/text-slicer/modules/slicer.js
|
title: $:/plugins/tiddlywiki/text-slicer/modules/slicer.js
|
||||||
type: application/javascript
|
type: application/javascript
|
||||||
module-type: startup
|
module-type: global
|
||||||
|
|
||||||
Setup the root widget event handlers
|
Setup the root widget event handlers
|
||||||
|
|
||||||
|
@ -12,24 +12,8 @@ Setup the root widget event handlers
|
||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Export name and synchronous status
|
|
||||||
exports.name = "slicer";
|
|
||||||
exports.platforms = ["browser"];
|
|
||||||
exports.after = ["startup"];
|
|
||||||
exports.synchronous = true;
|
|
||||||
|
|
||||||
var SLICER_OUTPUT_TITLE = "$:/TextSlicer";
|
var SLICER_OUTPUT_TITLE = "$:/TextSlicer";
|
||||||
|
|
||||||
// Install the root widget event handlers
|
|
||||||
exports.startup = function() {
|
|
||||||
$tw.rootWidget.addEventListener("tm-slice-tiddler",function(event) {
|
|
||||||
var slicer = new Slicer($tw.wiki,event.param);
|
|
||||||
slicer.sliceTiddler(event.param)
|
|
||||||
slicer.outputTiddlers();
|
|
||||||
slicer.destroy();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function Slicer(wiki,sourceTitle) {
|
function Slicer(wiki,sourceTitle) {
|
||||||
this.wiki = wiki;
|
this.wiki = wiki;
|
||||||
this.sourceTitle = sourceTitle;
|
this.sourceTitle = sourceTitle;
|
||||||
|
@ -283,4 +267,6 @@ Slicer.prototype.outputTiddlers_viaImportTiddler = function(tiddlers) {
|
||||||
this.wiki.addTiddler(new $tw.Tiddler(slicerOutputTiddler,newFields));
|
this.wiki.addTiddler(new $tw.Tiddler(slicerOutputTiddler,newFields));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.Slicer = Slicer;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*\
|
||||||
|
title: $:/plugins/tiddlywiki/text-slicer/modules/startup/slicer.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: startup
|
||||||
|
|
||||||
|
Setup the root widget event handlers
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
// Export name and synchronous status
|
||||||
|
exports.name = "slicer";
|
||||||
|
exports.platforms = ["browser"];
|
||||||
|
exports.after = ["startup"];
|
||||||
|
exports.synchronous = true;
|
||||||
|
|
||||||
|
// Install the root widget event handlers
|
||||||
|
exports.startup = function() {
|
||||||
|
$tw.rootWidget.addEventListener("tm-slice-tiddler",function(event) {
|
||||||
|
var slicer = new $tw.Slicer($tw.wiki,event.param);
|
||||||
|
slicer.sliceTiddler(event.param)
|
||||||
|
slicer.outputTiddlers();
|
||||||
|
slicer.destroy();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
|
@ -5,7 +5,7 @@ tags: $:/tags/AboveStory
|
||||||
|
|
||||||
<$set name="tv-default-heading-state" value="closed">
|
<$set name="tv-default-heading-state" value="closed">
|
||||||
|
|
||||||
<$list filter="[toc-type[document]!has[draft.of]]" template="$:/plugins/tiddlywiki/text-slicer/templates/interactive/document"/>
|
<$list filter="[toc-type[document]!has[draft.of]sort[title]]" template="$:/plugins/tiddlywiki/text-slicer/templates/interactive/document"/>
|
||||||
|
|
||||||
</$set>
|
</$set>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user