This repository was archived by the owner on Nov 8, 2022. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork20
refactor(new-editor): editor.js convert & parse#264
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
23 commits Select commitHold shift + click to select a range
76b0eee
chore(clean-up): remove old wip tags
mydearxym72f3813
test(editor): paragraph and header basic test
mydearxymf527057
test(editor): re-org codebase by parse header part
mydearxym995e602
test(editor): parse workflow adjust
mydearxym80b8831
test(editor-parse): re-org dir structure based on blocks
mydearxym7392f79
test(editor-parse): clean up imports
mydearxym221c050
test(editor): add basic paragraph block test
mydearxyme074944
test(editor): using macro && clean up
mydearxymfd8831c
refactor(editor): re-org the editor json validte workflow
mydearxymb255880
refactor(editor): return map fmt when error raised
mydearxymba9b230
fix(editor): utils
mydearxymefa82d5
fix(editor): error message alert
mydearxymdc5f0cf
fix(editor): add :lang to tursted_atoms
mydearxym0ea6c34
refactor(editor): use string-fmt map instead of atom-fmt
mydearxym50d6108
fix(editor): re-org validate workflow by using config
mydearxym39ff354
fix(editor): add list to validator workflow as general
mydearxym2ece8ea
refactor(editor): use common schema to validate editor-fmt json
mydearxyme244d89
refactor(editor): use macros to reduce similar code
mydearxym89c2e2a
refactor(editor): adjust guard name in schema matchers
mydearxym23085c8
refactor(editor): re-org / rename the schema validator
mydearxymbad9428
refactor(editor): adjust parent schema cast logic
mydearxyme8d940e
refactor(editor): validate_with logic re-org
mydearxym0d43e6a
refactor(editor): adjust xss test && clean up
mydearxymFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions.iex.exs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# see: https://github.com/blackode/elixir-tips#loading-project-module-aliases-iexexs | ||
alias Helper.Converter.EditorToHTML |
3 changes: 1 addition & 2 deletionsMakefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionlib/helper/converter/assets/delimiter_icons.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletionslib/helper/converter/editor_to_html/header.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
defmodule Helper.Converter.EditorToHTML.Header do | ||
@moduledoc """ | ||
parse editor.js's header block | ||
see https://editorjs.io/ | ||
""" | ||
# @behaviour Helper.Converter.EditorToHTML.Parser | ||
defmacro __using__(_opts) do | ||
quote do | ||
alias Helper.Metric | ||
@clazz Metric.Article.class_names(:html) | ||
defp parse_block(%{ | ||
"type" => "header", | ||
"data" => | ||
%{ | ||
"text" => text, | ||
"level" => level, | ||
"eyebrowTitle" => eyebrow_title, | ||
"footerTitle" => footer_title | ||
} = data | ||
}) do | ||
""" | ||
<div class="#{@clazz.header.wrapper}"> | ||
<div class="#{@clazz.header.eyebrow_title}">#{eyebrow_title}</div> | ||
<h#{level}>#{text}</h#{level}> | ||
<div class="#{@clazz.header.footer_title}">#{footer_title}</div> | ||
</div> | ||
""" | ||
end | ||
defp parse_block(%{ | ||
"type" => "header", | ||
"data" => | ||
%{ | ||
"text" => text, | ||
"level" => level, | ||
"eyebrowTitle" => eyebrow_title | ||
} = data | ||
}) do | ||
""" | ||
<div class="#{@clazz.header.wrapper}"> | ||
<div class="#{@clazz.header.eyebrow_title}">#{eyebrow_title}</div> | ||
<h#{level}>#{text}</h#{level}> | ||
</div> | ||
""" | ||
end | ||
defp parse_block(%{ | ||
"type" => "header", | ||
"data" => | ||
%{ | ||
"text" => text, | ||
"level" => level, | ||
"footerTitle" => footer_title | ||
} = data | ||
}) do | ||
""" | ||
<div class="#{@clazz.header.wrapper}"> | ||
<h#{level}>#{text}</h#{level}> | ||
<div class="#{@clazz.header.footer_title}">#{footer_title}</div> | ||
</div> | ||
""" | ||
end | ||
defp parse_block(%{ | ||
"type" => "header", | ||
"data" => %{ | ||
"text" => text, | ||
"level" => level | ||
} | ||
}) do | ||
"<h#{level}>#{text}</h#{level}>" | ||
end | ||
end | ||
end | ||
end |
70 changes: 28 additions & 42 deletionslib/helper/converter/editor_to_html.ex → lib/helper/converter/editor_to_html/index.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.