mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2025-12-06 02:30:46 -08:00
Text-slicer: Use xmldom plugin so we can slice under Node.js
This commit is contained in:
parent
68b54a6e6f
commit
c98ef97d23
1 changed files with 12 additions and 6 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue