UNPKG

@contensis/canvas-react

Version:
502 lines (501 loc) 28.6 kB
var __defProp = Object.defineProperty; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __objRest = (source, exclude) => { var target = {}; for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop]; if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) { if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop]; } return target; }; // src/renderer.tsx import React, { createContext, useContext } from "react"; var RendererContext = createContext({}); function RenderContextProvider(props) { const overrideBlocks = props.blocks; const blocks = Object.keys(BLOCK_RENDERERS).reduce((prev, type) => { const blockType = type; const renderer = (overrideBlocks == null ? void 0 : overrideBlocks[blockType]) || BLOCK_RENDERERS[blockType]; prev[blockType] = renderer; return prev; }, {}); const overrideDecorators = props.decorators; const decorators = Object.keys(DECORATOR_RENDERERS).reduce((prev, type) => { const decoratorType = type; prev[decoratorType] = (overrideDecorators == null ? void 0 : overrideDecorators[decoratorType]) || DECORATOR_RENDERERS[decoratorType]; return prev; }, {}); const value = { blocks, decorators, components: props.components }; return /* @__PURE__ */ React.createElement(RendererContext.Provider, { value }, props.children); } function useBlocks() { const value = useContext(RendererContext); return value.blocks || BLOCK_RENDERERS; } function useDecorators() { const value = useContext(RendererContext); return value.decorators || DECORATOR_RENDERERS; } function useComponents() { const value = useContext(RendererContext); return value.components || {}; } function RenderBlock(props) { const blocks = useBlocks(); const Component2 = blocks[props.block.type]; return !!Component2 ? /* @__PURE__ */ React.createElement(Component2, { block: props.block }) : null; } function RenderBlocks(props) { return /* @__PURE__ */ React.createElement(React.Fragment, null, props.blocks.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, { block, key: block.id }))); } function RenderContents(props) { return props.contents ? props.contents : props.fallback; } function RenderChildren(props) { var _a, _b; const isArray = Array.isArray((_a = props.block) == null ? void 0 : _a.value); const isString = typeof ((_b = props.block) == null ? void 0 : _b.value) === "string"; const render = () => { if (isArray) { return /* @__PURE__ */ React.createElement(RenderBlocks, { blocks: props.block.value }); } else if (isString) { return /* @__PURE__ */ React.createElement(RenderText, { text: props.block.value }); } else { return /* @__PURE__ */ React.createElement(RenderText, { text: "" }); } }; return render(); } function RenderText(props) { return /* @__PURE__ */ React.createElement(React.Fragment, null, props.text); } function Renderer(props) { return /* @__PURE__ */ React.createElement(RenderBlocks, { blocks: props.data }); } function getAttributes(props, extra = {}) { var _c; const _a = props, { block } = _a, rest = __objRest(_a, ["block"]); let _b = rest, { children, decorator, otherDecorators } = _b, attributes = __objRest(_b, ["children", "decorator", "otherDecorators"]); attributes = __spreadValues(__spreadValues({ id: (_c = block == null ? void 0 : block.properties) == null ? void 0 : _c.id }, extra), attributes); return attributes; } function WithCaption(props) { return !!props.caption ? /* @__PURE__ */ React.createElement("figure", null, props.children, /* @__PURE__ */ React.createElement("figcaption", null, props.caption)) : props.children || null; } function RenderBlockChildrenFactory() { return function(props) { return /* @__PURE__ */ React.createElement(RenderChildren, { block: props.block }); }; } function EmptyChildrenFactory() { return function(props) { return /* @__PURE__ */ React.createElement(React.Fragment, null); }; } function Anchor(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("a", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Anchor.Children, { block: props.block }) })); } Anchor.Children = RenderBlockChildrenFactory(); function Code(props) { var _a, _b, _c, _d; const attributes = getAttributes(props, { "data-language": (_b = (_a = props.block) == null ? void 0 : _a.value) == null ? void 0 : _b.language }); const codeAttributes = getAttributes(props, { className: `language-${(_d = (_c = props.block) == null ? void 0 : _c.value) == null ? void 0 : _d.language}` }); return /* @__PURE__ */ React.createElement("pre", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement("code", __spreadValues({}, codeAttributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Code.Children, { block: props.block }) }))); } Code.Children = function(props) { var _a, _b; return /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = (_a = props.block) == null ? void 0 : _a.value) == null ? void 0 : _b.code); }; function CodeWithCaption(props) { var _a, _b; return /* @__PURE__ */ React.createElement(WithCaption, { caption: (_b = (_a = props.block) == null ? void 0 : _a.value) == null ? void 0 : _b.caption }, /* @__PURE__ */ React.createElement(Code, __spreadValues({}, props))); } function Component(props) { var _a, _b; const component = (_a = props == null ? void 0 : props.block.properties) == null ? void 0 : _a.component; const components = useComponents(); const ComponentElement = !!component ? components == null ? void 0 : components[component] : void 0; const value = props.block.value ? JSON.stringify(props.block.value) : ""; const attributes = getAttributes(props, { className: "component", "data-component": (_b = props.block.properties) == null ? void 0 : _b.component, "data-component-value": value }); return !!ComponentElement ? /* @__PURE__ */ React.createElement(ComponentElement, __spreadValues({}, props)) : /* @__PURE__ */ React.createElement("div", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Component.Children, { block: props.block }) })); } Component.Children = function(props) { var _a, _b; return /* @__PURE__ */ React.createElement(React.Fragment, null, "Component: ", (_b = (_a = props.block) == null ? void 0 : _a.properties) == null ? void 0 : _b.component); }; function Divider(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("hr", __spreadValues({}, attributes)); } Divider.Children = EmptyChildrenFactory(); function FormContentType(_props) { return null; } FormContentType.Children = function(_props) { return null; }; function Fragment(props) { var _a, _b, _c, _d, _e; const hasDecorators = !!((_c = (_b = (_a = props.block) == null ? void 0 : _a.properties) == null ? void 0 : _b.decorators) == null ? void 0 : _c.length); const decorators = (_e = (_d = props.block) == null ? void 0 : _d.properties) == null ? void 0 : _e.decorators; return hasDecorators ? /* @__PURE__ */ React.createElement(Decorators, { block: props.block, decorators }) : /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Fragment.Children, { block: props.block }) }); } Fragment.Children = RenderBlockChildrenFactory(); function Heading(props) { const attributes = getAttributes(props); const render = () => { var _a, _b; switch ((_b = (_a = props == null ? void 0 : props.block) == null ? void 0 : _a.properties) == null ? void 0 : _b.level) { case 2: { return /* @__PURE__ */ React.createElement("h2", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Heading.Children, { block: props.block }) })); } case 3: { return /* @__PURE__ */ React.createElement("h3", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Heading.Children, { block: props.block }) })); } case 4: { return /* @__PURE__ */ React.createElement("h4", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Heading.Children, { block: props.block }) })); } case 5: { return /* @__PURE__ */ React.createElement("h5", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Heading.Children, { block: props.block }) })); } case 6: { return /* @__PURE__ */ React.createElement("h6", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Heading.Children, { block: props.block }) })); } default: { return /* @__PURE__ */ React.createElement("h1", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Heading.Children, { block: props.block }) })); } } }; return render(); } Heading.Children = RenderBlockChildrenFactory(); function Image(props) { var _a, _b, _c, _d, _e, _f, _g, _h; const src = (_d = (_c = (_b = (_a = props.block) == null ? void 0 : _a.value) == null ? void 0 : _b.asset) == null ? void 0 : _c.sys) == null ? void 0 : _d.uri; const attributes = getAttributes(props, { src, alt: (_f = (_e = props.block) == null ? void 0 : _e.value) == null ? void 0 : _f.altText, title: (_h = (_g = props == null ? void 0 : props.block) == null ? void 0 : _g.value) == null ? void 0 : _h.caption }); return /* @__PURE__ */ React.createElement("img", __spreadValues({}, attributes)); } Image.Children = EmptyChildrenFactory(); function ImageWithCaption(props) { var _a, _b; return /* @__PURE__ */ React.createElement(WithCaption, { caption: (_b = (_a = props.block) == null ? void 0 : _a.value) == null ? void 0 : _b.caption }, /* @__PURE__ */ React.createElement(Image, __spreadValues({}, props))); } function InlineEntry(props) { var _a, _b, _c; const href = (_c = (_b = (_a = props == null ? void 0 : props.block) == null ? void 0 : _a.value) == null ? void 0 : _b.sys) == null ? void 0 : _c.uri; const attributes = getAttributes(props, { href }); return !!attributes.href ? /* @__PURE__ */ React.createElement("a", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(InlineEntry.Children, { block: props.block }) })) : /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(InlineEntry.Children, { block: props.block }) }); } InlineEntry.Children = function(props) { var _a, _b; const entryTitle = ((_b = (_a = props == null ? void 0 : props.block) == null ? void 0 : _a.value) == null ? void 0 : _b.entryTitle) || ""; return /* @__PURE__ */ React.createElement(React.Fragment, null, entryTitle); }; function Link(props) { var _a, _b, _c, _d, _e, _f, _g; const linkValue = (_b = (_a = props == null ? void 0 : props.block) == null ? void 0 : _a.properties) == null ? void 0 : _b.link; const attributes = getAttributes(props, { href: (_c = linkValue == null ? void 0 : linkValue.sys) == null ? void 0 : _c.uri, target: ((_e = (_d = props == null ? void 0 : props.block) == null ? void 0 : _d.properties) == null ? void 0 : _e.newTab) ? "_blank" : null, rel: ((_g = (_f = props == null ? void 0 : props.block) == null ? void 0 : _f.properties) == null ? void 0 : _g.newTab) ? "noopener noreferrer" : null }); return !!attributes.href ? /* @__PURE__ */ React.createElement("a", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Link.Children, { block: props.block }) })) : /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Link.Children, { block: props.block }) }); } Link.Children = RenderBlockChildrenFactory(); function Liquid(props) { return /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Liquid.Children, { block: props.block }) }); } Liquid.Children = function(props) { var _a; return /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.block) == null ? void 0 : _a.value); }; function List(props) { var _a, _b, _c, _d; const isOrdered = ((_b = (_a = props.block) == null ? void 0 : _a.properties) == null ? void 0 : _b.listType) === "ordered"; const attributes = getAttributes(props, { start: isOrdered ? (_d = (_c = props.block) == null ? void 0 : _c.properties) == null ? void 0 : _d.start : null }); return isOrdered ? /* @__PURE__ */ React.createElement("ol", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(List.Children, { block: props.block }) })) : /* @__PURE__ */ React.createElement("ul", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(List.Children, { block: props.block }) })); } List.Children = RenderBlockChildrenFactory(); function ListItem(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("li", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(ListItem.Children, { block: props.block }) })); } ListItem.Children = RenderBlockChildrenFactory(); function Panel(props) { var _a, _b; const attributes = getAttributes(props, { className: ["panel", ((_b = (_a = props.block) == null ? void 0 : _a.properties) == null ? void 0 : _b.panelType) || "info"].join(" ") }); return /* @__PURE__ */ React.createElement("aside", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Panel.Children, { block: props.block }) })); } Panel.Children = RenderBlockChildrenFactory(); function Paragraph(props) { var _a, _b; const attributes = getAttributes(props, { className: (_b = (_a = props.block) == null ? void 0 : _a.properties) == null ? void 0 : _b.paragraphType }); return /* @__PURE__ */ React.createElement("p", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Paragraph.Children, { block: props.block }) })); } Paragraph.Children = RenderBlockChildrenFactory(); function Quote(props) { var _a, _b; const attributes = getAttributes(props, { "cite": (_b = (_a = props.block) == null ? void 0 : _a.properties) == null ? void 0 : _b.url }); return /* @__PURE__ */ React.createElement("blockquote", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Quote.Children, { block: props.block }) })); } Quote.Children = function(props) { var _a, _b, _c, _d; const source = (_b = (_a = props.block) == null ? void 0 : _a.properties) == null ? void 0 : _b.source; const citation = (_d = (_c = props.block) == null ? void 0 : _c.properties) == null ? void 0 : _d.citation; const hasChildren = !!source || !!citation; return hasChildren ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement(RenderChildren, { block: props.block })), /* @__PURE__ */ React.createElement("footer", null, source, " ", !!citation ? /* @__PURE__ */ React.createElement("cite", null, citation) : /* @__PURE__ */ React.createElement(React.Fragment, null))) : /* @__PURE__ */ React.createElement(RenderChildren, { block: props.block }); }; function Table(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("table", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Table.Children, { block: props.block }) })); } Table.Children = RenderBlockChildrenFactory(); function TableBody(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("tbody", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(TableBody.Children, { block: props.block }) })); } TableBody.Children = RenderBlockChildrenFactory(); function TableCaption(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("caption", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(TableCaption.Children, { block: props.block }) })); } TableCaption.Children = RenderBlockChildrenFactory(); function TableCell(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("td", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(TableCell.Children, { block: props.block }) })); } TableCell.Children = RenderBlockChildrenFactory(); function TableFooter(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("tfoot", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(TableFooter.Children, { block: props.block }) })); } TableFooter.Children = RenderBlockChildrenFactory(); function TableHeader(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("thead", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(TableHeader.Children, { block: props.block }) })); } TableHeader.Children = RenderBlockChildrenFactory(); function TableHeaderCell(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("th", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(TableHeaderCell.Children, { block: props.block }) })); } TableHeaderCell.Children = RenderBlockChildrenFactory(); function TableRow(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("tr", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(TableRow.Children, { block: props.block }) })); } TableRow.Children = RenderBlockChildrenFactory(); function Decorators(props) { const decorators = useDecorators(); const remainingDecorators = !!props.decorators ? [...props.decorators] : void 0; const firstDecorator = !!remainingDecorators ? remainingDecorators.shift() : void 0; const DecoratorComponent = !!firstDecorator ? decorators[firstDecorator] : void 0; const render = () => { if (!!DecoratorComponent) { return /* @__PURE__ */ React.createElement(DecoratorComponent, { block: props.block, decorator: firstDecorator, otherDecorators: remainingDecorators }); } else if (firstDecorator) { return /* @__PURE__ */ React.createElement(Decorators, { block: props.block, decorators: remainingDecorators }); } else { return /* @__PURE__ */ React.createElement(Fragment.Children, { block: props.block }); } }; return render(); } function DecoratorChildren(props) { return /* @__PURE__ */ React.createElement(Decorators, { block: props.block, decorators: props.otherDecorators }); } function InlineCode(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("code", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(InlineCode.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) })); } InlineCode.Children = DecoratorChildren; function Delete(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("del", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Delete.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) })); } Delete.Children = DecoratorChildren; function Emphasis(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("em", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Emphasis.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) })); } Emphasis.Children = DecoratorChildren; function Insert(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("ins", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Insert.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) })); } Insert.Children = DecoratorChildren; function Keyboard(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("kbd", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Keyboard.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) })); } Keyboard.Children = DecoratorChildren; function LineBreak(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("br", __spreadValues({}, attributes)); } LineBreak.Children = function(props) { return /* @__PURE__ */ React.createElement(React.Fragment, null); }; function Mark(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("mark", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Mark.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) })); } Mark.Children = DecoratorChildren; function Strong(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("strong", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Strong.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) })); } Strong.Children = DecoratorChildren; function Strikethrough(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("s", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Strikethrough.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) })); } Strikethrough.Children = DecoratorChildren; function Subscript(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("sub", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Subscript.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) })); } Subscript.Children = DecoratorChildren; function Superscript(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("sup", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Superscript.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) })); } Superscript.Children = DecoratorChildren; function Underline(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("u", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Underline.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) })); } Underline.Children = DecoratorChildren; function Variable(props) { const attributes = getAttributes(props); return /* @__PURE__ */ React.createElement("var", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(RenderContents, { contents: props.children, fallback: /* @__PURE__ */ React.createElement(Variable.Children, { block: props.block, decorator: props.decorator, otherDecorators: props.otherDecorators }) })); } Variable.Children = DecoratorChildren; var BLOCK_RENDERERS = { "_anchor": Anchor, "_code": CodeWithCaption, "_component": Component, "_divider": Divider, "_formContentType": FormContentType, "_fragment": Fragment, "_heading": Heading, "_image": ImageWithCaption, "_inlineEntry": InlineEntry, "_link": Link, "_liquid": Liquid, "_list": List, "_listItem": ListItem, "_panel": Panel, "_paragraph": Paragraph, "_quote": Quote, "_table": Table, "_tableBody": TableBody, "_tableCaption": TableCaption, "_tableCell": TableCell, "_tableFooter": TableFooter, "_tableHeader": TableHeader, "_tableHeaderCell": TableHeaderCell, "_tableRow": TableRow }; var DECORATOR_RENDERERS = { "code": InlineCode, "delete": Delete, "emphasis": Emphasis, "insert": Insert, "keyboard": Keyboard, "linebreak": LineBreak, "mark": Mark, "strikethrough": Strikethrough, "strong": Strong, "subscript": Subscript, "superscript": Superscript, "underline": Underline, "variable": Variable }; export { Anchor, Code, Component, Delete, Divider, Emphasis, FormContentType, Fragment, Heading, Image, InlineCode, InlineEntry, Insert, Keyboard, LineBreak, Link, Liquid, List, ListItem, Mark, Panel, Paragraph, Quote, RenderChildren, RenderContextProvider, Renderer, RendererContext, Strikethrough, Strong, Subscript, Superscript, Table, TableBody, TableCaption, TableCell, TableFooter, TableHeader, TableHeaderCell, TableRow, Underline, Variable }; //# sourceMappingURL=canvas-react.mjs.map