Sometimes I use the Firefox Add-On Textern to edit a tiddler in vim. Textern works like that: Whenever you edit a div or a textarea, you can press a certain shortcut to open the content of that div or textarea in your favorite editor. After saving the temporary file in the editor, all changes show up in your browser.
But there is one problem, when I use Textern in TiddlyWiki: The tiddler content gets updated, but the preview pane doesn’t notice that the text has changed. See Textern issue #60 (no additional link allowed).
How to simply reproduce without this plugin:
- Open https://tiddlywiki.com in your browser.
- Click on the
+
button to create a new tiddler. - Click on the “eye” button to show a preview pane.
- Enter some text in your new tiddler. (The new text should show up in the preview.)
- Open the Web Developer Tools (Firefox) or however this is called in your browser.
- Enter:
var textarea = document.getElementsByTagName('textarea')[0];
textarea.value += 'new text';
new text
will be added to the tiddler but it doesn’t show up in the preview pane. Only after typing in more text, new text
will become visible in the preview pane.
How can I update the preview pane programmatically? I mean like simulating that new text has been typed in. I have tried this, without success:
textarea.onkeypress();
var event = new Event('keydown');
textarea.dispatchEvent(event);
textarea.dispatchEvent(new KeyboardEvent('keypress',{'key': 'a'}))
document.dispatchEvent(new KeyboardEvent('keypress',{'key': 'a'}))
Best regards,
Max