Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
9702974a
Commit
9702974a
authored
Jan 15, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Markdown] some more work on the editor
parent
900956af
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
MarkdownEditor.purs
src/Gargantext/Components/MarkdownEditor.purs
+16
-4
No files found.
src/Gargantext/Components/MarkdownEditor.purs
View file @
9702974a
module Gargantext.Components.MarkdownEditor where
import Data.Either (either, Either(..))
import Prelude (($), (>>>), identity, pure)
import Data.Maybe (Maybe(..))
import Data.Nullable (Nullable, null, toMaybe)
import FFI.Simple ((.=))
import Prelude (($), (>>>), bind, discard, identity, pure, unit)
import Reactix as R
import Reactix.DOM.HTML as H
import Text.Markdown.SlamDown.Parser (parseMd)
...
...
@@ -28,6 +31,15 @@ markdownEditor p = R.createElement markdownEditorCpt p []
markdownEditorCpt :: R.Component Props
markdownEditorCpt = R.hooksComponent "G.C.MarkdownEditor" cpt
where
cpt {md, nodeId} _ =
pure $
H.div {} [ H.text $ compileMd md ]
cpt {md, nodeId} _ = do
ref <- R.useRef null
R.useEffect1' md $ do
let mDiv = toMaybe $ R.readRef ref
case mDiv of
Nothing -> pure unit
Just d -> do
_ <- pure $ ("innerHTML" .= d) $ compileMd md
pure unit
pure $ H.div { ref } []
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment