forked from thompsonsj/slate-serializers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(serializers): support more HTML tags (#2)
* docs(readme.md): add references, compatible environments and implementation details * feat(serializers): support more HTML tags * feat(htmltoslate): support text tags inside a sentence * style(*tags.ts): add EOL * build(package.json): remove dependency as not required
- Loading branch information
1 parent
b0cde46
commit 84a09a8
Showing
7 changed files
with
402 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
interface Ifixture { | ||
name: string | ||
html: string | ||
slate: object[] | ||
} | ||
|
||
export const fixtures: Ifixture[] = [ | ||
{ | ||
name: "blockquote", | ||
html: "<blockquote>Blockquote</blockquote>", | ||
slate: [ | ||
{ | ||
children: [ | ||
{ | ||
text: 'Blockquote', | ||
}, | ||
], | ||
type: 'blockquote', | ||
}, | ||
] | ||
}, | ||
{ | ||
name: "headings", | ||
html: "<h1>Heading 1</h1><h2>Heading 2</h2><h3>Heading 3</h3><h4>Heading 4</h4><h5>Heading 5</h5><h6>Heading 6</h6>", | ||
slate: [ | ||
{ | ||
children: [ | ||
{ | ||
text: 'Heading 1', | ||
}, | ||
], | ||
type: 'h1', | ||
}, | ||
{ | ||
children: [ | ||
{ | ||
text: 'Heading 2', | ||
}, | ||
], | ||
type: 'h2', | ||
}, | ||
{ | ||
children: [ | ||
{ | ||
text: 'Heading 3', | ||
}, | ||
], | ||
type: 'h3', | ||
}, | ||
{ | ||
children: [ | ||
{ | ||
text: 'Heading 4', | ||
}, | ||
], | ||
type: 'h4', | ||
}, | ||
{ | ||
children: [ | ||
{ | ||
text: 'Heading 5', | ||
}, | ||
], | ||
type: 'h5', | ||
}, | ||
{ | ||
children: [ | ||
{ | ||
text: 'Heading 6', | ||
}, | ||
], | ||
type: 'h6', | ||
}, | ||
] | ||
}, | ||
{ | ||
name: "paragraph", | ||
html: "<p>Paragraph 1</p>", | ||
slate: [ | ||
{ | ||
children: [ | ||
{ | ||
text: 'Paragraph 1', | ||
}, | ||
], | ||
type: 'p', | ||
}, | ||
] | ||
}, | ||
{ | ||
name: "link", | ||
html: '<a href="https://github.com/thompsonsj/slate-serializers">Slate Serializers | GitHub</a>', | ||
slate: [ | ||
{ | ||
children: [ | ||
{ | ||
text: 'Slate Serializers | GitHub', | ||
}, | ||
], | ||
newTab: false, | ||
type: 'link', | ||
url: 'https://github.com/thompsonsj/slate-serializers', | ||
}, | ||
] | ||
}, | ||
{ | ||
name: "unordered list", | ||
html: '<ul><li>Item 1</li><li>Item 2</li></ul>', | ||
slate: [ | ||
{ | ||
children: [ | ||
{ | ||
children: [ | ||
{ | ||
text: 'Item 1', | ||
}, | ||
], | ||
type: 'li', | ||
}, | ||
{ | ||
children: [ | ||
{ | ||
text: 'Item 2', | ||
}, | ||
], | ||
type: 'li', | ||
}, | ||
], | ||
type: 'ul', | ||
}, | ||
] | ||
}, | ||
{ | ||
name: "nested unordered list", | ||
html: '<ul><li>Item 1<ul><li>Nested item 1</li><li>Nested item 2</li></ul></li><li>Item 2</li></ul>', | ||
slate: [ | ||
{ | ||
children: [ | ||
{ | ||
children: [ | ||
{ | ||
text: 'Item 1', | ||
}, | ||
{ | ||
children: [ | ||
{ | ||
children: [ | ||
{ | ||
text: 'Nested item 1', | ||
}, | ||
], | ||
type: "li" | ||
}, | ||
{ | ||
children: [ | ||
{ | ||
text: 'Nested item 2', | ||
}, | ||
], | ||
type: "li" | ||
} | ||
], | ||
type: 'ul' | ||
}, | ||
], | ||
type: 'li', | ||
}, | ||
{ | ||
children: [ | ||
{ | ||
text: 'Item 2', | ||
}, | ||
], | ||
type: 'li', | ||
}, | ||
], | ||
type: 'ul', | ||
}, | ||
] | ||
}, | ||
{ | ||
name: "ordered list", | ||
html: '<ol><li>Item 1</li><li>Item 2</li></ol>', | ||
slate: [ | ||
{ | ||
children: [ | ||
{ | ||
children: [ | ||
{ | ||
text: 'Item 1', | ||
}, | ||
], | ||
type: 'li', | ||
}, | ||
{ | ||
children: [ | ||
{ | ||
text: 'Item 2', | ||
}, | ||
], | ||
type: 'li', | ||
}, | ||
], | ||
type: 'ol', | ||
}, | ||
] | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
interface Ifixture { | ||
name: string | ||
html: string | ||
slate: object[] | ||
} | ||
|
||
export const fixtures: Ifixture[] = [ | ||
{ | ||
name: "strong", | ||
html: "<strong>Bold</strong>", | ||
slate: [ | ||
{ | ||
children: [ | ||
{ | ||
bold: true, | ||
text: "Bold" | ||
} | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "strong in paragraph", | ||
html: "<p><strong>Bold</strong></p>", | ||
slate: [ | ||
{ | ||
children: [ | ||
{ | ||
bold: true, | ||
text: "Bold" | ||
}, | ||
], | ||
type: 'p', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "strong mid-sentence", | ||
html: "Some <strong>bold text</strong> in a sentence.", | ||
/* | ||
Expected but not received: | ||
{ | ||
"text": "Some " | ||
}, | ||
{ | ||
"text": "bold text", | ||
"bold": true | ||
}, | ||
{ | ||
"text": " in a sentence." | ||
} | ||
*/ | ||
slate: [ | ||
{ | ||
"children": [ | ||
{ | ||
"text": "Some ", | ||
}, | ||
], | ||
}, | ||
{ | ||
"children": [ | ||
{ | ||
"bold": true, | ||
"text": "bold text", | ||
}, | ||
], | ||
}, | ||
{ | ||
"children": [ | ||
{ | ||
"text": " in a sentence.", | ||
}, | ||
], | ||
} | ||
] | ||
}, | ||
{ | ||
name: "pre", | ||
html: "<pre><code>Pre</code></pre>", | ||
slate: [ | ||
{ | ||
children: [ | ||
{ | ||
code: true, | ||
text: "Pre", | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
] |
Oops, something went wrong.