mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Text-slicer: Use xmldom plugin so we can slice under Node.js
This commit is contained in:
parent
68b54a6e6f
commit
c98ef97d23
@ -12,6 +12,8 @@ Main text-slicing logic
|
|||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var DOMParser = require("$:/plugins/tiddlywiki/xmldom/dom-parser").DOMParser;
|
||||||
|
|
||||||
var SLICER_OUTPUT_TITLE = "$:/TextSlicer";
|
var SLICER_OUTPUT_TITLE = "$:/TextSlicer";
|
||||||
|
|
||||||
function Slicer(wiki,sourceTitle) {
|
function Slicer(wiki,sourceTitle) {
|
||||||
@ -104,12 +106,16 @@ Slicer.prototype.isBlank = function(s) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Slicer.prototype.getSourceHtmlDocument = function(tiddler) {
|
Slicer.prototype.getSourceHtmlDocument = function(tiddler) {
|
||||||
this.iframe = document.createElement("iframe");
|
if($tw.browser) {
|
||||||
document.body.appendChild(this.iframe);
|
this.iframe = document.createElement("iframe");
|
||||||
this.iframe.contentWindow.document.open();
|
document.body.appendChild(this.iframe);
|
||||||
this.iframe.contentWindow.document.write(tiddler.fields.text);
|
this.iframe.contentWindow.document.open();
|
||||||
this.iframe.contentWindow.document.close();
|
this.iframe.contentWindow.document.write(tiddler.fields.text);
|
||||||
return this.iframe.contentWindow.document;
|
this.iframe.contentWindow.document.close();
|
||||||
|
return this.iframe.contentWindow.document;
|
||||||
|
} else {
|
||||||
|
return new DOMParser().parseFromString(tiddler.fields.text);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Slicer.prototype.getSourceWikiDocument = function(tiddler) {
|
Slicer.prototype.getSourceWikiDocument = function(tiddler) {
|
||||||
|
Loading…
Reference in New Issue
Block a user