Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions elm/src/MdCommon.elm
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ type alias HtmlFns a =
, panelView : String -> List a -> a
, imageView : String -> String -> Maybe String -> List a -> a
, videoView : String -> Maybe String -> Maybe String -> Maybe String -> List a -> a
, audioView : String -> String -> List a -> a
, audioView : String -> Maybe String -> List a -> a
, noteView : String -> Maybe String -> Maybe String -> List a -> a
, yeetView : String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> List a -> a
}
Expand Down Expand Up @@ -394,11 +394,13 @@ textHtml =
|> List.filterMap identity
)
, audioView =
\text src _ ->
\src text _ ->
htmlTextTag "audio"
[ ( "src", src )
, ( "text", text )
]
([ Just ( "src", src )
, Maybe.map (\s -> ( "text", s )) text
]
|> List.filterMap identity
)
, noteView =
\id show text _ ->
htmlTextTag "note"
Expand Down Expand Up @@ -442,8 +444,8 @@ htmlF hf =
|> Markdown.Html.withOptionalAttribute "width"
|> Markdown.Html.withOptionalAttribute "height"
, Markdown.Html.tag "audio" hf.audioView
|> Markdown.Html.withAttribute "text"
|> Markdown.Html.withAttribute "src"
|> Markdown.Html.withOptionalAttribute "text"
, Markdown.Html.tag "note" hf.noteView
|> Markdown.Html.withAttribute "id"
|> Markdown.Html.withOptionalAttribute "show"
Expand Down Expand Up @@ -542,14 +544,14 @@ imageView fui text url mbwidth renderedChildren =
{ src = furl, description = text }


audioView : FileUrlInfo -> String -> String -> List (Element a) -> Element a
audioView fui text url renderedChildren =
htmlAudioView (fileUrl fui url) text
audioView : FileUrlInfo -> String -> Maybe String -> List (Element a) -> Element a
audioView fui url mbtext renderedChildren =
htmlAudioView (fileUrl fui url) mbtext


htmlAudioView : String -> String -> Element a
htmlAudioView url text =
E.html (Html.audio [ HA.controls True, HA.src url ] [ Html.text text ])
htmlAudioView : String -> Maybe String -> Element a
htmlAudioView url mbtext =
E.html (Html.audio [ HA.controls True, HA.src url ] [ Html.text (Maybe.withDefault "" mbtext) ])


audioNoteView : FileUrlInfo -> Data.ZkNote -> Element a
Expand All @@ -561,7 +563,7 @@ audioNoteView fui zkn =
E.column [ EBd.width 1, E.spacing 5, E.padding 5 ]
[ link ("/note/" ++ zkNoteIdToString zkn.id) [ E.text zkn.title ]
, E.row [ E.spacing 20 ]
[ htmlAudioView fileurl zkn.title
[ htmlAudioView fileurl (Just zkn.title)
, if fui.tauri || List.filter (\i -> i == DataUtil.sysids.publicid) zkn.sysids /= [] then
link
("https://29a.ch/timestretch/#a=" ++ fui.location ++ "/file/" ++ zkNoteIdToString zkn.id)
Expand Down
4 changes: 2 additions & 2 deletions elm/src/MdGui.elm
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ guiHtmlElement tag attribs =

"audio" ->
case Toop.T2 (findAttrib "src" attribs) (findAttrib "text" attribs) of
Toop.T2 (Just src) (Just text) ->
Toop.T2 (Just src) mbtext ->
row <|
E.column coltrib
[ EI.text []
Expand All @@ -950,7 +950,7 @@ guiHtmlElement tag attribs =
}
, EI.text []
{ onChange = AudioText
, text = text
, text = Maybe.withDefault "" mbtext
, placeholder = Nothing
, label = EI.labelLeft [] (E.text "text")
}
Expand Down
43 changes: 40 additions & 3 deletions elm/src/MdInlineXform.elm
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,44 @@ transforms inline =
( mbtext, Just noteid, show ) ->
[ ( "none", inline )
, ( "link", MB.Link ("/note/" ++ noteid) Nothing [ MB.Text (Maybe.withDefault "" mbtext) ] )
, ( "panel"
, ( "md image", MB.Image ("/file/" ++ noteid) mbtext [] )
, ( "zkn image"
, MB.HtmlInline
(MB.HtmlElement "image"
(List.filterMap identity
[ Just { name = "url", value = "/file/" ++ noteid }
, mbtext
|> Maybe.map (\s -> { name = "text", value = s })
]
)
[]
)
)
, ( "zkn video"
, MB.HtmlInline
(MB.HtmlElement "video"
(List.filterMap identity
[ Just { name = "src", value = "/file/" ++ noteid }
, mbtext
|> Maybe.map (\s -> { name = "text", value = s })
]
)
[]
)
)
, ( "zkn audio"
, MB.HtmlInline
(MB.HtmlElement "audio"
(List.filterMap identity
[ Just { name = "src", value = "/file/" ++ noteid }
, mbtext
|> Maybe.map (\s -> { name = "text", value = s })
]
)
[]
)
)
, ( "zkn panel"
, MB.HtmlInline
(MB.HtmlElement "panel"
[ { name = "noteid", value = noteid } ]
Expand Down Expand Up @@ -261,7 +298,7 @@ transforms inline =
)
, Just ( "md image", MB.Image url mbt inlines )
, Just
( "html image"
( "zkn image"
, MB.HtmlInline
(MB.HtmlElement "image"
(List.filterMap identity
Expand All @@ -278,7 +315,7 @@ transforms inline =
Image src mbt inlines ->
[ ( "none", inline )
, ( "link", MB.Link src mbt inlines )
, ( "html image"
, ( "zkn image"
, MB.HtmlInline
(MB.HtmlElement "image"
(List.filterMap identity
Expand Down