Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract inline fragments from HTML markup #1801

Draft
wants to merge 6 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
266 changes: 180 additions & 86 deletions example/example-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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'
// },

},

Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"terser-webpack-plugin": "^2.3.6",
"ts-loader": "^7.0.1",
"tslint": "^6.1.1",
"typescript": "3.8.3",
"typescript": "4.4.3",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
},
Expand Down
Loading