mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-03 20:59:09 +00:00
Report ZoomIn issues when using tiddler template that starts with a text node (#7007)
* add alert when zoomin error occurs plus protection to avoid TW getting stuck when it happens * Reverted additional logging and made the zoomin just silently and safely ignore the issue
This commit is contained in:
parent
5bce35d90b
commit
3a9f848ea0
@ -40,6 +40,7 @@ Error/RetrievingSkinny: Error retrieving skinny tiddler list
|
||||
Error/SavingToTWEdit: Error saving to TWEdit
|
||||
Error/WhileSaving: Error while saving
|
||||
Error/XMLHttpRequest: XMLHttpRequest error code
|
||||
Error/ZoominTextNode: Story View Error: It appears you tried to interact with a tiddler that displays in a custom container. This is most likely caused by using `$:/tags/StoryTiddlerTemplateFilter` with a template that contains text or whitespace at the start. Please use the pragma `\whitespace trim` and ensure the whole contents of the tiddler is wrapped in a single HTML element. The text that caused this issue:
|
||||
InternalJavaScriptError/Title: Internal JavaScript Error
|
||||
InternalJavaScriptError/Hint: Well, this is embarrassing. It is recommended that you restart TiddlyWiki by refreshing your browser
|
||||
LayoutSwitcher/Description: Open the layout switcher
|
||||
|
@ -17,6 +17,10 @@ var easing = "cubic-bezier(0.645, 0.045, 0.355, 1)"; // From http://easings.net/
|
||||
var ZoominListView = function(listWidget) {
|
||||
var self = this;
|
||||
this.listWidget = listWidget;
|
||||
this.textNodeLogger = new $tw.utils.Logger("zoomin story river view", {
|
||||
enable: true,
|
||||
colour: 'red'
|
||||
});
|
||||
// Get the index of the tiddler that is at the top of the history
|
||||
var history = this.listWidget.wiki.getTiddlerDataCached(this.listWidget.historyTitle,[]),
|
||||
targetTiddler;
|
||||
@ -48,7 +52,10 @@ ZoominListView.prototype.navigateTo = function(historyInfo) {
|
||||
var listItemWidget = this.listWidget.children[listElementIndex],
|
||||
targetElement = listItemWidget.findFirstDomNode();
|
||||
// Abandon if the list entry isn't a DOM element (it might be a text node)
|
||||
if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) {
|
||||
if(!targetElement) {
|
||||
return;
|
||||
} else if (targetElement.nodeType === Node.TEXT_NODE) {
|
||||
this.logTextNodeRoot(targetElement);
|
||||
return;
|
||||
}
|
||||
// Make the new tiddler be position absolute and visible so that we can measure it
|
||||
@ -130,7 +137,10 @@ function findTitleDomNode(widget,targetClass) {
|
||||
ZoominListView.prototype.insert = function(widget) {
|
||||
var targetElement = widget.findFirstDomNode();
|
||||
// Abandon if the list entry isn't a DOM element (it might be a text node)
|
||||
if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) {
|
||||
if(!targetElement) {
|
||||
return;
|
||||
} else if (targetElement.nodeType === Node.TEXT_NODE) {
|
||||
this.logTextNodeRoot(targetElement);
|
||||
return;
|
||||
}
|
||||
// Make the newly inserted node position absolute and hidden
|
||||
@ -173,16 +183,21 @@ ZoominListView.prototype.remove = function(widget) {
|
||||
var toWidgetDomNode = toWidget && toWidget.findFirstDomNode();
|
||||
// Set up the tiddler we're moving back in
|
||||
if(toWidgetDomNode) {
|
||||
$tw.utils.addClass(toWidgetDomNode,"tc-storyview-zoomin-tiddler");
|
||||
$tw.utils.setStyle(toWidgetDomNode,[
|
||||
{display: "block"},
|
||||
{transformOrigin: "50% 50%"},
|
||||
{transform: "translateX(0px) translateY(0px) scale(10)"},
|
||||
{transition: $tw.utils.roundTripPropertyName("transform") + " " + duration + "ms " + easing + ", opacity " + duration + "ms " + easing},
|
||||
{opacity: "0"},
|
||||
{zIndex: "500"}
|
||||
]);
|
||||
this.currentTiddlerDomNode = toWidgetDomNode;
|
||||
if (toWidgetDomNode.nodeType === Node.TEXT_NODE) {
|
||||
this.logTextNodeRoot(toWidgetDomNode);
|
||||
toWidgetDomNode = null;
|
||||
} else {
|
||||
$tw.utils.addClass(toWidgetDomNode,"tc-storyview-zoomin-tiddler");
|
||||
$tw.utils.setStyle(toWidgetDomNode,[
|
||||
{display: "block"},
|
||||
{transformOrigin: "50% 50%"},
|
||||
{transform: "translateX(0px) translateY(0px) scale(10)"},
|
||||
{transition: $tw.utils.roundTripPropertyName("transform") + " " + duration + "ms " + easing + ", opacity " + duration + "ms " + easing},
|
||||
{opacity: "0"},
|
||||
{zIndex: "500"}
|
||||
]);
|
||||
this.currentTiddlerDomNode = toWidgetDomNode;
|
||||
}
|
||||
}
|
||||
// Animate them both
|
||||
// Force layout
|
||||
@ -206,6 +221,10 @@ ZoominListView.prototype.remove = function(widget) {
|
||||
return true; // Indicate that we'll delete the DOM node
|
||||
};
|
||||
|
||||
ZoominListView.prototype.logTextNodeRoot = function(node) {
|
||||
this.textNodeLogger.log($tw.language.getString("Error/ZoominTextNode") + " " + node.textContent);
|
||||
};
|
||||
|
||||
exports.zoomin = ZoominListView;
|
||||
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user