[tw5] Re: Editing Drafts from JavaScript
Thank you. Much appreciated. Pekka On Friday, September 17, 2021 at 12:20:21 PM UTC+3 PMario wrote: > On Friday, September 17, 2021 at 11:11:40 AM UTC+2 Pekka wrote: > > Now I was able to create a function that operates "inside" >> tm-edit-text-operation. I suppose it would similarly be possible to react >> to custom created messages as well, e.g. tm-user-specified-message? >> > > Yes. The mechanism is the same and since the parameters in the > button-config tiddlers are dynamic you can send as much info to the event > as you like. > It's a super powerful mechanism and very flexible to extend once you > "got" the concept. > > -m > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/9bb0e322-c9e3-4e79-8649-9a9909d992d8n%40googlegroups.com.
[tw5] Re: Editing Drafts from JavaScript
On Friday, September 17, 2021 at 11:11:40 AM UTC+2 Pekka wrote: Now I was able to create a function that operates "inside" > tm-edit-text-operation. I suppose it would similarly be possible to react > to custom created messages as well, e.g. tm-user-specified-message? > Yes. The mechanism is the same and since the parameters in the button-config tiddlers are dynamic you can send as much info to the event as you like. It's a super powerful mechanism and very flexible to extend once you "got" the concept. -m -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/7e66f2a0-f5ed-4c57-9b0b-b62405cc5236n%40googlegroups.com.
[tw5] Re: Editing Drafts from JavaScript
Thanks a lot! It was enough and I got the idea. I'm now able to achieve what I want. I did not know one could so easily create own functions that react to sendmessage. I was afraid I would have to modify the core and create own event listeners etc. which is currently out of my abilities. Now I was able to create a function that operates "inside" tm-edit-text-operation. I suppose it would similarly be possible to react to custom created messages as well, e.g. tm-user-specified-message? Pekka On Friday, September 17, 2021 at 10:20:33 AM UTC+3 PMario wrote: > The prerelease contains a new HowTo: > https://tiddlywiki.com/prerelease/#How%20to%20create%20dynamic%20editor%20toolbar%20buttons > > which shows how to create new toolbar buttons. ... The messages used by > those buttons are created with module-type: texteditoroperation JS function. > > -mario > > > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/6744aa3c-fdd4-4fcd-8533-8d7cc34dc68an%40googlegroups.com.
[tw5] Re: Editing Drafts from JavaScript
The prerelease contains a new HowTo: https://tiddlywiki.com/prerelease/#How%20to%20create%20dynamic%20editor%20toolbar%20buttons which shows how to create new toolbar buttons. ... The messages used by those buttons are created with module-type: texteditoroperation JS function. -mario -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/4e9b6a20-a8bc-421d-9912-ef2a7039e6a2n%40googlegroups.com.
[tw5] Re: Editing Drafts from JavaScript
On Friday, September 17, 2021 at 9:15:34 AM UTC+2 PMario wrote: ... > IMO that will get you started. ... If it doesn't let us know. .. It's > relatively easy to extend those functions, .. once you see the concept. > The core concept is modular and can be extended with your own "toolbar button parameters" ... Let me know, if this was enough info. -mario -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/f2c2f036-b742-4e78-bea9-7f9599db2dcbn%40googlegroups.com.
[tw5] Re: Editing Drafts from JavaScript
Hi Pekka, If you search the TW source for "module-type: texteditoroperation" .. you will find 9 text operator functions. They are all part of the $:/core/modules/editor/operations/text/ namespace. If you start with an easy one: $:/core/modules/editor/operations/text/insert-text.js you'll see it exports "insert-text" If you search for "insert-text" in the .tid files. you'll find: https://tiddlywiki.com/#WidgetMessage%3A%20tm-edit-text-operation ... Then have a look at the more powerful ones. eg: wrap lines, wrap selections Then: excise and prefix-lines IMO that will get you started. ... If it doesn't let us know. .. It's relatively easy to extend those functions, .. once you see the concept. -mario -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/3cca92a6-6e01-4b7c-b58d-39399f112a68n%40googlegroups.com.
[tw5] Re: Editing Drafts from JavaScript
Hi Mark, Thanks for the reply. I did not explain my goals properly. I would basically like to create a new EditorToolbar button similar to bold, italic etc. but with custom functionality. I have successfully created buttons that can edit the text in normal Tiddlers but I cannot do the same when the Tiddler is in draft mode. Would there be an easy way to do this? I have added a picture to help illustrate my goal. Just as an example, what I could do is that when the circled button is pressed, the text before " xx " would be a new field, the text after it would become the field content. The text would then be removed from the text area. All this should happen while the Tiddler is in draft mode. Hope this clarifies my goals. Thanks! Pekka On Thursday, September 16, 2021 at 7:23:59 PM UTC+3 Mark S. wrote: > It sounds like you would like to edit javascript in a mode similar to a > code editor. > > You can use the code mirror plugin and the javascript for codemirror > plugin to edit javascript text. > > You can get the plugins from the stand-alone TW by going to > > control panel (cog wheel) --> plugins (tab) --> official plugins (button) > > Search for codemirror and javascript . > > On Wednesday, September 15, 2021 at 11:46:54 PM UTC-7 Pekka wrote: > >> How can Drafts be edited with JavaScript? >> >> I would like to parse the text in a draft according to more complicated >> rules than what is currently possible with existing widgets, e.g. >> tm-edit-text-operation. >> >> I have tried *this.wiki.setText(...)*, but it doesn't work. >> >> What would be the easiest way to change the text field in a Draft Tiddler >> according to arbitrary rules? >> >> >> Pekka >> > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/520780e9-606f-4900-ba60-831c4c4ebd6fn%40googlegroups.com.
[tw5] Re: Editing Drafts from JavaScript
It sounds like you would like to edit javascript in a mode similar to a code editor. You can use the code mirror plugin and the javascript for codemirror plugin to edit javascript text. You can get the plugins from the stand-alone TW by going to control panel (cog wheel) --> plugins (tab) --> official plugins (button) Search for codemirror and javascript . On Wednesday, September 15, 2021 at 11:46:54 PM UTC-7 Pekka wrote: > How can Drafts be edited with JavaScript? > > I would like to parse the text in a draft according to more complicated > rules than what is currently possible with existing widgets, e.g. > tm-edit-text-operation. > > I have tried *this.wiki.setText(...)*, but it doesn't work. > > What would be the easiest way to change the text field in a Draft Tiddler > according to arbitrary rules? > > > Pekka > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/46a11133-5932-4dc6-99f6-fc40522239b7n%40googlegroups.com.