-
In most cases, this problem is caused by the fakedom of tiddlywiki. I have encountered the same problem several times before. The general reason is that the virtual dom created by the widget appears in an abnormal place, such as the Sidebar Title. The previous solution was Use window.document instead of fakedom. I ran into this problem again today with cm6 widget, I tried using window.document instead of `this.widget.document.createElement('div'), but it still didn't work. so I will temporarily add a try catch for this cm6 widget. In the CM6 editor, enter [[Getting_]] and a floating preview of the rendered GettingStarted Tiddler will appear. This GettingStarted tiddler uses the Are there any issues that need to be paid attention to with this kind of widget that appears in non-story rivers or in regular locations? @Jermolene |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 5 replies
-
Hi @oeyoews I don't understand why the CM6 widget is being rendered to the fakedom in the example in your illustration. The fakedom is used for rendering in fairly limited circumstances:
It can be useful to explicitly check for the fakedom with |
Beta Was this translation helpful? Give feedback.
-
Hi @oeyoews can you break on that TW_Element.appendChild element and then scroll up the call tree to find the original root |
Beta Was this translation helpful? Give feedback.
-
If the tiddler rendered using This also happens at https://tiddlywiki.com/edition/full. @Jermolene |
Beta Was this translation helpful? Give feedback.
-
Hi @oeyoews what preview mode are you using? Things like the "parse tree" and "widget tree" view are rendered using the wikify widget and so will use the fake dom for rendering. |
Beta Was this translation helpful? Give feedback.
-
const previewNode = $tw.wiki.renderTiddler('text/html', title);
const preview = document.createElement('div');
preview.innerHTML = previewNode; I use this method for preview. I have tried rendering other widgets, such as widget, no errors will occur. Only this |
Beta Was this translation helpful? Give feedback.
-
Just add a try catch in |
Beta Was this translation helpful? Give feedback.
-
I found that if I use the $index parameter of transclude, tw will automatically handle the error and return an empty |
Beta Was this translation helpful? Give feedback.
-
previewHTML = $tw.wiki.renderText(
'text/html',
'text/vnd.tiddlywiki',
`<$transclude $tiddler=${title} $mode=block />`
); $index should be the order of the fields. It seems thatonly need to use transclude. |
Beta Was this translation helpful? Give feedback.
-
I think I have figured out the relationship between $index and $field param. Unfortunately, I still have to manually add try catch last. |
Beta Was this translation helpful? Give feedback.
-
Hi @oeyoews that try/catch should not be necessary, and it would be good if we could track down what's going on. As I said before, I think the answer will be that your widget needs to check explicitly for the fake dom. |
Beta Was this translation helpful? Give feedback.
Hi @oeyoews the core edit widgets all include specific code to check for the fake dom. Perhaps you need to do the same, and only execute some code if you're running against the real dom.