1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 01:20:30 +00:00

Dynannotate: Don't crash when used in the fake DOM

Fixes #7258
This commit is contained in:
jeremy@jermolene.com 2023-02-10 09:00:52 +00:00
parent 3da3318396
commit 81f5141166

View File

@ -38,23 +38,28 @@ DynannotateWidget.prototype.render = function(parent,nextSibling) {
// Create our DOM nodes // Create our DOM nodes
var isSnippetMode = this.isSnippetMode(); var isSnippetMode = this.isSnippetMode();
this.domContent = $tw.utils.domMaker("div",{ this.domContent = $tw.utils.domMaker("div",{
"class": "tc-dynannotation-selection-container" "class": "tc-dynannotation-selection-container",
document: this.document
}); });
if(isSnippetMode) { if(isSnippetMode) {
this.domContent.setAttribute("hidden","hidden"); this.domContent.setAttribute("hidden","hidden");
} }
this.domAnnotations = $tw.utils.domMaker("div",{ this.domAnnotations = $tw.utils.domMaker("div",{
"class": "tc-dynannotation-annotation-wrapper" "class": "tc-dynannotation-annotation-wrapper",
document: this.document
}); });
this.domSnippets = $tw.utils.domMaker("div",{ this.domSnippets = $tw.utils.domMaker("div",{
"class": "tc-dynannotation-snippet-wrapper" "class": "tc-dynannotation-snippet-wrapper",
document: this.document
}); });
this.domSearches = $tw.utils.domMaker("div",{ this.domSearches = $tw.utils.domMaker("div",{
"class": "tc-dynannotation-search-wrapper" "class": "tc-dynannotation-search-wrapper",
document: this.document
}); });
this.domWrapper = $tw.utils.domMaker("div",{ this.domWrapper = $tw.utils.domMaker("div",{
"class": "tc-dynannotation-wrapper", "class": "tc-dynannotation-wrapper",
children: [this.domContent,this.domAnnotations,this.domSnippets,this.domSearches] children: [this.domContent,this.domAnnotations,this.domSnippets,this.domSearches],
document: this.document
}) })
parent.insertBefore(this.domWrapper,nextSibling); parent.insertBefore(this.domWrapper,nextSibling);
this.domNodes.push(this.domWrapper); this.domNodes.push(this.domWrapper);
@ -64,16 +69,18 @@ DynannotateWidget.prototype.render = function(parent,nextSibling) {
} }
// Render our child widgets // Render our child widgets
this.renderChildren(this.domContent,null); this.renderChildren(this.domContent,null);
if(isSnippetMode) { if(!this.document.isTiddlyWikiFakeDom) {
// Apply search snippets if(isSnippetMode) {
this.applySnippets(); // Apply search snippets
} else { this.applySnippets();
// Get the list of annotation tiddlers } else {
this.getAnnotationTiddlers(); // Get the list of annotation tiddlers
// Apply annotations this.getAnnotationTiddlers();
this.applyAnnotations(); // Apply annotations
// Apply search overlays this.applyAnnotations();
this.applySearch(); // Apply search overlays
this.applySearch();
}
} }
// Save the width of the wrapper so that we can tell when it changes // Save the width of the wrapper so that we can tell when it changes
this.wrapperWidth = this.domWrapper.offsetWidth; this.wrapperWidth = this.domWrapper.offsetWidth;