2015-09-15 12:37:12 +00:00
|
|
|
/*\
|
|
|
|
title: $:/plugins/tiddlywiki/text-slicer/modules/slicers/list.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: slicer
|
|
|
|
|
2015-09-16 17:59:03 +00:00
|
|
|
Handle slicing list nodes
|
2015-09-15 12:37:12 +00:00
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
exports.processListNode = function(domNode,tagName) {
|
2015-09-17 07:41:21 +00:00
|
|
|
if(domNode.nodeType === 1 && (tagName === "ul" || tagName === "ol")) {
|
2015-09-15 12:37:12 +00:00
|
|
|
var title = this.makeUniqueTitle("list-" + tagName),
|
|
|
|
parentTitle = this.parentStack[this.parentStack.length - 1].title,
|
|
|
|
tags = [];
|
2016-02-01 21:22:55 +00:00
|
|
|
if(domNode.className && domNode.className.trim() !== "") {
|
2015-09-15 12:37:12 +00:00
|
|
|
tags = tags.concat(domNode.className.split(" "));
|
|
|
|
}
|
|
|
|
this.addToList(parentTitle,title);
|
|
|
|
this.parentStack.push({type: tagName, title: this.addTiddler({
|
|
|
|
"toc-type": "list",
|
|
|
|
"toc-list-type": tagName,
|
|
|
|
"toc-list-filter": "[list<currentTiddler>!has[draft.of]]",
|
|
|
|
text: "",
|
|
|
|
title: title,
|
|
|
|
list: [],
|
|
|
|
tags: tags
|
|
|
|
})});
|
2015-09-16 17:59:03 +00:00
|
|
|
this.currentTiddler = title;
|
2015-09-15 12:37:12 +00:00
|
|
|
this.processNodeList(domNode.childNodes);
|
|
|
|
this.parentStack.pop();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|