Skip to content

Commit 1714da9

Browse files
authored
Merge pull request #61 from ben-basten/feat/missing-renderers
feat: support strikethrough mark
2 parents e029f18 + 147ca29 commit 1714da9

File tree

5 files changed

+61
-13
lines changed

5 files changed

+61
-13
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ The `nodeRenderers` prop should be one of the following `BLOCKS` and `INLINES` p
223223
- `EMBEDDED_ENTRY`
224224
- `EMBEDDED_ASSET`
225225
- `TABLE`
226+
- `TABLE_ROW`
227+
- `TABLE_CELL`
228+
- `TABLE_HEADER_CELL`
226229

227230
- `INLINES`
228231
- `EMBEDDED_ENTRY` (this is different from the `BLOCKS.EMBEDDED_ENTRY`)
@@ -238,3 +241,4 @@ The `markRenderers` prop should be one of the following `MARKS` properties as de
238241
- `CODE`
239242
- `SUBSCRIPT`
240243
- `SUPERSCRIPT`
244+
- `STRIKETHROUGH`

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"vue"
3131
],
3232
"peerDependencies": {
33-
"@contentful/rich-text-types": "^15.14.1"
33+
"@contentful/rich-text-types": "^16.5.0 || ^17.0.0"
3434
},
3535
"peerDependenciesMeta": {
3636
"@contentful/rich-text-types": {
@@ -42,7 +42,7 @@
4242
"devDependencies": {
4343
"@babel/core": "^7.12.10",
4444
"@babel/preset-env": "^7.12.11",
45-
"@contentful/rich-text-types": "^15.14.1",
45+
"@contentful/rich-text-types": "^17.0.1",
4646
"@rollup/plugin-alias": "^3.1.9",
4747
"@rollup/plugin-babel": "^5.3.1",
4848
"@rollup/plugin-commonjs": "^22.0.0",

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const defaultMarkRenderers = {
2424
[MARKS.CODE]: (children, key) => h("code", { key }, children),
2525
[MARKS.SUPERSCRIPT]: (children, key) => h("sup", { key }, children),
2626
[MARKS.SUBSCRIPT]: (children, key) => h("sub", { key }, children),
27+
[MARKS.STRIKETHROUGH]: (children, key) => h("s", { key }, children),
2728
};
2829

2930
const defaultNodeRenderers = {

src/index.test.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,19 @@ describe("RichText", () => {
4949
value: "Subpar",
5050
marks: [{ type: MARKS.SUBSCRIPT }],
5151
},
52+
{
53+
nodeType: "text",
54+
value: "Irrelevant",
55+
marks: [{ type: MARKS.STRIKETHROUGH }],
56+
},
5257
],
5358
},
5459
]);
5560
const rendered = mount(RichText, { props: { document } });
5661

5762
it("renders them all in a single paragraph", () => {
5863
expect(rendered.html()).toBe(
59-
'<p><strong>Hello</strong><em> world!</em><code>console.log("yo");</code><u>Greetings!</u><sup>Superb!</sup><sub>Subpar</sub></p>'
64+
'<p><strong>Hello</strong><em> world!</em><code>console.log("yo");</code><u>Greetings!</u><sup>Superb!</sup><sub>Subpar</sub><s>Irrelevant</s></p>'
6065
);
6166
});
6267
});
@@ -83,11 +88,23 @@ describe("RichText", () => {
8388
{ type: MARKS.SUBSCRIPT },
8489
],
8590
},
91+
{
92+
nodeType: "text",
93+
value: "!",
94+
marks: [
95+
{ type: MARKS.UNDERLINE },
96+
{ type: MARKS.ITALIC },
97+
{ type: MARKS.BOLD },
98+
{ type: MARKS.STRIKETHROUGH },
99+
],
100+
},
86101
]);
87102
const rendered = mount(RichText, { props: { document } });
88103

89104
it("renders all overlapping marks in order", () => {
90-
expect(rendered.html()).toBe("<strong><em><u><sup>Hello</sup></u></em></strong>\n<strong><em><u><sub>World</sub></u></em></strong>");
105+
expect(rendered.html()).toBe(
106+
"<strong><em><u><sup>Hello</sup></u></em></strong>\n<strong><em><u><sub>World</sub></u></em></strong>\n<u><em><strong><s>!</s></strong></em></u>"
107+
);
91108
});
92109
});
93110
});

0 commit comments

Comments
 (0)