@contensis/canvas-react 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +169 -0
- package/dist/canvas-react.d.mts +480 -0
- package/dist/canvas-react.d.ts +480 -0
- package/dist/canvas-react.js +513 -0
- package/dist/canvas-react.js.map +1 -0
- package/dist/canvas-react.mjs +450 -0
- package/dist/canvas-react.mjs.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
// src/renderer.tsx
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var RendererContext = createContext({});
|
|
5
|
+
function RenderContextProvider(props) {
|
|
6
|
+
const overrideBlocks = props.blocks;
|
|
7
|
+
const blocks = Object.keys(BLOCK_RENDERERS).reduce((prev, type) => {
|
|
8
|
+
const blockType = type;
|
|
9
|
+
prev[blockType] = overrideBlocks?.[blockType] || BLOCK_RENDERERS[blockType];
|
|
10
|
+
return prev;
|
|
11
|
+
}, {});
|
|
12
|
+
const overrideDecorators = props.decorators;
|
|
13
|
+
const decorators = Object.keys(DECORATOR_RENDERERS).reduce((prev, type) => {
|
|
14
|
+
const decoratorType = type;
|
|
15
|
+
prev[decoratorType] = overrideDecorators?.[decoratorType] || DECORATOR_RENDERERS[decoratorType];
|
|
16
|
+
return prev;
|
|
17
|
+
}, {});
|
|
18
|
+
const value = { blocks, decorators, components: props.components };
|
|
19
|
+
return /* @__PURE__ */ jsx(RendererContext.Provider, { value, children: props.children });
|
|
20
|
+
}
|
|
21
|
+
function useBlocks() {
|
|
22
|
+
const value = useContext(RendererContext);
|
|
23
|
+
return value.blocks || BLOCK_RENDERERS;
|
|
24
|
+
}
|
|
25
|
+
function useDecorators() {
|
|
26
|
+
const value = useContext(RendererContext);
|
|
27
|
+
return value.decorators || DECORATOR_RENDERERS;
|
|
28
|
+
}
|
|
29
|
+
function useComponents() {
|
|
30
|
+
const value = useContext(RendererContext);
|
|
31
|
+
return value.components || {};
|
|
32
|
+
}
|
|
33
|
+
function RenderBlock(props) {
|
|
34
|
+
const blocks = useBlocks();
|
|
35
|
+
const Component2 = blocks[props.block.type];
|
|
36
|
+
return /* @__PURE__ */ jsx(Component2, { block: props.block });
|
|
37
|
+
}
|
|
38
|
+
function RenderBlocks(props) {
|
|
39
|
+
return /* @__PURE__ */ jsx(Fragment, { children: props.blocks.map((block) => /* @__PURE__ */ jsx(RenderBlock, { block }, block.id)) });
|
|
40
|
+
}
|
|
41
|
+
function RenderContents(props) {
|
|
42
|
+
return props.contents ? props.contents : props.fallback;
|
|
43
|
+
}
|
|
44
|
+
function RenderChildren(props) {
|
|
45
|
+
const isArray = Array.isArray(props.block?.value);
|
|
46
|
+
const isString = typeof props.block?.value === "string";
|
|
47
|
+
const render = () => {
|
|
48
|
+
if (isArray) {
|
|
49
|
+
return /* @__PURE__ */ jsx(RenderBlocks, { blocks: props.block.value });
|
|
50
|
+
} else if (isString) {
|
|
51
|
+
return /* @__PURE__ */ jsx(RenderText, { text: props.block.value });
|
|
52
|
+
} else {
|
|
53
|
+
return /* @__PURE__ */ jsx(RenderText, { text: "" });
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return render();
|
|
57
|
+
}
|
|
58
|
+
function RenderText(props) {
|
|
59
|
+
return /* @__PURE__ */ jsx(Fragment, { children: props.text });
|
|
60
|
+
}
|
|
61
|
+
function Renderer(props) {
|
|
62
|
+
return /* @__PURE__ */ jsx(RenderBlocks, { blocks: props.data });
|
|
63
|
+
}
|
|
64
|
+
function getAttributes(props, extra = {}) {
|
|
65
|
+
const { block, ...rest } = props;
|
|
66
|
+
let { children, decorator, otherDecorators, ...attributes } = rest;
|
|
67
|
+
attributes = {
|
|
68
|
+
id: block?.properties?.id,
|
|
69
|
+
...extra,
|
|
70
|
+
...attributes
|
|
71
|
+
};
|
|
72
|
+
return attributes;
|
|
73
|
+
}
|
|
74
|
+
function WithCaption(props) {
|
|
75
|
+
return !!props.caption ? /* @__PURE__ */ jsxs("figure", { children: [
|
|
76
|
+
props.children,
|
|
77
|
+
/* @__PURE__ */ jsx("figcaption", { children: props.caption })
|
|
78
|
+
] }) : props.children;
|
|
79
|
+
}
|
|
80
|
+
function RenderBlockChildrenFactory() {
|
|
81
|
+
return function(props) {
|
|
82
|
+
return /* @__PURE__ */ jsx(RenderChildren, { block: props.block });
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function EmptyChildrenFactory() {
|
|
86
|
+
return function(props) {
|
|
87
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function Anchor(props) {
|
|
91
|
+
const attributes = getAttributes(props);
|
|
92
|
+
return /* @__PURE__ */ jsx("a", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Anchor.Children, { block: props.block }) }) });
|
|
93
|
+
}
|
|
94
|
+
Anchor.Children = RenderBlockChildrenFactory();
|
|
95
|
+
function Code(props) {
|
|
96
|
+
const attributes = getAttributes(props, {
|
|
97
|
+
"data-language": props.block?.value?.language
|
|
98
|
+
});
|
|
99
|
+
const codeAttributes = getAttributes(props, {
|
|
100
|
+
className: `language-${props.block?.value?.language}`
|
|
101
|
+
});
|
|
102
|
+
return /* @__PURE__ */ jsx("pre", { ...attributes, children: /* @__PURE__ */ jsx("code", { ...codeAttributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Code.Children, { block: props.block }) }) }) });
|
|
103
|
+
}
|
|
104
|
+
Code.Children = function(props) {
|
|
105
|
+
return /* @__PURE__ */ jsx(Fragment, { children: props.block?.value?.code });
|
|
106
|
+
};
|
|
107
|
+
function CodeWithCaption(props) {
|
|
108
|
+
return /* @__PURE__ */ jsx(WithCaption, { caption: props.block?.value?.caption, children: /* @__PURE__ */ jsx(Code, { ...props }) });
|
|
109
|
+
}
|
|
110
|
+
function Component(props) {
|
|
111
|
+
const component = props?.block.properties?.component;
|
|
112
|
+
const components = useComponents();
|
|
113
|
+
const ComponentElement = !!component ? components?.[component] : void 0;
|
|
114
|
+
const value = props.block.value ? JSON.stringify(props.block.value) : "";
|
|
115
|
+
const attributes = getAttributes(props, {
|
|
116
|
+
className: "component",
|
|
117
|
+
"data-component": props.block.properties?.component,
|
|
118
|
+
"data-component-value": value
|
|
119
|
+
});
|
|
120
|
+
return !!ComponentElement ? /* @__PURE__ */ jsx(ComponentElement, { ...props }) : /* @__PURE__ */ jsx("div", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Component.Children, { block: props.block }) }) });
|
|
121
|
+
}
|
|
122
|
+
Component.Children = function(props) {
|
|
123
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
124
|
+
"Component: ",
|
|
125
|
+
props.block?.properties?.component
|
|
126
|
+
] });
|
|
127
|
+
};
|
|
128
|
+
function Divider(props) {
|
|
129
|
+
const attributes = getAttributes(props);
|
|
130
|
+
return /* @__PURE__ */ jsx("hr", { ...attributes });
|
|
131
|
+
}
|
|
132
|
+
Divider.Children = EmptyChildrenFactory();
|
|
133
|
+
function Fragment2(props) {
|
|
134
|
+
const hasDecorators = !!props.block?.properties?.decorators?.length;
|
|
135
|
+
const decorators = props.block?.properties?.decorators;
|
|
136
|
+
return hasDecorators ? /* @__PURE__ */ jsx(Decorators, { block: props.block, decorators }) : /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Fragment2.Children, { block: props.block }) });
|
|
137
|
+
}
|
|
138
|
+
Fragment2.Children = RenderBlockChildrenFactory();
|
|
139
|
+
function Heading(props) {
|
|
140
|
+
const attributes = getAttributes(props);
|
|
141
|
+
const render = () => {
|
|
142
|
+
switch (props?.block?.properties?.level) {
|
|
143
|
+
case 2: {
|
|
144
|
+
return /* @__PURE__ */ jsx("h2", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Heading.Children, { block: props.block }) }) });
|
|
145
|
+
}
|
|
146
|
+
case 3: {
|
|
147
|
+
return /* @__PURE__ */ jsx("h3", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Heading.Children, { block: props.block }) }) });
|
|
148
|
+
}
|
|
149
|
+
case 4: {
|
|
150
|
+
return /* @__PURE__ */ jsx("h4", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Heading.Children, { block: props.block }) }) });
|
|
151
|
+
}
|
|
152
|
+
case 5: {
|
|
153
|
+
return /* @__PURE__ */ jsx("h5", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Heading.Children, { block: props.block }) }) });
|
|
154
|
+
}
|
|
155
|
+
case 6: {
|
|
156
|
+
return /* @__PURE__ */ jsx("h6", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Heading.Children, { block: props.block }) }) });
|
|
157
|
+
}
|
|
158
|
+
default: {
|
|
159
|
+
return /* @__PURE__ */ jsx("h1", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Heading.Children, { block: props.block }) }) });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
return render();
|
|
164
|
+
}
|
|
165
|
+
Heading.Children = RenderBlockChildrenFactory();
|
|
166
|
+
function Image(props) {
|
|
167
|
+
const src = props.block?.value?.asset?.sys?.uri;
|
|
168
|
+
const attributes = getAttributes(props, {
|
|
169
|
+
src,
|
|
170
|
+
alt: props.block?.value?.altText,
|
|
171
|
+
title: props?.block?.value?.caption
|
|
172
|
+
});
|
|
173
|
+
return /* @__PURE__ */ jsx("img", { ...attributes });
|
|
174
|
+
}
|
|
175
|
+
Image.Children = EmptyChildrenFactory();
|
|
176
|
+
function ImageWithCaption(props) {
|
|
177
|
+
return /* @__PURE__ */ jsx(WithCaption, { caption: props.block?.value?.caption, children: /* @__PURE__ */ jsx(Image, { ...props }) });
|
|
178
|
+
}
|
|
179
|
+
function InlineEntry(props) {
|
|
180
|
+
const href = props?.block?.value?.sys?.uri;
|
|
181
|
+
const attributes = getAttributes(props, {
|
|
182
|
+
href
|
|
183
|
+
});
|
|
184
|
+
return !!attributes.href ? /* @__PURE__ */ jsx("a", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(InlineEntry.Children, { block: props.block }) }) }) : /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(InlineEntry.Children, { block: props.block }) });
|
|
185
|
+
}
|
|
186
|
+
InlineEntry.Children = function(props) {
|
|
187
|
+
const entryTitle = props?.block?.value?.entryTitle || "";
|
|
188
|
+
return /* @__PURE__ */ jsx(Fragment, { children: entryTitle });
|
|
189
|
+
};
|
|
190
|
+
function Link(props) {
|
|
191
|
+
const linkValue = props?.block?.properties?.link;
|
|
192
|
+
const attributes = getAttributes(props, {
|
|
193
|
+
href: linkValue?.sys?.uri,
|
|
194
|
+
target: props?.block?.properties?.newTab ? "_blank" : null,
|
|
195
|
+
rel: props?.block?.properties?.newTab ? "noopener noreferrer" : null
|
|
196
|
+
});
|
|
197
|
+
return !!attributes.href ? /* @__PURE__ */ jsx("a", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Link.Children, { block: props.block }) }) }) : /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Link.Children, { block: props.block }) });
|
|
198
|
+
}
|
|
199
|
+
Link.Children = RenderBlockChildrenFactory();
|
|
200
|
+
function List(props) {
|
|
201
|
+
const isOrdered = props.block?.properties?.listType === "ordered";
|
|
202
|
+
const attributes = getAttributes(props, {
|
|
203
|
+
start: isOrdered ? props.block?.properties?.start : null
|
|
204
|
+
});
|
|
205
|
+
return isOrdered ? /* @__PURE__ */ jsx("ol", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(List.Children, { block: props.block }) }) }) : /* @__PURE__ */ jsx("ul", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(List.Children, { block: props.block }) }) });
|
|
206
|
+
}
|
|
207
|
+
List.Children = RenderBlockChildrenFactory();
|
|
208
|
+
function ListItem(props) {
|
|
209
|
+
const attributes = getAttributes(props);
|
|
210
|
+
return /* @__PURE__ */ jsx("li", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(ListItem.Children, { block: props.block }) }) });
|
|
211
|
+
}
|
|
212
|
+
ListItem.Children = RenderBlockChildrenFactory();
|
|
213
|
+
function Panel(props) {
|
|
214
|
+
const attributes = getAttributes(props, {
|
|
215
|
+
className: ["panel", props.block?.properties?.panelType || "info"].join(" ")
|
|
216
|
+
});
|
|
217
|
+
return /* @__PURE__ */ jsx("aside", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Panel.Children, { block: props.block }) }) });
|
|
218
|
+
}
|
|
219
|
+
Panel.Children = RenderBlockChildrenFactory();
|
|
220
|
+
function Paragraph(props) {
|
|
221
|
+
const attributes = getAttributes(props, {
|
|
222
|
+
className: props.block?.properties?.paragraphType
|
|
223
|
+
});
|
|
224
|
+
return /* @__PURE__ */ jsx("p", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Paragraph.Children, { block: props.block }) }) });
|
|
225
|
+
}
|
|
226
|
+
Paragraph.Children = RenderBlockChildrenFactory();
|
|
227
|
+
function Quote(props) {
|
|
228
|
+
const attributes = getAttributes(props, {
|
|
229
|
+
"cite": props.block?.properties?.url
|
|
230
|
+
});
|
|
231
|
+
return /* @__PURE__ */ jsx("blockquote", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Quote.Children, { block: props.block }) }) });
|
|
232
|
+
}
|
|
233
|
+
Quote.Children = function(props) {
|
|
234
|
+
const source = props.block?.properties?.source;
|
|
235
|
+
const citation = props.block?.properties?.citation;
|
|
236
|
+
const hasChildren = !!source || !!citation;
|
|
237
|
+
return hasChildren ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
238
|
+
/* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(RenderChildren, { block: props.block }) }),
|
|
239
|
+
/* @__PURE__ */ jsxs("footer", { children: [
|
|
240
|
+
source,
|
|
241
|
+
" ",
|
|
242
|
+
!!citation ? /* @__PURE__ */ jsx("cite", { children: citation }) : /* @__PURE__ */ jsx(Fragment, {})
|
|
243
|
+
] })
|
|
244
|
+
] }) : /* @__PURE__ */ jsx(RenderChildren, { block: props.block });
|
|
245
|
+
};
|
|
246
|
+
function Table(props) {
|
|
247
|
+
const attributes = getAttributes(props);
|
|
248
|
+
return /* @__PURE__ */ jsx("table", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Table.Children, { block: props.block }) }) });
|
|
249
|
+
}
|
|
250
|
+
Table.Children = RenderBlockChildrenFactory();
|
|
251
|
+
function TableBody(props) {
|
|
252
|
+
const attributes = getAttributes(props);
|
|
253
|
+
return /* @__PURE__ */ jsx("tbody", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(TableBody.Children, { block: props.block }) }) });
|
|
254
|
+
}
|
|
255
|
+
TableBody.Children = RenderBlockChildrenFactory();
|
|
256
|
+
function TableCaption(props) {
|
|
257
|
+
const attributes = getAttributes(props);
|
|
258
|
+
return /* @__PURE__ */ jsx("caption", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(TableCaption.Children, { block: props.block }) }) });
|
|
259
|
+
}
|
|
260
|
+
TableCaption.Children = RenderBlockChildrenFactory();
|
|
261
|
+
function TableCell(props) {
|
|
262
|
+
const attributes = getAttributes(props);
|
|
263
|
+
return /* @__PURE__ */ jsx("td", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(TableCell.Children, { block: props.block }) }) });
|
|
264
|
+
}
|
|
265
|
+
TableCell.Children = RenderBlockChildrenFactory();
|
|
266
|
+
function TableFooter(props) {
|
|
267
|
+
const attributes = getAttributes(props);
|
|
268
|
+
return /* @__PURE__ */ jsx("tfoot", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(TableFooter.Children, { block: props.block }) }) });
|
|
269
|
+
}
|
|
270
|
+
TableFooter.Children = RenderBlockChildrenFactory();
|
|
271
|
+
function TableHeader(props) {
|
|
272
|
+
const attributes = getAttributes(props);
|
|
273
|
+
return /* @__PURE__ */ jsx("thead", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(TableHeader.Children, { block: props.block }) }) });
|
|
274
|
+
}
|
|
275
|
+
TableHeader.Children = RenderBlockChildrenFactory();
|
|
276
|
+
function TableHeaderCell(props) {
|
|
277
|
+
const attributes = getAttributes(props);
|
|
278
|
+
return /* @__PURE__ */ jsx("th", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(TableHeaderCell.Children, { block: props.block }) }) });
|
|
279
|
+
}
|
|
280
|
+
TableHeaderCell.Children = RenderBlockChildrenFactory();
|
|
281
|
+
function TableRow(props) {
|
|
282
|
+
const attributes = getAttributes(props);
|
|
283
|
+
return /* @__PURE__ */ jsx("tr", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(TableRow.Children, { block: props.block }) }) });
|
|
284
|
+
}
|
|
285
|
+
TableRow.Children = RenderBlockChildrenFactory();
|
|
286
|
+
function Decorators(props) {
|
|
287
|
+
const decorators = useDecorators();
|
|
288
|
+
const remainingDecorators = !!props.decorators ? [...props.decorators] : void 0;
|
|
289
|
+
const firstDecorator = !!remainingDecorators ? remainingDecorators.shift() : void 0;
|
|
290
|
+
const DecoratorComponent = !!firstDecorator ? decorators[firstDecorator] : void 0;
|
|
291
|
+
const render = () => {
|
|
292
|
+
if (!!DecoratorComponent) {
|
|
293
|
+
return /* @__PURE__ */ jsx(DecoratorComponent, { block: props.block, decorator: firstDecorator, otherDecorators: remainingDecorators });
|
|
294
|
+
} else if (firstDecorator) {
|
|
295
|
+
return /* @__PURE__ */ jsx(Decorators, { block: props.block, decorators: remainingDecorators });
|
|
296
|
+
} else {
|
|
297
|
+
return /* @__PURE__ */ jsx(Fragment2.Children, { block: props.block });
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
return render();
|
|
301
|
+
}
|
|
302
|
+
function DecoratorChildren(props) {
|
|
303
|
+
return /* @__PURE__ */ jsx(Decorators, { block: props.block, decorators: props.otherDecorators });
|
|
304
|
+
}
|
|
305
|
+
function InlineCode(props) {
|
|
306
|
+
const attributes = getAttributes(props);
|
|
307
|
+
return /* @__PURE__ */ jsx("code", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(InlineCode.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) }) });
|
|
308
|
+
}
|
|
309
|
+
InlineCode.Children = DecoratorChildren;
|
|
310
|
+
function Delete(props) {
|
|
311
|
+
const attributes = getAttributes(props);
|
|
312
|
+
return /* @__PURE__ */ jsx("del", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Delete.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) }) });
|
|
313
|
+
}
|
|
314
|
+
Delete.Children = DecoratorChildren;
|
|
315
|
+
function Emphasis(props) {
|
|
316
|
+
const attributes = getAttributes(props);
|
|
317
|
+
return /* @__PURE__ */ jsx("em", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Emphasis.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) }) });
|
|
318
|
+
}
|
|
319
|
+
Emphasis.Children = DecoratorChildren;
|
|
320
|
+
function Insert(props) {
|
|
321
|
+
const attributes = getAttributes(props);
|
|
322
|
+
return /* @__PURE__ */ jsx("ins", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Insert.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) }) });
|
|
323
|
+
}
|
|
324
|
+
Insert.Children = DecoratorChildren;
|
|
325
|
+
function Keyboard(props) {
|
|
326
|
+
const attributes = getAttributes(props);
|
|
327
|
+
return /* @__PURE__ */ jsx("kbd", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Keyboard.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) }) });
|
|
328
|
+
}
|
|
329
|
+
Keyboard.Children = DecoratorChildren;
|
|
330
|
+
function LineBreak(props) {
|
|
331
|
+
const attributes = getAttributes(props);
|
|
332
|
+
return /* @__PURE__ */ jsx("br", { ...attributes });
|
|
333
|
+
}
|
|
334
|
+
LineBreak.Children = function(props) {
|
|
335
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
336
|
+
};
|
|
337
|
+
function Mark(props) {
|
|
338
|
+
const attributes = getAttributes(props);
|
|
339
|
+
return /* @__PURE__ */ jsx("mark", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Mark.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) }) });
|
|
340
|
+
}
|
|
341
|
+
Mark.Children = DecoratorChildren;
|
|
342
|
+
function Strong(props) {
|
|
343
|
+
const attributes = getAttributes(props);
|
|
344
|
+
return /* @__PURE__ */ jsx("strong", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Strong.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) }) });
|
|
345
|
+
}
|
|
346
|
+
Strong.Children = DecoratorChildren;
|
|
347
|
+
function Strikethrough(props) {
|
|
348
|
+
const attributes = getAttributes(props);
|
|
349
|
+
return /* @__PURE__ */ jsx("s", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Strikethrough.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) }) });
|
|
350
|
+
}
|
|
351
|
+
Strikethrough.Children = DecoratorChildren;
|
|
352
|
+
function Subscript(props) {
|
|
353
|
+
const attributes = getAttributes(props);
|
|
354
|
+
return /* @__PURE__ */ jsx("sub", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Subscript.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) }) });
|
|
355
|
+
}
|
|
356
|
+
Subscript.Children = DecoratorChildren;
|
|
357
|
+
function Superscript(props) {
|
|
358
|
+
const attributes = getAttributes(props);
|
|
359
|
+
return /* @__PURE__ */ jsx("sup", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Superscript.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) }) });
|
|
360
|
+
}
|
|
361
|
+
Superscript.Children = DecoratorChildren;
|
|
362
|
+
function Underline(props) {
|
|
363
|
+
const attributes = getAttributes(props);
|
|
364
|
+
return /* @__PURE__ */ jsx("u", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Underline.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) }) });
|
|
365
|
+
}
|
|
366
|
+
Underline.Children = DecoratorChildren;
|
|
367
|
+
function Variable(props) {
|
|
368
|
+
const attributes = getAttributes(props);
|
|
369
|
+
return /* @__PURE__ */ jsx("var", { ...attributes, children: /* @__PURE__ */ jsx(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ jsx(Variable.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) }) });
|
|
370
|
+
}
|
|
371
|
+
Variable.Children = DecoratorChildren;
|
|
372
|
+
var BLOCK_RENDERERS = {
|
|
373
|
+
"_anchor": Anchor,
|
|
374
|
+
"_code": CodeWithCaption,
|
|
375
|
+
"_component": Component,
|
|
376
|
+
"_divider": Divider,
|
|
377
|
+
"_fragment": Fragment2,
|
|
378
|
+
"_heading": Heading,
|
|
379
|
+
"_image": ImageWithCaption,
|
|
380
|
+
"_inlineEntry": InlineEntry,
|
|
381
|
+
"_link": Link,
|
|
382
|
+
"_list": List,
|
|
383
|
+
"_listItem": ListItem,
|
|
384
|
+
"_panel": Panel,
|
|
385
|
+
"_paragraph": Paragraph,
|
|
386
|
+
"_quote": Quote,
|
|
387
|
+
"_table": Table,
|
|
388
|
+
"_tableBody": TableBody,
|
|
389
|
+
"_tableCaption": TableCaption,
|
|
390
|
+
"_tableCell": TableCell,
|
|
391
|
+
"_tableFooter": TableFooter,
|
|
392
|
+
"_tableHeader": TableHeader,
|
|
393
|
+
"_tableHeaderCell": TableHeaderCell,
|
|
394
|
+
"_tableRow": TableRow
|
|
395
|
+
};
|
|
396
|
+
var DECORATOR_RENDERERS = {
|
|
397
|
+
"code": InlineCode,
|
|
398
|
+
"delete": Delete,
|
|
399
|
+
"emphasis": Emphasis,
|
|
400
|
+
"insert": Insert,
|
|
401
|
+
"keyboard": Keyboard,
|
|
402
|
+
"linebreak": LineBreak,
|
|
403
|
+
"mark": Mark,
|
|
404
|
+
"strikethrough": Strikethrough,
|
|
405
|
+
"strong": Strong,
|
|
406
|
+
"subscript": Subscript,
|
|
407
|
+
"superscript": Superscript,
|
|
408
|
+
"underline": Underline,
|
|
409
|
+
"variable": Variable
|
|
410
|
+
};
|
|
411
|
+
export {
|
|
412
|
+
Anchor,
|
|
413
|
+
Code,
|
|
414
|
+
Component,
|
|
415
|
+
Delete,
|
|
416
|
+
Divider,
|
|
417
|
+
Emphasis,
|
|
418
|
+
Fragment2 as Fragment,
|
|
419
|
+
Heading,
|
|
420
|
+
Image,
|
|
421
|
+
InlineCode,
|
|
422
|
+
InlineEntry,
|
|
423
|
+
Insert,
|
|
424
|
+
Keyboard,
|
|
425
|
+
LineBreak,
|
|
426
|
+
Link,
|
|
427
|
+
List,
|
|
428
|
+
ListItem,
|
|
429
|
+
Mark,
|
|
430
|
+
Panel,
|
|
431
|
+
Paragraph,
|
|
432
|
+
RenderContextProvider,
|
|
433
|
+
Renderer,
|
|
434
|
+
RendererContext,
|
|
435
|
+
Strikethrough,
|
|
436
|
+
Strong,
|
|
437
|
+
Subscript,
|
|
438
|
+
Superscript,
|
|
439
|
+
Table,
|
|
440
|
+
TableBody,
|
|
441
|
+
TableCaption,
|
|
442
|
+
TableCell,
|
|
443
|
+
TableFooter,
|
|
444
|
+
TableHeader,
|
|
445
|
+
TableHeaderCell,
|
|
446
|
+
TableRow,
|
|
447
|
+
Underline,
|
|
448
|
+
Variable
|
|
449
|
+
};
|
|
450
|
+
//# sourceMappingURL=canvas-react.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/renderer.tsx"],"sourcesContent":["import {\n AnchorBlock, CodeBlock, ComponentBlock, Block, DecoratorType, DividerBlock,\n FragmentBlock, HeadingBlock, ImageBlock, InlineEntryBlock, LinkBlock,\n ListBlock, ListItemBlock, PanelBlock, ParagraphBlock, QuoteBlock, TableBodyBlock,\n TableCaptionBlock, TableCellBlock, TableBlock, TableFooterBlock,\n TableHeaderCellBlock, TableHeaderBlock, TableRowBlock\n} from '@contensis/canvas-types';\nimport { createContext, useContext } from 'react';\n\ntype Attributes = Record<string, any>;\ntype WithChildren = { children?: JSX.Element };\n\ntype RendererProps = { data: Block[] };\ntype RenderBlocksProps = { blocks: Block[] };\ntype RenderBlockProps<T extends Block> = { block: T };\ntype RenderBlockPropsWithChildren<T extends Block>\n = RenderBlockProps<T> & WithChildren & Attributes;\n\ntype RenderContentsProps = { contents: undefined | JSX.Element, fallback: JSX.Element };\ntype RenderTextProps = { text: string };\n\ntype DecoratorProps = { block: FragmentBlock, decorators: undefined | DecoratorType[] };\n\ntype TypedBlock<TType extends Block['type']> = Extract<Block, { type: TType }>;\n\ntype BlockRenderer<T extends Block> = (props: RenderBlockPropsWithChildren<T>) => JSX.Element;\ntype BlockRenderers = {\n [TType in Block['type']]: BlockRenderer<TypedBlock<TType>>\n};\n\n\ntype RenderDecoratorProps = { block: FragmentBlock, decorator: undefined | DecoratorType, otherDecorators: undefined | DecoratorType[] };\ntype RenderDecoratorPropsWithChildren = RenderDecoratorProps & WithChildren & Attributes;\n\ntype DecoratorRenderer = (props: RenderDecoratorPropsWithChildren) => JSX.Element;\ntype DecoratorRenderers = Record<DecoratorType, DecoratorRenderer>;\n\ntype ComponentRenderer = (props: RenderBlockPropsWithChildren<ComponentBlock>) => JSX.Element;\ntype ComponentRenderers = Record<string, ComponentRenderer>;\n\ntype RendererContextValue = {\n blocks?: BlockRenderers,\n decorators?: DecoratorRenderers,\n components?: ComponentRenderers\n};\n\ntype RendererOverridesContextValue = {\n blocks?: Partial<BlockRenderers>,\n decorators?: Partial<DecoratorRenderers>,\n components?: ComponentRenderers\n};\n\ntype RendererContextProviderProps = { children: JSX.Element } & RendererOverridesContextValue;\n\nexport const RendererContext = createContext<RendererContextValue>({});\n\nexport function RenderContextProvider(props: RendererContextProviderProps) {\n const overrideBlocks = props.blocks;\n const blocks = Object.keys(BLOCK_RENDERERS)\n .reduce((prev, type) => {\n const blockType = type as Block['type'];\n prev[blockType] = (overrideBlocks?.[blockType] || BLOCK_RENDERERS[blockType]) as BlockRenderer<TypedBlock<typeof blockType>>;\n return prev;\n }, {} as BlockRenderers);\n\n const overrideDecorators = props.decorators;\n const decorators = Object.keys(DECORATOR_RENDERERS)\n .reduce((prev, type) => {\n const decoratorType = type as DecoratorType;\n prev[decoratorType] = overrideDecorators?.[decoratorType] || DECORATOR_RENDERERS[decoratorType];\n return prev;\n }, {} as DecoratorRenderers);\n\n const value = { blocks, decorators, components: props.components };\n\n return (\n <RendererContext.Provider value={value}>\n {props.children}\n </RendererContext.Provider>\n );\n}\n\nfunction useBlocks() {\n const value = useContext(RendererContext);\n return value.blocks || BLOCK_RENDERERS;\n}\n\nfunction useDecorators() {\n const value = useContext(RendererContext);\n return value.decorators || DECORATOR_RENDERERS;\n}\n\nfunction useComponents() {\n const value = useContext(RendererContext);\n return value.components || {};\n}\n\nfunction RenderBlock<TBlock extends Block>(props: RenderBlockProps<TBlock>) {\n const blocks = useBlocks();\n const Component = blocks[props.block.type] as BlockRenderer<TBlock>;\n return (<Component block={props.block} />);\n}\n\nfunction RenderBlocks(props: RenderBlocksProps) {\n return (<>{props.blocks.map(block => <RenderBlock block={block} key={block.id} />)}</>);\n}\n\nfunction RenderContents(props: RenderContentsProps) {\n return (props.contents ? props.contents : props.fallback);\n}\n\nfunction RenderChildren(props: RenderBlockProps<Block>) {\n const isArray = Array.isArray(props.block?.value);\n const isString = typeof props.block?.value === 'string';\n\n const render = () => {\n if (isArray) {\n return (<RenderBlocks blocks={props.block.value as any} />);\n } else if (isString) {\n return (<RenderText text={props.block.value as any} />);\n } else {\n return (<RenderText text={''} />);\n }\n };\n\n return render();\n};\n\nfunction RenderText(props: RenderTextProps) {\n return (<>{props.text}</>);\n};\n\nexport function Renderer(props: RendererProps) {\n return (<RenderBlocks blocks={props.data} />);\n}\n\ntype AttributeProps = RenderBlockProps<Block>\n | RenderBlockPropsWithChildren<Block>\n | RenderDecoratorProps\n | RenderDecoratorPropsWithChildren;\n\nfunction getAttributes(props: AttributeProps, extra: Record<string, any> = {}) {\n const { block, ...rest } = props;\n let { children, decorator, otherDecorators, ...attributes } = rest as Record<string, any>;\n attributes = {\n id: block?.properties?.id,\n ...extra,\n ...attributes\n };\n return attributes;\n}\n\nfunction WithCaption(props: { caption: undefined | string, children: JSX.Element }) {\n return (\n !!props.caption\n ? (\n <figure>\n {props.children}\n <figcaption>{props.caption}</figcaption>\n </figure>\n )\n : props.children\n );\n};\n\nfunction RenderBlockChildrenFactory<T extends Block>() {\n return function (props: RenderBlockProps<T>) {\n return (<RenderChildren block={props.block} />);\n };\n}\n\nfunction EmptyChildrenFactory<T extends Block>() {\n return function (props: RenderBlockProps<T>) {\n return (<></>);\n };\n}\n\nexport function Anchor(props: RenderBlockPropsWithChildren<AnchorBlock>) {\n const attributes = getAttributes(props);\n return (\n <a {...attributes}>\n <RenderContents contents={props.children} fallback={<Anchor.Children block={props.block} />} />\n </a>\n );\n}\n\nAnchor.Children = RenderBlockChildrenFactory<AnchorBlock>();\n\nexport function Code(props: RenderBlockPropsWithChildren<CodeBlock>) {\n const attributes = getAttributes(props, {\n 'data-language': props.block?.value?.language\n });\n const codeAttributes = getAttributes(props, {\n className: `language-${props.block?.value?.language}`\n });\n return (\n <pre {...attributes}>\n <code {...codeAttributes}>\n <RenderContents contents={props.children} fallback={<Code.Children block={props.block} />} />\n </code>\n </pre>\n );\n}\n\nCode.Children = function (props: RenderBlockProps<CodeBlock>) {\n return (<>{props.block?.value?.code}</>);\n};\n\nfunction CodeWithCaption(props: RenderBlockPropsWithChildren<CodeBlock>) {\n return (\n <WithCaption caption={props.block?.value?.caption}>\n <Code {...props} />\n </WithCaption>\n );\n}\n\nexport function Component(props: RenderBlockPropsWithChildren<ComponentBlock>) {\n const component = props?.block.properties?.component;\n const components = useComponents();\n const ComponentElement = !!component ? components?.[component] : undefined;\n\n const value = props.block.value ? JSON.stringify(props.block.value) : '';\n const attributes = getAttributes(props, {\n className: 'component',\n 'data-component': props.block.properties?.component,\n 'data-component-value': value,\n });\n\n return (!!ComponentElement)\n ? (<ComponentElement {...props} />)\n : (\n <div {...attributes}>\n <RenderContents contents={props.children} fallback={<Component.Children block={props.block} />} />\n </div>\n );\n}\n\nComponent.Children = function (props: RenderBlockProps<ComponentBlock>) {\n return (<>Component: {props.block?.properties?.component}</>);\n};\n\nexport function Divider(props: RenderBlockPropsWithChildren<DividerBlock>) {\n const attributes = getAttributes(props);\n return (<hr {...attributes} />);\n}\n\nDivider.Children = EmptyChildrenFactory<DividerBlock>();\n\nexport function Fragment(props: RenderBlockPropsWithChildren<FragmentBlock>) {\n const hasDecorators = !!props.block?.properties?.decorators?.length;\n const decorators = props.block?.properties?.decorators;\n return (\n hasDecorators\n ? (<Decorators block={props.block} decorators={decorators}></Decorators>)\n : (<RenderContents contents={props.children} fallback={<Fragment.Children block={props.block} />} />)\n );\n}\n\nFragment.Children = RenderBlockChildrenFactory<FragmentBlock>();\n\nexport function Heading(props: RenderBlockPropsWithChildren<HeadingBlock>) {\n const attributes = getAttributes(props);\n const render = () => {\n switch (props?.block?.properties?.level) {\n case 2: {\n return (\n <h2 {...attributes}>\n <RenderContents contents={props.children} fallback={<Heading.Children block={props.block} />} />\n </h2>\n );\n }\n case 3: {\n return (\n <h3 {...attributes}>\n <RenderContents contents={props.children} fallback={<Heading.Children block={props.block} />} />\n </h3>\n );\n }\n case 4: {\n return (\n <h4 {...attributes}>\n <RenderContents contents={props.children} fallback={<Heading.Children block={props.block} />} />\n </h4>\n );\n }\n case 5: {\n return (\n <h5 {...attributes}>\n <RenderContents contents={props.children} fallback={<Heading.Children block={props.block} />} />\n </h5>\n );\n }\n case 6: {\n return (\n <h6 {...attributes}>\n <RenderContents contents={props.children} fallback={<Heading.Children block={props.block} />} />\n </h6>\n );\n }\n default: {\n return (\n <h1 {...attributes}>\n <RenderContents contents={props.children} fallback={<Heading.Children block={props.block} />} />\n </h1>\n );\n }\n }\n };\n return render();\n}\n\nHeading.Children = RenderBlockChildrenFactory<HeadingBlock>();\n\nexport function Image(props: RenderBlockPropsWithChildren<ImageBlock>) {\n const src = props.block?.value?.asset?.sys?.uri;\n const attributes = getAttributes(props, {\n src,\n alt: props.block?.value?.altText,\n title: props?.block?.value?.caption,\n });\n return (<img {...attributes} />);\n}\n\nImage.Children = EmptyChildrenFactory<ImageBlock>();\n\nfunction ImageWithCaption(props: RenderBlockPropsWithChildren<ImageBlock>) {\n return (\n <WithCaption caption={props.block?.value?.caption}>\n <Image {...props} />\n </WithCaption>\n );\n}\n\nexport function InlineEntry(props: RenderBlockPropsWithChildren<InlineEntryBlock>) {\n const href = props?.block?.value?.sys?.uri;\n const attributes = getAttributes(props, {\n href\n });\n return (!!attributes.href\n ? (\n <a {...attributes}>\n <RenderContents contents={props.children} fallback={<InlineEntry.Children block={props.block} />} />\n </a>\n )\n : (<RenderContents contents={props.children} fallback={<InlineEntry.Children block={props.block} />} />)\n );\n}\n\nInlineEntry.Children = function (props: RenderBlockProps<InlineEntryBlock>) {\n const entryTitle = props?.block?.value?.entryTitle || '';\n return (<>{entryTitle}</>);\n};\n\nexport function Link(props: RenderBlockPropsWithChildren<LinkBlock>) {\n const linkValue = props?.block?.properties?.link;\n const attributes = getAttributes(props, {\n href: linkValue?.sys?.uri,\n target: props?.block?.properties?.newTab ? '_blank' : null,\n rel: props?.block?.properties?.newTab ? 'noopener noreferrer' : null\n });\n return (!!attributes.href\n ? (\n <a {...attributes}>\n <RenderContents contents={props.children} fallback={<Link.Children block={props.block} />} />\n </a>\n )\n : (<RenderContents contents={props.children} fallback={<Link.Children block={props.block} />} />)\n );\n}\n\nLink.Children = RenderBlockChildrenFactory<LinkBlock>();\n\nexport function List(props: RenderBlockPropsWithChildren<ListBlock>) {\n const isOrdered = (props.block?.properties?.listType === 'ordered');\n const attributes = getAttributes(props, {\n start: isOrdered ? props.block?.properties?.start : null,\n });\n return (isOrdered\n ? (\n <ol {...attributes}>\n <RenderContents contents={props.children} fallback={<List.Children block={props.block} />} />\n </ol>\n )\n : (\n <ul {...attributes}>\n <RenderContents contents={props.children} fallback={<List.Children block={props.block} />} />\n </ul>\n )\n );\n}\n\nList.Children = RenderBlockChildrenFactory<ListBlock>();\n\nexport function ListItem(props: RenderBlockPropsWithChildren<ListItemBlock>) {\n const attributes = getAttributes(props);\n return (\n <li {...attributes}>\n <RenderContents contents={props.children} fallback={<ListItem.Children block={props.block} />} />\n </li>\n );\n}\n\nListItem.Children = RenderBlockChildrenFactory<ListItemBlock>();\n\nexport function Panel(props: RenderBlockPropsWithChildren<PanelBlock>) {\n const attributes = getAttributes(props, {\n className: ['panel', props.block?.properties?.panelType || 'info'].join(' ')\n });\n return (\n <aside {...attributes}>\n <RenderContents contents={props.children} fallback={<Panel.Children block={props.block} />} />\n </aside>\n );\n}\n\nPanel.Children = RenderBlockChildrenFactory<PanelBlock>();\n\nexport function Paragraph(props: RenderBlockPropsWithChildren<ParagraphBlock>) {\n const attributes = getAttributes(props, {\n className: props.block?.properties?.paragraphType\n });\n return (\n <p {...attributes}>\n <RenderContents contents={props.children} fallback={<Paragraph.Children block={props.block} />} />\n </p>\n );\n}\n\nParagraph.Children = RenderBlockChildrenFactory<ParagraphBlock>();\n\n\nexport function Quote(props: RenderBlockPropsWithChildren<QuoteBlock>) {\n const attributes = getAttributes(props, {\n 'cite': props.block?.properties?.url\n });\n return (\n <blockquote {...attributes}>\n <RenderContents contents={props.children} fallback={<Quote.Children block={props.block} />} />\n </blockquote>\n );\n}\n\nQuote.Children = function (props: RenderBlockProps<QuoteBlock>) {\n const source = props.block?.properties?.source;\n const citation = props.block?.properties?.citation;\n const hasChildren = !!source || !!citation;\n return (\n hasChildren\n ? (\n <>\n <p>\n <RenderChildren block={props.block} />\n </p>\n <footer>{source} {!!citation ? (<cite>{citation}</cite>) : (<></>)}</footer>\n </>\n )\n : (<RenderChildren block={props.block} />)\n );\n // return (<RenderChildren block={props.block} />);\n // return (\n // <Show when={hasChildren()} fallback={<RenderChildren block={props.block} />}>\n // <p>\n // <RenderChildren block={props.block} />\n // </p>\n // <Show when={citation()} fallback={<footer>{source()}</footer>}>\n // <footer>{source()} <cite>{citation()}</cite></footer>\n // </Show>\n // </Show>\n // );\n};\n\n\nexport function Table(props: RenderBlockPropsWithChildren<TableBlock>) {\n const attributes = getAttributes(props);\n return (\n <table {...attributes}>\n <RenderContents contents={props.children} fallback={<Table.Children block={props.block} />} />\n </table>\n );\n}\n\nTable.Children = RenderBlockChildrenFactory<TableBlock>();\n\nexport function TableBody(props: RenderBlockPropsWithChildren<TableBodyBlock>) {\n const attributes = getAttributes(props);\n return (\n <tbody {...attributes}>\n <RenderContents contents={props.children} fallback={<TableBody.Children block={props.block} />} />\n </tbody>\n );\n}\n\nTableBody.Children = RenderBlockChildrenFactory<TableBodyBlock>();\n\nexport function TableCaption(props: RenderBlockPropsWithChildren<TableCaptionBlock>) {\n const attributes = getAttributes(props);\n return (\n <caption {...attributes}>\n <RenderContents contents={props.children} fallback={<TableCaption.Children block={props.block} />} />\n </caption>\n );\n}\n\nTableCaption.Children = RenderBlockChildrenFactory<TableCaptionBlock>();\n\nexport function TableCell(props: RenderBlockPropsWithChildren<TableCellBlock>) {\n const attributes = getAttributes(props);\n return (\n <td {...attributes}>\n <RenderContents contents={props.children} fallback={<TableCell.Children block={props.block} />} />\n </td>\n );\n}\n\nTableCell.Children = RenderBlockChildrenFactory<TableCellBlock>();\n\nexport function TableFooter(props: RenderBlockPropsWithChildren<TableFooterBlock>) {\n const attributes = getAttributes(props);\n return (\n <tfoot {...attributes}>\n <RenderContents contents={props.children} fallback={<TableFooter.Children block={props.block} />} />\n </tfoot>\n );\n}\n\nTableFooter.Children = RenderBlockChildrenFactory<TableFooterBlock>();\n\nexport function TableHeader(props: RenderBlockPropsWithChildren<TableHeaderBlock>) {\n const attributes = getAttributes(props);\n return (\n <thead {...attributes}>\n <RenderContents contents={props.children} fallback={<TableHeader.Children block={props.block} />} />\n </thead>\n );\n}\n\nTableHeader.Children = RenderBlockChildrenFactory<TableHeaderBlock>();\n\nexport function TableHeaderCell(props: RenderBlockPropsWithChildren<TableHeaderCellBlock>) {\n const attributes = getAttributes(props);\n return (\n <th {...attributes}>\n <RenderContents contents={props.children} fallback={<TableHeaderCell.Children block={props.block} />} />\n </th>\n );\n}\n\nTableHeaderCell.Children = RenderBlockChildrenFactory<TableHeaderCellBlock>();\n\nexport function TableRow(props: RenderBlockPropsWithChildren<TableRowBlock>) {\n const attributes = getAttributes(props);\n return (\n <tr {...attributes}>\n <RenderContents contents={props.children} fallback={<TableRow.Children block={props.block} />} />\n </tr>\n );\n}\n\nTableRow.Children = RenderBlockChildrenFactory<TableRowBlock>();\n\n\nfunction Decorators(props: DecoratorProps) {\n const decorators = useDecorators();\n const remainingDecorators = !!props.decorators ? [...props.decorators] : undefined;\n const firstDecorator = !!remainingDecorators ? remainingDecorators.shift() : undefined;\n const DecoratorComponent = !!firstDecorator ? decorators[firstDecorator] : undefined;\n\n const render = () => {\n if (!!DecoratorComponent) {\n return (<DecoratorComponent block={props.block} decorator={firstDecorator} otherDecorators={remainingDecorators} />);\n } else if (firstDecorator) {\n return (<Decorators block={props.block} decorators={remainingDecorators} />);\n } else {\n return (<Fragment.Children block={props.block} />);\n }\n };\n\n return render();\n}\n\nfunction DecoratorChildren(props: RenderDecoratorPropsWithChildren) {\n return (<Decorators block={props.block} decorators={props.otherDecorators} />)\n}\n\nexport function InlineCode(props: RenderDecoratorPropsWithChildren) {\n const attributes = getAttributes(props);\n return (\n <code {...attributes}>\n <RenderContents contents={props.children} fallback={<InlineCode.Children block={props.block} decorator={props.decorator} otherDecorators={props.otherDecorators} />} />\n </code>\n );\n}\n\nInlineCode.Children = DecoratorChildren;\n\nexport function Delete(props: RenderDecoratorPropsWithChildren) {\n const attributes = getAttributes(props);\n return (\n <del {...attributes}>\n <RenderContents contents={props.children} fallback={<Delete.Children block={props.block} decorator={props.decorator} otherDecorators={props.otherDecorators} />} />\n </del>\n );\n}\n\nDelete.Children = DecoratorChildren;\n\nexport function Emphasis(props: RenderDecoratorPropsWithChildren) {\n const attributes = getAttributes(props);\n return (\n <em {...attributes}>\n <RenderContents contents={props.children} fallback={<Emphasis.Children block={props.block} decorator={props.decorator} otherDecorators={props.otherDecorators} />} />\n </em>\n );\n}\n\nEmphasis.Children = DecoratorChildren;\n\nexport function Insert(props: RenderDecoratorPropsWithChildren) {\n const attributes = getAttributes(props);\n return (\n <ins {...attributes}>\n <RenderContents contents={props.children} fallback={<Insert.Children block={props.block} decorator={props.decorator} otherDecorators={props.otherDecorators} />} />\n </ins>\n );\n}\n\nInsert.Children = DecoratorChildren;\n\nexport function Keyboard(props: RenderDecoratorPropsWithChildren) {\n const attributes = getAttributes(props);\n return (\n <kbd {...attributes}>\n <RenderContents contents={props.children} fallback={<Keyboard.Children block={props.block} decorator={props.decorator} otherDecorators={props.otherDecorators} />} />\n </kbd>\n );\n}\n\nKeyboard.Children = DecoratorChildren;\n\nexport function LineBreak(props: RenderDecoratorPropsWithChildren) {\n const attributes = getAttributes(props);\n return (<br {...attributes} />);\n}\n\nLineBreak.Children = function (props: RenderDecoratorPropsWithChildren) {\n return (<></>)\n}\n\nexport function Mark(props: RenderDecoratorPropsWithChildren) {\n const attributes = getAttributes(props);\n return (\n <mark {...attributes}>\n <RenderContents contents={props.children} fallback={<Mark.Children block={props.block} decorator={props.decorator} otherDecorators={props.otherDecorators} />} />\n </mark>\n );\n}\n\nMark.Children = DecoratorChildren;\n\nexport function Strong(props: RenderDecoratorPropsWithChildren) {\n const attributes = getAttributes(props);\n return (\n <strong {...attributes}>\n <RenderContents contents={props.children} fallback={<Strong.Children block={props.block} decorator={props.decorator} otherDecorators={props.otherDecorators} />} />\n </strong>\n );\n}\n\nStrong.Children = DecoratorChildren;\n\nexport function Strikethrough(props: RenderDecoratorPropsWithChildren) {\n const attributes = getAttributes(props);\n return (\n <s {...attributes}>\n <RenderContents contents={props.children} fallback={<Strikethrough.Children block={props.block} decorator={props.decorator} otherDecorators={props.otherDecorators} />} />\n </s>\n );\n}\n\nStrikethrough.Children = DecoratorChildren;\n\nexport function Subscript(props: RenderDecoratorPropsWithChildren) {\n const attributes = getAttributes(props);\n return (\n <sub {...attributes}>\n <RenderContents contents={props.children} fallback={<Subscript.Children block={props.block} decorator={props.decorator} otherDecorators={props.otherDecorators} />} />\n </sub>\n );\n}\n\nSubscript.Children = DecoratorChildren;\n\nexport function Superscript(props: RenderDecoratorPropsWithChildren) {\n const attributes = getAttributes(props);\n return (\n <sup {...attributes}>\n <RenderContents contents={props.children} fallback={<Superscript.Children block={props.block} decorator={props.decorator} otherDecorators={props.otherDecorators} />} />\n </sup>\n );\n}\n\nSuperscript.Children = DecoratorChildren;\n\nexport function Underline(props: RenderDecoratorPropsWithChildren) {\n const attributes = getAttributes(props);\n return (\n <u {...attributes}>\n <RenderContents contents={props.children} fallback={<Underline.Children block={props.block} decorator={props.decorator} otherDecorators={props.otherDecorators} />} />\n </u>\n );\n}\n\nUnderline.Children = DecoratorChildren;\n\nexport function Variable(props: RenderDecoratorPropsWithChildren) {\n const attributes = getAttributes(props);\n return (\n <var {...attributes}>\n <RenderContents contents={props.children} fallback={<Variable.Children block={props.block} decorator={props.decorator} otherDecorators={props.otherDecorators} />} />\n </var>\n );\n}\n\nVariable.Children = DecoratorChildren;\n\n\nconst BLOCK_RENDERERS: BlockRenderers = {\n '_anchor': Anchor,\n '_code': CodeWithCaption,\n '_component': Component,\n '_divider': Divider,\n '_fragment': Fragment,\n '_heading': Heading,\n '_image': ImageWithCaption,\n '_inlineEntry': InlineEntry,\n '_link': Link,\n '_list': List,\n '_listItem': ListItem,\n '_panel': Panel,\n '_paragraph': Paragraph,\n '_quote': Quote,\n '_table': Table,\n '_tableBody': TableBody,\n '_tableCaption': TableCaption,\n '_tableCell': TableCell,\n '_tableFooter': TableFooter,\n '_tableHeader': TableHeader,\n '_tableHeaderCell': TableHeaderCell,\n '_tableRow': TableRow,\n};\n\nconst DECORATOR_RENDERERS: DecoratorRenderers = {\n 'code': InlineCode,\n 'delete': Delete,\n 'emphasis': Emphasis,\n 'insert': Insert,\n 'keyboard': Keyboard,\n 'linebreak': LineBreak,\n 'mark': Mark,\n 'strikethrough': Strikethrough,\n 'strong': Strong,\n 'subscript': Subscript,\n 'superscript': Superscript,\n 'underline': Underline,\n 'variable': Variable\n};"],"mappings":";AAOA,SAAS,eAAe,kBAAkB;AAqElC,SA4BI,UA5BJ,KAgFQ,YAhFR;AAtBD,IAAM,kBAAkB,cAAoC,CAAC,CAAC;AAE9D,SAAS,sBAAsB,OAAqC;AACvE,QAAM,iBAAiB,MAAM;AAC7B,QAAM,SAAS,OAAO,KAAK,eAAe,EACrC,OAAO,CAAC,MAAM,SAAS;AACpB,UAAM,YAAY;AAClB,SAAK,SAAS,IAAK,iBAAiB,SAAS,KAAK,gBAAgB,SAAS;AAC3E,WAAO;AAAA,EACX,GAAG,CAAC,CAAmB;AAE3B,QAAM,qBAAqB,MAAM;AACjC,QAAM,aAAa,OAAO,KAAK,mBAAmB,EAC7C,OAAO,CAAC,MAAM,SAAS;AACpB,UAAM,gBAAgB;AACtB,SAAK,aAAa,IAAI,qBAAqB,aAAa,KAAK,oBAAoB,aAAa;AAC9F,WAAO;AAAA,EACX,GAAG,CAAC,CAAuB;AAE/B,QAAM,QAAQ,EAAE,QAAQ,YAAY,YAAY,MAAM,WAAW;AAEjE,SACI,oBAAC,gBAAgB,UAAhB,EAAyB,OACrB,gBAAM,UACX;AAER;AAEA,SAAS,YAAY;AACjB,QAAM,QAAQ,WAAW,eAAe;AACxC,SAAO,MAAM,UAAU;AAC3B;AAEA,SAAS,gBAAgB;AACrB,QAAM,QAAQ,WAAW,eAAe;AACxC,SAAO,MAAM,cAAc;AAC/B;AAEA,SAAS,gBAAgB;AACrB,QAAM,QAAQ,WAAW,eAAe;AACxC,SAAO,MAAM,cAAc,CAAC;AAChC;AAEA,SAAS,YAAkC,OAAiC;AACxE,QAAM,SAAS,UAAU;AACzB,QAAMA,aAAY,OAAO,MAAM,MAAM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AAA,EACV,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU;AAAA,EACV,cAAc;AAAA,EACd,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,aAAa;AACjB;AAEA,IAAM,sBAA0C;AAAA,EAC5C,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,aAAa;AAAA,EACb,eAAe;AAAA,EACf,aAAa;AAAA,EACb,YAAY;AAChB;","names":["Component","Fragment"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contensis/canvas-react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Render canvas content with React",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"contensis",
|
|
7
|
+
"canvas",
|
|
8
|
+
"react",
|
|
9
|
+
"render",
|
|
10
|
+
"jsx"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/contensis/canvas/tree/main/packages/react",
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Zengenti",
|
|
15
|
+
"url": "https://www.contensis.com/"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/contensis/canvas.git"
|
|
20
|
+
},
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"main": "dist/canvas-react.js",
|
|
23
|
+
"module": "dist/canvas-react.mjs",
|
|
24
|
+
"types": "dist/canvas-react.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"prebuild": "npm run tsc",
|
|
30
|
+
"build": "tsup --dts-resolve",
|
|
31
|
+
"tsc": "tsc --noEmit"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"react": ">16.8.0",
|
|
35
|
+
"react-dom": ">16.8.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@contensis/canvas-types": "^0.0.1",
|
|
39
|
+
"@types/react": "^18.0.28",
|
|
40
|
+
"@types/react-dom": "^18.0.11",
|
|
41
|
+
"@vitejs/plugin-react": "^3.1.0",
|
|
42
|
+
"vite": "^4.1.4"
|
|
43
|
+
},
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"require": "./dist/canvas-react.js",
|
|
47
|
+
"import": "./dist/canvas-react.mjs",
|
|
48
|
+
"types": "./dist/canvas-react.d.ts"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|