Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commitefa82d5

Browse files
committed
fix(editor): error message alert
1 parentba9b230 commitefa82d5

File tree

5 files changed

+33
-173
lines changed

5 files changed

+33
-173
lines changed

‎lib/helper/converter/editor_to_html/validator.ex‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ defmodule Helper.Converter.EditorToHTML.Validator do
1818
tursted_atoms=[
1919
# common
2020
:text,
21+
:items,
2122
# header
2223
:level,
2324
:eyebrowTitle,
@@ -123,6 +124,20 @@ defmodule Helper.Converter.EditorToHTML.Validator do
123124
{:ok,:pass}
124125
end
125126
end)
127+
128+
{:ok,:pass}
129+
end
130+
131+
defpvalidate_block(%{type:"code"})do
132+
# schema = %{text: [:string]}
133+
# case ValidateBySchema.cast(schema, data) do
134+
# {:error, errors} ->
135+
# format_parse_error("paragraph", errors)
136+
137+
# _ ->
138+
# {:ok, :pass}
139+
# end
140+
{:ok,:pass}
126141
end
127142

128143
defpvalidate_block(%{type:type}),do:raise("undown#{type} block")

‎test/helper/converter/editor_to_html_test/header_test.exs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.Header do
124124
}\">footer title content</div>\n</div>\n<div>"
125125
end
126126

