Re: [twdev] Re: ANN: widget tutorial

2019-02-22 Thread Brian Theado
More progress. I wrote the child widget tutorial with lots of parse tree
and widget tree examples.  See
https://btheado.github.io/tw-widget-tutorial/#Child%20widgets%20tutorial.
Best viewed with a wider screen and with the sidebar hidden.

On Sun, Feb 17, 2019 at 9:21 AM Brian Theado  wrote:

> I have been making slow progress with this.
>
> I wrote additional sections:
>
> Widget attributes tutorial part II
> 3rd party library tutorial part I
> 3rd party library tutorial part II
>
> I also improved some of the examples of the previous sections.
>
> I still haven't written about child widgets. I also haven't covered the
> difficult topic of how to get the 3rd party library code suitable for
> loading into Tiddlywiki. I plan to add a few examples from my experience,
> but it won't be comprehensive as it is a large topic.
>
> See the update at https://btheado.github.io/tw-widget-tutorial/
>
> Stefano,
>
> > great work and greatly needed. Can't wait to read the 3rd party library
> tutorial!
>
> I would guess based on your other threads that you are already past the
> point where the 3rd party library tutorials would help you. Also based on
> those threads, I doubt what I've written so far would have helped you much.
> One difficulty you faced was how to get 3rd party code suitable for loading
> and I haven't written anything on that yet. Another difficulty was related
> to arranging files on the file system such that node.js would pick them up
> as plugins. This topic I don't plan to cover at all as I see that topic
> being orthogonal to writing widget code.
>
> Brian
>
> On Sun, Feb 3, 2019 at 11:14 PM stefano franchi 
> wrote:
>
>> Brian,
>>
>> great work and greatly needed. Can't wait to read the 3rd party library
>> tutorial!
>>
>> Cheers,
>> Stefano
>>
>> On Sun, Feb 3, 2019 at 9:35 PM Brian Theado 
>> wrote:
>>
>>> Tony and Mohammad, thanks for the feedback.
>>>
>>> I just added "Widget attributes tutorial part I".
>>>
>>> So now these sections are written:
>>>
>>> Undefined widget tutorial
>>> Do nothing widget tutorial
>>> Hello World widget tutorial
>>> Widget refresh tutorial part I
>>> Widget refresh tutorial part II
>>> Widget refresh tutorial part III
>>> Widget attributes tutorial part I
>>>
>>>
>>> With these still left to write:
>>>
>>> Widget attributes tutorial part II
>>> 3rd party library tutorial part I
>>> 3rd party library tutorial part II
>>> Child widgets tutorial
>>>
>>>
>>> Brian
>>>
>>> On Sun, Feb 3, 2019 at 8:14 AM Brian Theado 
>>> wrote:
>>>
 I have a work in progress tutorial for writing TW widgets at
 https://btheado.github.io/tw-widget-tutorial/. It starts with the
 simplest widget I could think of and builds from there. I will be adding
 more over the coming days and weeks.

 It uses the innerwiki plugin to provide an interactive playground for
 the javascript code. In fact I developed it all using a single file
 tiddlywiki. The immediate feedback provided by the innerwiki widget was
 most helpful.

 Any feedback appreciated, especially if I've misrepresented anything.

 Brian

>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "TiddlyWikiDev" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to tiddlywikidev+unsubscr...@googlegroups.com.
>>> To post to this group, send email to tiddlywikidev@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/tiddlywikidev.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/tiddlywikidev/CAO5X8CzUa3%3D50x2fFUW-EvMPzmUsDsrPW98ESLigEFp8zT8YmA%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> __
>> Stefano Franchi
>>
>> stefano.fran...@gmail.com 
>> http://stefano.cleinias.org
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "TiddlyWikiDev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to tiddlywikidev+unsubscr...@googlegroups.com.
>> To post to this group, send email to tiddlywikidev@googlegroups.com.
>> Visit this group at https://groups.google.com/group/tiddlywikidev.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/tiddlywikidev/CAJODLwZ3RqwhEvEZc%2BMx%3DPpKP6h19Z%3D_Ve%3D6-2pY4zsF4RmrfA%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop 

