On Tuesday, February 28, 2017 at 10:54:56 PM UTC, Witold Szczerba wrote:
>
> Hi,
> few days ago I was trying to embed a date picker in my Elm app. I have 
> used MutationObserver, so in Elm all I have to do is to add a specific 
> class and custom event handler, so there is no need to track it by "id". 
> The mutation observer is attached at the top node of the Elm app. This 
> works OK so far.
>
> I have described it here: 
> https://www.reddit.com/r/elm/comments/5uqa13/those_fancy_date_pickers_in_elm_watch_this_no/
> There is also a demo app.
>

Very good. This will be a big help, thanks. I think you are taking a better 
approach by attaching the mutation observer at the top, as this seems 
likely to be much more stable and not subject to breaking or working 
depending on the particulars of the diffing algorithm.
 

> I was wandering if I could use exactly same approach to embed a rich text 
> editor. I wanted to check it out and publish my results, but did not have 
> time to do it yet. What kind of editor are you using? What exactly is your 
> "content" value, "Overlay.editedValue" and "markdownView" functions 
> doing? 
>

markdownView is just rendering my content with evancz/elm-markdown:

markdownView contentModel =
            Markdown.toHtml
                [ domMetricsOn (MouseOverContent contentModel) "mouseover"
                ]
            <|
                asMarkdown contentModel


Overlay.editedValue gets the updated value for the content if it is being 
edited.

I have an 'overlay' which sits on top of the page, and lets me edit content 
as markdown. I have an 'inline' editor which intercepts the rendering of a 
piece of content and replaces it with a wysiwyg editor. I have not yet 
implemented or chosen a wysiwyg editor, its just a place-holder for now, 
and I will edit my content as markdown to begin with.

I am sharing a lot of code between client and server side. The type of the 
Editor is:

type alias Editor msg =
    Model.ContentModel -> Html msg

That is, it just renders some content to Html. In the server side 
implementation, it just renders the content. In the client side 
implementation, it renders the content or injects an editor into the html 
when the content is selected for editing. I replaced all the rendering 
templates which were written in handlebars, with server side Elm. This 
means I can now produce new rendering templates in Elm, and automatically 
be able to inject an editing facility into them, regardless of what the 
template looks like. That's the idea anyway :-).

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to