127-
@tag:wip2
127+
@tag:wip
128128
test"wrong header format data should have invalid hint"do
129129
json=
130130
Map.merge(@editor_json,%{

‎test/helper/converter/editor_to_html_test/index_test.exs‎

Lines changed: 1 addition & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -10,169 +10,6 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML do
1010
@real_editor_data~S({
1111
"time" : 1567250876713,
1212
"blocks" : [
13-
{
14-
"type" : "paragraph",
15-
"data" : {
16-
"text" : "Hey. Meet the new Editor. On this page you can see it in action — try to edit this text."
17-
}
18-
},
19-
{
20-
"type" : "header",
21-
"data" : {
22-
"text" : "Editor.js",
23-
"level" : 2
24-
}
25-
},
26-
{
27-
"type" : "header",
28-
"data" : {
29-
"text" : "Key features",
30-
"level" : 3
31-
}
32-
},
33-
{
34-
"type" : "list",
35-
"data" : {
36-
"style" : "unordered",
37-
"items" : [
38-
"It is a block-styled editor",
39-
"It returns clean data output in JSON",
40-
"Designed to be extendable and pluggable with a simple API"
41-
]
42-
}
43-
},
44-
{
45-
"type" : "header",
46-
"data" : {
47-
"text" : "Key features",
48-
"level" : 3
49-
}
50-
},
51-
{
52-
"type" : "list",
53-
"data" : {
54-
"style" : "ordered",
55-
"items" : [
56-
"It is a block-styled editor",
57-
"It returns clean data output in JSON",
58-
"Designed to be extendable and pluggable with a simple API"
59-
]
60-
}
61-
},
62-
{
63-
"type" : "header",
64-
"data" : {
65-
"text" : "What does it mean «block-styled editor»",
66-
"level" : 3
67-
}
68-
},
69-
{
70-
"type" : "checklist",
71-
"data" : {
72-
"items" : [
73-
{
74-
"text" : "This is a block-styled editor",
75-
"checked" : true
76-
},
77-
{
78-
"text" : "Clean output data",
79-
"checked" : false
80-
},
81-
{
82-
"text" : "Simple and powerful API",
83-
"checked" : true
84-
}
85-
]
86-
}
87-
},
88-
{
89-
"type" : "paragraph",
90-
"data" : {
91-
"text" : "Workspace in classic editors is made of a single contenteditable element, used to create different HTML markups. Editor.js <mark class=\"cdx-marker\">workspace consists of separate Blocks: paragraphs, headings, images, lists, quotes, etc</mark>. Each of them is an independent contenteditable element (or more complex structure\) provided by Plugin and united by Editor's Core."
92-
}
93-
},
94-
{
95-
"type" : "paragraph",
96-
"data" : {
97-
"text" : "There are dozens of <a href=\"https://github.com/editor-js\">ready-to-use Blocks</a> and the <a href=\"https://editorjs.io/creating-a-block-tool\">simple API</a> for creation any Block you need. For example, you can implement Blocks for Tweets, Instagram posts, surveys and polls, CTA-buttons and even games."
98-
}
99-
},
100-
{
101-
"type" : "header",
102-
"data" : {
103-
"text" : "What does it mean clean data output",
104-
"level" : 3
105-
}
106-
},
107-
{
108-
"type" : "paragraph",
109-
"data" : {
110-
"text" : "Classic WYSIWYG-editors produce raw HTML-markup with both content data and content appearance. On the contrary, Editor.js outputs JSON object with data of each Block. You can see an example below"
111-
}
112-
},
113-
{
114-
"type" : "paragraph",
115-
"data" : {
116-
"text" : "Given data can be used as you want: render with HTML for <code class=\"inline-code\">Web clients</code>, render natively for <code class=\"inline-code\">mobile apps</code>, create markup for <code class=\"inline-code\">Facebook Instant Articles</code> or <code class=\"inline-code\">Google AMP</code>, generate an <code class=\"inline-code\">audio version</code> and so on."
117-
}
118-
},
119-
{
120-
"type" : "paragraph",
121-
"data" : {
122-
"text" : "Clean data is useful to sanitize, validate and process on the backend."
123-
}
124-
},
125-
{
126-
"type" : "delimiter",
127-
"data" : {}
128-
},
129-
{
130-
"type" : "paragraph",
131-
"data" : {
132-
"text" : "We have been working on this project more than three years. Several large media projects help us to test and debug the Editor, to make it's core more stable. At the same time we significantly improved the API. Now, it can be used to create any plugin for any task. Hope you enjoy. 😏"
133-
}
134-
},
135-
{
136-
"type" : "image",
137-
"data" : {
138-
"file" : {
139-
"url" : "https://codex.so/upload/redactor_images/o_e48549d1855c7fc1807308dd14990126.jpg"
140-
},
141-
"caption" : "",
142-
"withBorder" : true,
143-
"stretched" : false,
144-
"withBackground" : false
145-
}
146-
},
147-
{
148-
"type" : "linkTool",
149-
"data" : {
150-
"link" : "https://www.github.com",
151-
"meta" : {
152-
"url" : "https://www.github.com",
153-
"domain" : "www.github.com",
154-
"title" : "Build software better, together",
155-
"description" : "GitHub is where people build software. More than 40 million people use GitHub to discover, fork, and contribute to over 100 million projects.",
156-
"image" : {
157-
"url" : "https://github.githubassets.com/images/modules/open_graph/github-logo.png"
158-
}
159-
}
160-
}
161-
},
162-
{
163-
"type" : "quote",
164-
"data" : {
165-
"text" : "quote demo text",
166-
"caption" : "desc?",
167-
"alignment" : "left"
168-
}
169-
},
170-
{
171-
"type" : "delimiter",
172-
"data" : {
173-
"type" : "pen"
174-
}
175-
},
17613
{
17714
"type" : "code",
17815
"data" : {
@@ -237,6 +74,7 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML do
23774
end
23875

23976
describe"[secure issues]"do
77+
@tag:wip
24078
test"code block should avoid potential xss script attack"do
24179
{:ok,converted}=Parser.to_html(@real_editor_data)
24280

‎test/helper/converter/editor_to_html_test/list_test.exs‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,19 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.List do
3636
{:ok,editor_string}=Jason.encode(@editor_json)
3737
{:error,err_msg}=Parser.to_html(editor_string)
3838

39-
asserterr_msg==
40-
"indent should be: 0 | 1 | 2 | 3 | 4 ; hideLabel should be: boolean"
39+
asserterr_msg==[
40+
%{
41+
block:"list(checklist)",
42+
field:"hideLabel",
43+
message:"should be: boolean",
44+
value:"invalid"
45+
},
46+
%{
47+
block:"list(checklist)",
48+
field:"indent",
49+
message:"should be: 0 | 1 | 2 | 3 | 4"
50+
}
51+
]
4152
end
4253

4354
@editor_json%{
@@ -65,11 +76,7 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.List do
6576
@tag:wip
6677
test"valid list parse should work"do
6778
{:ok,editor_string}=Jason.encode(@editor_json)
68-
# {:ok, converted} = Parser.to_html(editor_string)
69-
Parser.to_html(editor_string)
70-
71-
assert{:ok,converted}=Parser.to_html(editor_string)
72-
# IO.inspect(converted, label: "->> converted")
79+
assert{:ok,_}=Parser.to_html(editor_string)
7380
end
7481

7582
@editor_json%{
@@ -94,7 +101,7 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.List do
94101
],
95102
"version"=>"2.15.0"
96103
}
97-
@tag:wip2
104+
@tag:wip
98105
test"invalid indent field should get error"do
99106
{:ok,editor_string}=Jason.encode(@editor_json)
100107
{:error,error}=Parser.to_html(editor_string)

‎test/helper/converter/editor_to_html_test/paragraph_test.exs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ defmodule GroupherServer.Test.Helper.Converter.EditorToHTML.Paragraph do
4141
],
4242
"version"=>"2.15.0"
4343
}
44-
@tag:wip2
44+
@tag:wip
4545
test"invalid paragraph should have invalid hint"do
4646
{:ok,editor_string}=Jason.encode(@editor_json)
4747
{:error,error}=Parser.to_html(editor_string)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp