mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-12 12:59:57 +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 */
|
||||
"use strict";
|
||||
|
||||
var DOMParser = require("$:/plugins/tiddlywiki/xmldom/dom-parser").DOMParser;
|
||||
|
||||
var SLICER_OUTPUT_TITLE = "$:/TextSlicer";
|
||||
|
||||
function Slicer(wiki,sourceTitle) {
|
||||
@ -104,12 +106,16 @@ Slicer.prototype.isBlank = function(s) {
|
||||
};
|
||||
|
||||
Slicer.prototype.getSourceHtmlDocument = function(tiddler) {
|
||||
this.iframe = document.createElement("iframe");
|
||||
document.body.appendChild(this.iframe);
|
||||
this.iframe.contentWindow.document.open();
|
||||
this.iframe.contentWindow.document.write(tiddler.fields.text);
|
||||
this.iframe.contentWindow.document.close();
|
||||
return this.iframe.contentWindow.document;
|
||||
if($tw.browser) {
|
||||
this.iframe = document.createElement("iframe");
|
||||
document.body.appendChild(this.iframe);
|
||||
this.iframe.contentWindow.document.open();
|
||||
this.iframe.contentWindow.document.write(tiddler.fields.text);
|
||||
this.iframe.contentWindow.document.close();
|
||||
return this.iframe.contentWindow.document;
|
||||
} else {
|
||||
return new DOMParser().parseFromString(tiddler.fields.text);
|
||||
}
|
||||
};
|
||||
|
||||
Slicer.prototype.getSourceWikiDocument = function(tiddler) {
|
||||
|
Loading…
Reference in New Issue
Block a user