Skip to content
This repository was archived by the owner on Nov 13, 2021. It is now read-only.

Commit e81320d

Browse files
committed
implemented parser and importert
renamed block typer parsers
1 parent a683813 commit e81320d

20 files changed

+476
-2247
lines changed

dist/0.bundle.js

Lines changed: 0 additions & 1498 deletions
This file was deleted.

dist/bundle.js

Lines changed: 205 additions & 420 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 130 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,137 @@
11
<html>
2+
23
<head>
3-
<link href="https://fonts.googleapis.com/css?family=PT+Mono" rel="stylesheet">
4-
<link href="assets/demo.css" rel="stylesheet">
5-
<script src="dist/bundle.js" type="module"></script>
4+
<link href="https://fonts.googleapis.com/css?family=PT+Mono" rel="stylesheet">
5+
<link href="assets/demo.css" rel="stylesheet">
6+
<script src="dist/bundle.js" type="module"></script>
7+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/header@latest"></script><!-- Header -->
8+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/simple-image@latest"></script><!-- Image -->
9+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/delimiter@latest"></script><!-- Delimiter -->
10+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/list@latest"></script><!-- List -->
11+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/checklist@latest"></script><!-- Checklist -->
12+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/quote@latest"></script><!-- Quote -->
13+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/code@latest"></script><!-- Code -->
14+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/embed@latest"></script><!-- Embed -->
15+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/table@latest"></script><!-- Table -->
16+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/link@latest"></script><!-- Link -->
17+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/warning@latest"></script><!-- Warning -->
618

7-
<meta charset="utf-8" />
8-
</head>
19+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/marker@latest"></script><!-- Marker -->
20+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/inline-code@latest"></script><!-- Inline Code -->
21+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest"></script>
22+
<script src="dist/bundle.js"></script>
23+
<style>
24+
#title {
25+
font-family: "Helvetica", sans-serif;
26+
color: #1e1e1e;
27+
text-align: center;
28+
}
29+
30+
#output-wrapper {
31+
display: flex;
32+
flex-direction: column;
33+
justify-content: center;
34+
align-items: center;
35+
}
936

10-
<div class="ce-example__output">
11-
<pre class="ce-example__output-content" id="output"></pre>
12-
</div>
37+
#save-button {
38+
width: 80px;
39+
margin: 20px;
40+
}
41+
</style>
1342

14-
<div class="ce-example__content _ce-example__content--small">
15-
<div id="editorjs">
43+
<meta charset="utf-8" />
44+
</head>
45+
46+
<body>
47+
<h2 id="title">Editor.js - Github Gist Plugin</h2>
48+
<div id="editorjs"></div>
49+
<div id="output-wrapper">
50+
<button id="save-button" class="cdx-button">Save</button>
51+
<pre id="output"></pre>
1652
</div>
17-
</div>
18-
<div class="ce-example__button" id="saveButton">
19-
editor.save()
20-
</div>
53+
54+
<script>
55+
const editor = new EditorJS({
56+
autofocus: true,
57+
58+
tools: {
59+
header: {
60+
class: Header,
61+
inlineToolbar: ['marker', 'link'],
62+
config: {
63+
placeholder: 'Header'
64+
},
65+
shortcut: 'CMD+SHIFT+H'
66+
},
67+
image: SimpleImage,
68+
69+
list: {
70+
class: List,
71+
inlineToolbar: true,
72+
shortcut: 'CMD+SHIFT+L'
73+
},
74+
75+
checklist: {
76+
class: Checklist,
77+
inlineToolbar: true,
78+
},
79+
80+
quote: {
81+
class: Quote,
82+
inlineToolbar: true,
83+
config: {
84+
quotePlaceholder: 'Enter a quote',
85+
captionPlaceholder: 'Quote\'s author',
86+
},
87+
shortcut: 'CMD+SHIFT+O'
88+
},
89+
90+
warning: Warning,
91+
92+
marker: {
93+
class: Marker,
94+
shortcut: 'CMD+SHIFT+M'
95+
},
96+
97+
code: {
98+
class: CodeTool,
99+
shortcut: 'CMD+SHIFT+C'
100+
},
101+
102+
delimiter: Delimiter,
103+
104+
inlineCode: {
105+
class: InlineCode,
106+
shortcut: 'CMD+SHIFT+C'
107+
},
108+
109+
linkTool: LinkTool,
110+
111+
embed: Embed,
112+
113+
parser: MarkdownParser,
114+
importer: MarkdownImporter,
115+
116+
table: {
117+
class: Table,
118+
inlineToolbar: true,
119+
shortcut: 'CMD+ALT+T'
120+
},
121+
122+
123+
},
124+
});
125+
126+
const saveButton = document.getElementById('save-button');
127+
const output = document.getElementById('output');
128+
129+
saveButton.addEventListener('click', () => {
130+
editor.save().then(savedData => {
131+
output.innerHTML = JSON.stringify(savedData, null, 4);
132+
})
133+
})
134+
</script>
135+
</body>
136+
21137
</html>
File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export function parseCodeToMarkdown(blocks) {
2+
return `\`\`\`\n${blocks.code}\n\`\`\`\n`;
3+
}
4+
5+
export function parseMarkdownToCode(blocks) {
6+
const codeData = {
7+
data: {
8+
code: blocks.value,
9+
},
10+
type: 'code',
11+
};
12+
13+
return codeData;
14+
}
File renamed without changes.
File renamed without changes.

src/BlockTypeParsers/paragraph-type-parser.js renamed to src/BlockTypeParsers/ParagraphTypeParser.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ export function parseMarkdownToParagraph(blocks) {
1515
type: 'paragraph',
1616
};
1717
}
18+
if (item.type === 'image') {
19+
paragraphData = {
20+
data: {
21+
caption: item.title,
22+
stretched: false,
23+
url: item.url,
24+
withBackground: false,
25+
withBorder: false,
26+
},
27+
type: 'image',
28+
};
29+
}
1830
});
1931
}
2032
return paragraphData;

0 commit comments

Comments
 (0)