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.

Commitfc93811

Browse files
committed
refactor(editor-playground): basic style setup
1 parentd1ece95 commitfc93811

File tree

5 files changed

+109
-22
lines changed

5 files changed

+109
-22
lines changed

‎pages/editor.js‎

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
11
importReactfrom'react'
2+
import{Provider}from'mobx-react'
23

4+
importinitRootStorefrom'@stores/init'
5+
importThemeWrapperfrom'@containers/ThemeWrapper'
36
importRichEditorfrom'@containers/RichEditor'
47
// import EditorJS from '@editorjs/editorjs'
58

69
consthtml=
7-
'<div class="cps-viewer"><h2>Editor.js</h2><p>Hey. Meet the new Editor. On this page you can see it in action — try to edit this text.</p><h3>Key features</h3><ul><li>It is a block-styled editor</li><li>It returns clean data output in JSON</li><li>Designed to be extendable and pluggable with a simple API</li></ul><h3>Key features</h3><ol><li>It is a block-styled editor</li><li>It returns clean data output in JSON</li><li>Designed to be extendable and pluggable with a simple API</li></ol><h3>What does it mean «block-styled editor»</h3><div class="cps-viewer-checklist"><div>This is a block-styled editor</div><div>Clean output data</div><div>Simple and powerful API</div></div><p>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.</p><p>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.</p><h3>What does it mean clean data output</h3><p>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</p><p>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.</p><p>Clean data is useful to sanitize, validate and process on the backend.</p><div class="cps-viewer-delimiter"></div><p>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. 😏</p><div class="cps-viewer-image"><img src="https://codex.so/upload/redactor_images/o_e48549d1855c7fc1807308dd14990126.jpg" /></div><div class="cps-viewer-linker"><a href="https://www.github.com">https://www.github.com</a></div><div class="cps-viewer-quote">quote demo text</div><div>'
10+
'<div class="cps-viewer"><h2 class="cps-viewer-header">Editor.js</h2><p class="cps-viewer-paragraph">Hey. Meet the new Editor. On this page you can see it in action — try to edit this text.</p><h3 class="cps-viewer-header">Key features</h3><ul><li>It is a block-styled editor</li><li>It returns clean data output in JSON</li><li>Designed to be extendable and pluggable with a simple API</li></ul><h3 class="cps-viewer-header">Key features</h3><ol><li>It is a block-styled editor</li><li>It returns clean data output in JSON</li><li>Designed to be extendable and pluggable with a simple API</li></ol><h3 class="cps-viewer-header">What does it mean «block-styled editor»</h3><div class="cps-viewer-checklist"><div>This is a block-styled editor</div><div>Clean output data</div><div>Simple and powerful API</div></div><p class="cps-viewer-paragraph">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.</p><p class="cps-viewer-paragraph">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.</p><h3 class="cps-viewer-header">What does it mean clean data output</h3><p class="cps-viewer-paragraph">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</p><p class="cps-viewer-paragraph">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.</p><p class="cps-viewer-paragraph">Clean data is useful to sanitize, validate and process on the backend.</p><div class="cps-viewer-delimiter"></div><p class="cps-viewer-paragraph">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. 😏</p><div class="cps-viewer-image"><img src="https://codex.so/upload/redactor_images/o_e48549d1855c7fc1807308dd14990126.jpg" /></div><div class="cps-viewer-linker"><a href="https://www.github.com">https://www.github.com</a></div><div class="cps-viewer-quote">quote demo text</div><div>'
811

912
constEditor=()=>{
13+
conststore=initRootStore({langSetup:{}})
14+
1015
return(
11-
<div
12-
style={{
13-
border:'1px solid lightgrey',
14-
width:'800px',
15-
margin:'10% 20%',
16-
}}
17-
>
18-
<div
19-
dangerouslySetInnerHTML={{
20-
__html:html,
21-
}}
22-
/>
23-
<hr/>
24-
<br/>
25-
<RichEditor/>
26-
</div>
16+
<Providerstore={store}>
17+
<ThemeWrapper>
18+
<div
19+
style={{
20+
border:'1px solid lightgrey',
21+
background:'lightgrey',
22+
width:'100%',
23+
padding:'30px',
24+
height:'100%',
25+
}}
26+
>
27+
<div
28+
dangerouslySetInnerHTML={{
29+
__html:html,
30+
}}
31+
/>
32+
<hr/>
33+
<br/>
34+
<RichEditor/>
35+
</div>
36+
</ThemeWrapper>
37+
</Provider>
2738
)
2839
}
2940

