Extract inline fragments from HTML markup

This commit is contained in:
Georgy Berezhnoy 2021-10-16 23:03:34 +03:00
commit 2831423d78
No known key found for this signature in database
GPG key ID: F72152EC600B4FAE
11 changed files with 398 additions and 96 deletions

View file

@ -69,12 +69,12 @@
<script src="./tools/simple-image/dist/bundle.js"></script><!-- Image -->
<script src="./tools/delimiter/dist/bundle.js"></script><!-- Delimiter -->
<!-- <script src="./tools/list/dist/bundle.js"></script> List -->
<script src="./tools/nested-list/dist/nested-list.js"></script><!-- Nested List -->
<!-- <script src="./tools/nested-list/dist/nested-list.js"></script>&lt;!&ndash; Nested List &ndash;&gt;-->
<script src="./tools/checklist/dist/bundle.js"></script><!-- Checklist -->
<script src="./tools/quote/dist/bundle.js"></script><!-- Quote -->
<script src="./tools/code/dist/bundle.js"></script><!-- Code -->
<script src="./tools/embed/dist/bundle.js"></script><!-- Embed -->
<script src="./tools/table/dist/bundle.js"></script><!-- Table -->
<!-- <script src="./tools/table/dist/bundle.js"></script>&lt;!&ndash; Table &ndash;&gt;-->
<script src="./tools/link/dist/bundle.js"></script><!-- Link -->
<script src="./tools/raw/dist/bundle.js"></script><!-- Raw -->
<script src="./tools/warning/dist/bundle.js"></script><!-- Warning -->
@ -131,11 +131,11 @@
*/
image: SimpleImage,
list: {
class: NestedList,
inlineToolbar: true,
shortcut: 'CMD+SHIFT+L'
},
// list: {
// class: NestedList,
// inlineToolbar: true,
// shortcut: 'CMD+SHIFT+L'
// },
checklist: {
class: Checklist,
@ -176,12 +176,12 @@
raw: RawTool,
embed: Embed,
table: {
class: Table,
inlineToolbar: true,
shortcut: 'CMD+ALT+T'
},
//
// table: {
// class: Table,
// inlineToolbar: true,
// shortcut: 'CMD+ALT+T'
// },
},
@ -194,126 +194,220 @@
* Initial Editor data
*/
data: {
blocks: [
"time" : 1634414421172,
"blocks" : [
{
id: "zcKCF1S7X8",
type: "header",
data: {
text: "Editor.js",
level: 2
"id" : "zcKCF1S7X8",
"type" : "header",
"data" : {
"text" : "Editor.js",
"level" : 2
}
},
{
"id": "b6ji-DvaKb",
"type": "paragraph",
"data": {
"text": "Hey. Meet the new Editor. On this page you can see it in action — try to edit this text. Source code of the page contains the example of connection and configuration."
"id" : "b6ji-DvaKb",
"type" : "paragraph",
"data" : {
"text" : "Hey. Meet the new Editor. On this page you can see it in action — try to edit this text. Source code of the page contains the example of connection and configuration."
}
},
{
type: "header",
id: "7ItVl5biRo",
data: {
text: "Key features",
level: 3
"id" : "7ItVl5biRo",
"type" : "header",
"data" : {
"text" : "Key features",
"level" : 3
}
},
{
type : 'list',
id: "SSBSguGvP7",
data : {
items : [
"id" : "SSBSguGvP7",
"type" : "list",
"data" : {
"items" : [
{
content: 'It is a block-styled editor',
items: []
"content" : "It is a block-styled editor",
"items" : []
},
{
content: 'It returns clean data output in JSON',
items: []
"content" : "It returns clean data output in JSON",
"items" : []
},
{
content: 'Designed to be extendable and pluggable with a simple API',
items: []
"content" : "Designed to be extendable and pluggable with a simple API",
"items" : []
}
],
style: 'unordered'
"style" : "unordered"
}
},
{
type: "header",
id: "QZFox1m_ul",
data: {
text: "What does it mean «block-styled editor»",
level: 3
"id" : "QZFox1m_ul",
"type" : "header",
"data" : {
"text" : "What does it mean «block-styled editor»",
"level" : 3
}
},
{
type : 'paragraph',
id: "bwnFX5LoX7",
data : {
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.'
"id" : "bwnFX5LoX7",
"type" : "paragraph",
"data" : {
"text" : "Workspace in classic editors is made of a single contenteditable element, used to create different HTML markups. Editor.js workspace consists of separate Blocks: paragraphs, headings, images, lists, quotes, etc. Each of them is an independent contenteditable element (or more complex structure) provided by Plugin and united by Editor's Core."
},
"fragments" : {
"text" : [
{
"range" : [
123,
210
],
"element" : "MARK",
"attributes" : {
"class" : "cdx-marker"
}
}
]
}
},
{
type : 'paragraph',
id: "mTrPOHAQTe",
data : {
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.`
"id" : "mTrPOHAQTe",
"type" : "paragraph",
"data" : {
"text" : "There are dozens of ready-to-use Blocks and the simple API for creation any Block you need. For example, you can implement Blocks for Tweets, Instagram posts, surveys and polls, CTA-buttons and even games."
},
"fragments" : {
"text" : [
{
"range" : [
20,
39
],
"element" : "A",
"attributes" : {
"href" : "https://github.com/editor-js"
}
},
{
"range" : [
48,
58
],
"element" : "A",
"attributes" : {
"href" : "https://editorjs.io/creating-a-block-tool"
}
}
]
}
},
{
type: "header",
id: "1sYMhUrznu",
data: {
text: "What does it mean clean data output",
level: 3
"id" : "1sYMhUrznu",
"type" : "header",
"data" : {
"text" : "What does it mean clean data output",
"level" : 3
}
},
{
type : 'paragraph',
id: "jpd7WEXrJG",
data : {
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'
"id" : "jpd7WEXrJG",
"type" : "paragraph",
"data" : {
"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"
}
},
{
type : 'paragraph',
id: "0lOGNUKxqt",
data : {
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.`
"id" : "0lOGNUKxqt",
"type" : "paragraph",
"data" : {
"text" : "Given data can be used as you want: render with HTML for Web clients, render natively for mobile apps, create markup for Facebook Instant Articles or Google AMP, generate an audio version and so on."
},
"fragments" : {
"text" : [
{
"range" : [
57,
68
],
"element" : "CODE",
"attributes" : {
"class" : "inline-code"
}
},
{
"range" : [
90,
101
],
"element" : "CODE",
"attributes" : {
"class" : "inline-code"
}
},
{
"range" : [
121,
146
],
"element" : "CODE",
"attributes" : {
"class" : "inline-code"
}
},
{
"range" : [
150,
160
],
"element" : "CODE",
"attributes" : {
"class" : "inline-code"
}
},
{
"range" : [
174,
187
],
"element" : "CODE",
"attributes" : {
"class" : "inline-code"
}
}
]
}
},
{
type : 'paragraph',
id: "WvX7kBjp0I",
data : {
text : 'Clean data is useful to sanitize, validate and process on the backend.'
"id" : "WvX7kBjp0I",
"type" : "paragraph",
"data" : {
"text" : "Clean data is useful to sanitize, validate and process on the backend."
}
},
{
type : 'delimiter',
id: "H9LWKQ3NYd",
data : {}
"id" : "H9LWKQ3NYd",
"type" : "delimiter",
"data" : {}
},
{
type : 'paragraph',
id: "h298akk2Ad",
data : {
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 its 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. 😏'
"id" : "h298akk2Ad",
"type" : "paragraph",
"data" : {
"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 its 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. 😏"
}
},
{
type: 'image',
id: "9802bjaAA2",
data: {
url: 'assets/codex2x.png',
caption: '',
stretched: false,
withBorder: true,
withBackground: false,
"id" : "9802bjaAA2",
"type" : "image",
"data" : {
"url" : "assets/codex2x.png",
"caption" : "",
"withBorder" : true,
"withBackground" : false,
"stretched" : false
}
},
]
}
],
"version" : "2.23.0-rc.0"
},
onReady: function(){
saveButton.click();