Re: [twdev] Re: Help with saving a widget's tiddler content from external library code

2019-02-22 Thread Simon Huber

>
> The easiest way of doing all this would be using the way the codemirror 
engine does it (have a look at tiddlywiki.com/prerelease and look at 
$:/plugins/tiddlywiki/codemirror/edit-codemirror.js)

* clone the edit-codemirror.js tiddler, make it export edit-sftype (for 
example)
* it will be used when you have a editor type mapping 
($:/config/EditorTypeMappings/application/sftype) that contains sftype (in 
its text field ... if you export edit-sftype ... if you export 
edit-myengine, put myengine inside) ... that will automatically call the 
edit-sftype widget (or the edit-myengine widget), when editing a tiddler 
with type application/sftype
* then the basic handling is done by factory.js
* and you create your engine javascript tiddler with the title you defined 
above (your clone of edit-codemirror.js)
* for the content of your engine you can use 
$:/core/modules/editor/engines/simple.js as the easiest template to build 
on top , and you can have a look at the codemirror engine how it 
incorporates the codemirror library (probably too complicated for your case)

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywikidev+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywikidev@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/7b910a8f-413b-46f3-bd06-8875520578a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [twdev] Re: Help with saving a widget's tiddler content from external library code

2019-02-22 Thread Simon Huber

>
>
> On Fri, Feb 22, 2019 at 2:20 PM Simon Huber  > wrote:
>
>> I am having some trouble understanding how to update the text and other 
>>> fields of a tiddler my  widget editor works on. 
>>>
>>> I am at the point where the editor is holding 
>>> (1) editor.widget, a ref to the widget it was called from and 
>>> (2) fieldUpdates,  an object with field/value pairs  for all the 
>>> tiddler's fields I want to update. My problem is which function to use to 
>>> get the task done.
>>>
>>
>> If you're editing a tiddler with your editor and you want its title, the 
>> widget calling your editor must have it (...) ?
>>  
>> what does console.log(editor.widget) say? is there no editTitle?
>>
>> is your editor called the standard tw way using factory.js?
>>
>
> No it isn't. Sorry for using a confusing terminology. Here is my scenario:
>
> I have a widget plugin that creates a new Div element and then passes it  
> to  an external library. The latter builds a complete specialized editor 
> inside the Div. I also give the library a ref to the widget that calls it. 
> To be clearer, I have:
>
> 1. A tiddler with some specialized text format. Call it SF-Tiddler of type 
> text/SF-type
> 2. A widget that reads the content of tiddlers of type text/SF-type and 
> passes it to a specialized editor mini app
>

so the widget reads the content of tiddlers, so it must know the tiddler 
title

somewhere there is the hidden egg

inside that widget
 

> 3. A specialized editor mini app, Call it SF-EditorApp, which starts out 
> with a copy of the text content of (1) and holds on to a ref to the calling 
> widget (2)
> 4. Editing operations within SF-EditorApp that need the internal copy of 
> the text to be written back to the text of (1) as soon as they are carried 
> out.
>
> My problem is how to to reach (1) from a ref to (2).  SF-EditorApp has a 
> property "widget". IO have been looking at all the methods of Widget, as 
> well as staring at the object in the debugger, and I cannot find a ref to 
> the tiddler the widget is open on. I was expecting either something like:
>
> SF-EditorApp.widget.getTiddler()
>
> or 
>
> SF-EditorApp.widget.tiddler
>
> Instead, after many trips through  the debugger, all I could find was:
>
> SF-EditorApp.widget.parentWidget.transcludeTitle 
>
> which indeed points to the title of my tiddler (1), but has me even more 
> confused (to get from widget to tiddler I need to go up a level and descend 
> to a transclusion?)
>
> What I am looking for is the reference chain that leads from (2) to (1) or 
> to (1)'s title. 
> And the fact I cannot find it after spending two hours looking at the code 
> can only mean I ma still fundamentally confused about TW's data model.
>
>
> -- 
> __
> Stefano Franchi
>
> stefano...@gmail.com 
> http://stefano.cleinias.org
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywikidev+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywikidev@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/babeabd7-c030-4f1d-aaa2-59a520664af2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [twdev] Re: Help with saving a widget's tiddler content from external library code

2019-02-22 Thread stefano franchi
On Fri, Feb 22, 2019 at 2:20 PM Simon Huber 
wrote:

> I am having some trouble understanding how to update the text and other
>> fields of a tiddler my  widget editor works on.
>>
>> I am at the point where the editor is holding
>> (1) editor.widget, a ref to the widget it was called from and
>> (2) fieldUpdates,  an object with field/value pairs  for all the
>> tiddler's fields I want to update. My problem is which function to use to
>> get the task done.
>>
>
> If you're editing a tiddler with your editor and you want its title, the
> widget calling your editor must have it (...) ?
>
> what does console.log(editor.widget) say? is there no editTitle?
>
> is your editor called the standard tw way using factory.js?
>

No it isn't. Sorry for using a confusing terminology. Here is my scenario:

I have a widget plugin that creates a new Div element and then passes it
to  an external library. The latter builds a complete specialized editor
inside the Div. I also give the library a ref to the widget that calls it.
To be clearer, I have:

1. A tiddler with some specialized text format. Call it SF-Tiddler of type
text/SF-type
2. A widget that reads the content of tiddlers of type text/SF-type and
passes it to a specialized editor mini app
3. A specialized editor mini app, Call it SF-EditorApp, which starts out
with a copy of the text content of (1) and holds on to a ref to the calling
widget (2)
4. Editing operations within SF-EditorApp that need the internal copy of
the text to be written back to the text of (1) as soon as they are carried
out.

My problem is how to to reach (1) from a ref to (2).  SF-EditorApp has a
property "widget". IO have been looking at all the methods of Widget, as
well as staring at the object in the debugger, and I cannot find a ref to
the tiddler the widget is open on. I was expecting either something like:

SF-EditorApp.widget.getTiddler()

or

SF-EditorApp.widget.tiddler

Instead, after many trips through  the debugger, all I could find was:

SF-EditorApp.widget.parentWidget.transcludeTitle

which indeed points to the title of my tiddler (1), but has me even more
confused (to get from widget to tiddler I need to go up a level and descend
to a transclusion?)

What I am looking for is the reference chain that leads from (2) to (1) or
to (1)'s title.
And the fact I cannot find it after spending two hours looking at the code
can only mean I ma still fundamentally confused about TW's data model.


-- 
__
Stefano Franchi

stefano.fran...@gmail.com 
http://stefano.cleinias.org

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywikidev+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywikidev@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/CAJODLwatdUiH%3DE46wBrVrARyNx1m8b%3DgEEUCHyjjBJqRrkG8wg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[twdev] Help with saving a widget's tiddler content from external library code

2019-02-22 Thread stefano franchi
I am having some trouble understanding how to update the text and other
fields of a tiddler my  widget editor works on.

I am at the point where the editor is holding
(1) editor.widget, a ref to the widget it was called from and
(2) fieldUpdates,  an object with field/value pairs  for all the tiddler's
fields I want to update. My problem is which function to use to get the
task done.

I tried/looked up the following approaches in my update function (located
in a loop in the external library that builds the editor object-)

a. editor.widget.parseTreeNode[field]=fieldsUpdates[field]
Result: "Compiles" but no results, tiddler text and fields do not
change.

b. editor.widget.wiki.setText(title, field, null, fieldUpdates[field])
Didn't get to try it because it calls for the tiddler's title, And I
haven't find a method to get it from the widget

c. editor.widget.wiki.setData(fieldUpdates)
   Didn't try it it either, because the code comments say it would change
the tiddler's type to app/json, which is definitely not desired.

What am I missing?

Cheers,

Stefano


-- 
__
Stefano Franchi

stefano.fran...@gmail.com 
http://stefano.cleinias.org

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywikidev+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywikidev@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/CAJODLwayReu2EiCgneyHkGe73Xm8cGWdWqCgoSs_N91XVS9OQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.