‎src/containers/RichEditor/index.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { useScript } from '@hooks'
1212
import{useInit}from'./logic'
1313
// import * as logic from './logic'
1414

15+
import{Wrapper}from'./styles'
16+
1517
/* eslint-disable-next-line */
1618
constlog=buildLog('C:RichEditor')
1719

@@ -23,11 +25,10 @@ const RichEditorContainer = ({ richEditor }) => {
2325
useInit(richEditor,loaded)
2426

2527
return(
26-
<div>
27-
<h2>RichEditor container!</h2>
28-
<div>impress me!</div>
28+
<Wrapper>
29+
<h3>hello</h3>
2930
<divid="codex-editor"/>
30-
</div>
31+
</Wrapper>
3132
)
3233
}
3334

‎src/containers/RichEditor/styles/index.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ import styled from 'styled-components'
33
// import Img from '@components/Img'
44
// import { theme } from '@utils'
55

6-
exportconstWrapper=styled.div``
6+
exportconstWrapper=styled.div`
7+
background: white;
8+
`
79
exportconstTitle=styled.div``
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import{createGlobalStyle}from'styled-components'
2+
// import { theme, cs } from '@utils'
3+
4+
constRichEditorStyle=createGlobalStyle`
5+
.cps-viewer {
6+
padding: 10px;
7+
background: white;
8+
font-size: 15px;
9+
color: #313649;
10+
line-height: 1.6;
11+
letter-spacing: .005em;
12+
13+
h2 {
14+
display: block;
15+
font-size: 1.5em;
16+
margin-block-start: 0.83em;
17+
margin-block-end: 0.83em;
18+
margin-inline-start: 0px;
19+
margin-inline-end: 0px;
20+
font-weight: bold;
21+
}
22+
h3 {
23+
display: block;
24+
font-size: 1.17em;
25+
margin-block-start: 1em;
26+
margin-block-end: 1em;
27+
margin-inline-start: 0px;
28+
margin-inline-end: 0px;
29+
font-weight: bold;
30+
}
31+
.cps-viewer-header {
32+
padding: 1em 0;
33+
margin: 0;
34+
line-height: 1.5em;
35+
outline: none;
36+
}
37+
38+
.cps-viewer-paragraph {
39+
line-height: 1.6em;
40+
outline: none;
41+
}
42+
ul {
43+
list-style: disc;
44+
margin: 0;
45+
padding-left: 40px;
46+
outline: none;
47+
}
48+
ul li {
49+
padding: 5.5px 0 5.5px 3px;
50+
line-height: 1.6em;
51+
}
52+
53+
ol {
54+
list-style: decimal;
55+
margin: 0;
56+
padding-left: 40px;
57+
outline: none;
58+
}
59+
60+
ol li {
61+
padding: 5.5px 0 5.5px 3px;
62+
line-height: 1.6em;
63+
}
64+
65+
.cdx-marker {
66+
background-color: #FCF9D8;
67+
}
68+
}
69+
`
70+
71+
exportdefaultRichEditorStyle

‎src/containers/ThemeWrapper/index.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { usePlatform } from '@hooks'
1515
importCodeSyxHighlightfrom'./CodeSyxHighlight'
1616
importAntUIOverWritefrom'./AntUIOverWrite'
1717
importGlobalStylefrom'./GlobalStyle'
18+
importRichEditorStylefrom'./RichEditorStyle'
1819

1920
constThemeContainer=({ children,theme:{ themeData}})=>{
2021
const{ isMacOS, isMobile}=usePlatform()
@@ -29,6 +30,7 @@ const ThemeContainer = ({ children, theme: { themeData } }) => {
2930
<div>{children}</div>
3031
<CodeSyxHighlight/>
3132
<AntUIOverWrite/>
33+
<RichEditorStyle/>
3234
<GlobalStyleshowCustomScrollbar={showCustomScrollbar}/>
3335
</React.Fragment>
3436
</ThemeProvider>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp