@contember/react-client 1.3.0-alpha.7 → 1.3.0-alpha.9
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/dist/development/index.cjs +9 -5
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +1 -4
- package/dist/development/index.js.map +1 -1
- package/dist/development/upload/useFileUpload.cjs.map +1 -1
- package/dist/development/upload/useFileUpload.js.map +1 -1
- package/dist/development/useGraphQlClient.cjs.map +1 -1
- package/dist/development/useGraphQlClient.js.map +1 -1
- package/dist/production/index.cjs +9 -5
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +1 -4
- package/dist/production/index.js.map +1 -1
- package/dist/production/upload/useFileUpload.cjs.map +1 -1
- package/dist/production/upload/useFileUpload.js.map +1 -1
- package/dist/production/useGraphQlClient.cjs.map +1 -1
- package/dist/production/useGraphQlClient.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/index.ts +1 -1
- package/src/tsconfig.json +1 -0
- package/dist/development/components/RichTextRenderer/ElementRenderer.cjs +0 -27
- package/dist/development/components/RichTextRenderer/ElementRenderer.cjs.map +0 -1
- package/dist/development/components/RichTextRenderer/ElementRenderer.js +0 -27
- package/dist/development/components/RichTextRenderer/ElementRenderer.js.map +0 -1
- package/dist/development/components/RichTextRenderer/LeafRenderer.cjs +0 -28
- package/dist/development/components/RichTextRenderer/LeafRenderer.cjs.map +0 -1
- package/dist/development/components/RichTextRenderer/LeafRenderer.js +0 -28
- package/dist/development/components/RichTextRenderer/LeafRenderer.js.map +0 -1
- package/dist/development/components/RichTextRenderer/RenderElementFallback.cjs +0 -155
- package/dist/development/components/RichTextRenderer/RenderElementFallback.cjs.map +0 -1
- package/dist/development/components/RichTextRenderer/RenderElementFallback.js +0 -155
- package/dist/development/components/RichTextRenderer/RenderElementFallback.js.map +0 -1
- package/dist/development/components/RichTextRenderer/RenderLeafFallback.cjs +0 -74
- package/dist/development/components/RichTextRenderer/RenderLeafFallback.cjs.map +0 -1
- package/dist/development/components/RichTextRenderer/RenderLeafFallback.js +0 -74
- package/dist/development/components/RichTextRenderer/RenderLeafFallback.js.map +0 -1
- package/dist/development/components/RichTextRenderer/RichTextRenderMetadataContext.cjs +0 -15
- package/dist/development/components/RichTextRenderer/RichTextRenderMetadataContext.cjs.map +0 -1
- package/dist/development/components/RichTextRenderer/RichTextRenderMetadataContext.js +0 -15
- package/dist/development/components/RichTextRenderer/RichTextRenderMetadataContext.js.map +0 -1
- package/dist/development/components/RichTextRenderer/RichTextRenderer.cjs +0 -124
- package/dist/development/components/RichTextRenderer/RichTextRenderer.cjs.map +0 -1
- package/dist/development/components/RichTextRenderer/RichTextRenderer.js +0 -124
- package/dist/development/components/RichTextRenderer/RichTextRenderer.js.map +0 -1
- package/dist/development/components/RichTextRenderer/RichTextRendererError.cjs +0 -6
- package/dist/development/components/RichTextRenderer/RichTextRendererError.cjs.map +0 -1
- package/dist/development/components/RichTextRenderer/RichTextRendererError.js +0 -6
- package/dist/development/components/RichTextRenderer/RichTextRendererError.js.map +0 -1
- package/dist/development/components/RichTextRenderer/defaultDeserialize.cjs +0 -14
- package/dist/development/components/RichTextRenderer/defaultDeserialize.cjs.map +0 -1
- package/dist/development/components/RichTextRenderer/defaultDeserialize.js +0 -14
- package/dist/development/components/RichTextRenderer/defaultDeserialize.js.map +0 -1
- package/dist/development/components/RichTextRenderer/renderChildren.cjs +0 -33
- package/dist/development/components/RichTextRenderer/renderChildren.cjs.map +0 -1
- package/dist/development/components/RichTextRenderer/renderChildren.js +0 -33
- package/dist/development/components/RichTextRenderer/renderChildren.js.map +0 -1
- package/dist/development/components/RichTextRenderer/resolveRichTextElementMetadata.cjs +0 -29
- package/dist/development/components/RichTextRenderer/resolveRichTextElementMetadata.cjs.map +0 -1
- package/dist/development/components/RichTextRenderer/resolveRichTextElementMetadata.js +0 -29
- package/dist/development/components/RichTextRenderer/resolveRichTextElementMetadata.js.map +0 -1
- package/dist/production/components/RichTextRenderer/ElementRenderer.cjs +0 -23
- package/dist/production/components/RichTextRenderer/ElementRenderer.cjs.map +0 -1
- package/dist/production/components/RichTextRenderer/ElementRenderer.js +0 -23
- package/dist/production/components/RichTextRenderer/ElementRenderer.js.map +0 -1
- package/dist/production/components/RichTextRenderer/LeafRenderer.cjs +0 -24
- package/dist/production/components/RichTextRenderer/LeafRenderer.cjs.map +0 -1
- package/dist/production/components/RichTextRenderer/LeafRenderer.js +0 -24
- package/dist/production/components/RichTextRenderer/LeafRenderer.js.map +0 -1
- package/dist/production/components/RichTextRenderer/RenderElementFallback.cjs +0 -82
- package/dist/production/components/RichTextRenderer/RenderElementFallback.cjs.map +0 -1
- package/dist/production/components/RichTextRenderer/RenderElementFallback.js +0 -82
- package/dist/production/components/RichTextRenderer/RenderElementFallback.js.map +0 -1
- package/dist/production/components/RichTextRenderer/RenderLeafFallback.cjs +0 -38
- package/dist/production/components/RichTextRenderer/RenderLeafFallback.cjs.map +0 -1
- package/dist/production/components/RichTextRenderer/RenderLeafFallback.js +0 -38
- package/dist/production/components/RichTextRenderer/RenderLeafFallback.js.map +0 -1
- package/dist/production/components/RichTextRenderer/RichTextRenderMetadataContext.cjs +0 -15
- package/dist/production/components/RichTextRenderer/RichTextRenderMetadataContext.cjs.map +0 -1
- package/dist/production/components/RichTextRenderer/RichTextRenderMetadataContext.js +0 -15
- package/dist/production/components/RichTextRenderer/RichTextRenderMetadataContext.js.map +0 -1
- package/dist/production/components/RichTextRenderer/RichTextRenderer.cjs +0 -109
- package/dist/production/components/RichTextRenderer/RichTextRenderer.cjs.map +0 -1
- package/dist/production/components/RichTextRenderer/RichTextRenderer.js +0 -109
- package/dist/production/components/RichTextRenderer/RichTextRenderer.js.map +0 -1
- package/dist/production/components/RichTextRenderer/RichTextRendererError.cjs +0 -6
- package/dist/production/components/RichTextRenderer/RichTextRendererError.cjs.map +0 -1
- package/dist/production/components/RichTextRenderer/RichTextRendererError.js +0 -6
- package/dist/production/components/RichTextRenderer/RichTextRendererError.js.map +0 -1
- package/dist/production/components/RichTextRenderer/defaultDeserialize.cjs +0 -14
- package/dist/production/components/RichTextRenderer/defaultDeserialize.cjs.map +0 -1
- package/dist/production/components/RichTextRenderer/defaultDeserialize.js +0 -14
- package/dist/production/components/RichTextRenderer/defaultDeserialize.js.map +0 -1
- package/dist/production/components/RichTextRenderer/renderChildren.cjs +0 -21
- package/dist/production/components/RichTextRenderer/renderChildren.cjs.map +0 -1
- package/dist/production/components/RichTextRenderer/renderChildren.js +0 -21
- package/dist/production/components/RichTextRenderer/renderChildren.js.map +0 -1
- package/dist/production/components/RichTextRenderer/resolveRichTextElementMetadata.cjs +0 -29
- package/dist/production/components/RichTextRenderer/resolveRichTextElementMetadata.cjs.map +0 -1
- package/dist/production/components/RichTextRenderer/resolveRichTextElementMetadata.js +0 -29
- package/dist/production/components/RichTextRenderer/resolveRichTextElementMetadata.js.map +0 -1
- package/dist/types/components/RichTextRenderer/BuiltinElements.d.ts +0 -49
- package/dist/types/components/RichTextRenderer/BuiltinElements.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/BuiltinLeaves.d.ts +0 -21
- package/dist/types/components/RichTextRenderer/BuiltinLeaves.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/ElementRenderer.d.ts +0 -22
- package/dist/types/components/RichTextRenderer/ElementRenderer.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/LeafRenderer.d.ts +0 -14
- package/dist/types/components/RichTextRenderer/LeafRenderer.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/NormalizedRichTextBlock.d.ts +0 -14
- package/dist/types/components/RichTextRenderer/NormalizedRichTextBlock.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/ReferenceRenderer.d.ts +0 -14
- package/dist/types/components/RichTextRenderer/ReferenceRenderer.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/RenderElementFallback.d.ts +0 -12
- package/dist/types/components/RichTextRenderer/RenderElementFallback.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/RenderLeafFallback.d.ts +0 -6
- package/dist/types/components/RichTextRenderer/RenderLeafFallback.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/RichTextBlock.d.ts +0 -2
- package/dist/types/components/RichTextRenderer/RichTextBlock.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/RichTextElement.d.ts +0 -7
- package/dist/types/components/RichTextRenderer/RichTextElement.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/RichTextElementMetadata.d.ts +0 -11
- package/dist/types/components/RichTextRenderer/RichTextElementMetadata.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/RichTextLeaf.d.ts +0 -4
- package/dist/types/components/RichTextRenderer/RichTextLeaf.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/RichTextLeafMetadata.d.ts +0 -4
- package/dist/types/components/RichTextRenderer/RichTextLeafMetadata.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/RichTextReference.d.ts +0 -4
- package/dist/types/components/RichTextRenderer/RichTextReference.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/RichTextRenderMetadata.d.ts +0 -12
- package/dist/types/components/RichTextRenderer/RichTextRenderMetadata.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/RichTextRenderMetadataContext.d.ts +0 -7
- package/dist/types/components/RichTextRenderer/RichTextRenderMetadataContext.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/RichTextRenderer.d.ts +0 -33
- package/dist/types/components/RichTextRenderer/RichTextRenderer.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/RichTextRendererError.d.ts +0 -3
- package/dist/types/components/RichTextRenderer/RichTextRendererError.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/RootEditorNode.d.ts +0 -9
- package/dist/types/components/RichTextRenderer/RootEditorNode.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/defaultDeserialize.d.ts +0 -5
- package/dist/types/components/RichTextRenderer/defaultDeserialize.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/index.d.ts +0 -16
- package/dist/types/components/RichTextRenderer/index.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/renderChildren.d.ts +0 -14
- package/dist/types/components/RichTextRenderer/renderChildren.d.ts.map +0 -1
- package/dist/types/components/RichTextRenderer/resolveRichTextElementMetadata.d.ts +0 -8
- package/dist/types/components/RichTextRenderer/resolveRichTextElementMetadata.d.ts.map +0 -1
- package/dist/types/components/index.d.ts +0 -2
- package/dist/types/components/index.d.ts.map +0 -1
- package/src/components/RichTextRenderer/BuiltinElements.ts +0 -112
- package/src/components/RichTextRenderer/BuiltinLeaves.ts +0 -32
- package/src/components/RichTextRenderer/ElementRenderer.tsx +0 -71
- package/src/components/RichTextRenderer/LeafRenderer.tsx +0 -39
- package/src/components/RichTextRenderer/NormalizedRichTextBlock.ts +0 -17
- package/src/components/RichTextRenderer/ReferenceRenderer.ts +0 -26
- package/src/components/RichTextRenderer/RenderElementFallback.tsx +0 -147
- package/src/components/RichTextRenderer/RenderLeafFallback.tsx +0 -43
- package/src/components/RichTextRenderer/RichTextBlock.ts +0 -1
- package/src/components/RichTextRenderer/RichTextElement.ts +0 -10
- package/src/components/RichTextRenderer/RichTextElementMetadata.ts +0 -15
- package/src/components/RichTextRenderer/RichTextLeaf.ts +0 -3
- package/src/components/RichTextRenderer/RichTextLeafMetadata.ts +0 -3
- package/src/components/RichTextRenderer/RichTextReference.ts +0 -3
- package/src/components/RichTextRenderer/RichTextRenderMetadata.ts +0 -16
- package/src/components/RichTextRenderer/RichTextRenderMetadataContext.ts +0 -20
- package/src/components/RichTextRenderer/RichTextRenderer.tsx +0 -168
- package/src/components/RichTextRenderer/RichTextRendererError.ts +0 -1
- package/src/components/RichTextRenderer/RootEditorNode.ts +0 -12
- package/src/components/RichTextRenderer/defaultDeserialize.ts +0 -19
- package/src/components/RichTextRenderer/index.ts +0 -15
- package/src/components/RichTextRenderer/renderChildren.tsx +0 -50
- package/src/components/RichTextRenderer/resolveRichTextElementMetadata.ts +0 -50
- package/src/components/index.ts +0 -1
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { BuiltinElements } from './BuiltinElements';
|
|
2
|
-
import type { BuiltinLeaves } from './BuiltinLeaves';
|
|
3
|
-
import type { RichTextElement } from './RichTextElement';
|
|
4
|
-
import type { RichTextLeaf } from './RichTextLeaf';
|
|
5
|
-
export interface RootEditorNode<CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = never> {
|
|
6
|
-
formatVersion: number;
|
|
7
|
-
children: Array<BuiltinElements<CustomElements, CustomLeaves> | CustomElements | BuiltinLeaves | CustomLeaves>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=RootEditorNode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RootEditorNode.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextRenderer/RootEditorNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,MAAM,WAAW,cAAc,CAC9B,cAAc,SAAS,eAAe,GAAG,KAAK,EAC9C,YAAY,SAAS,YAAY,GAAG,KAAK;IAEzC,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,KAAK,CAAC,eAAe,CAAC,cAAc,EAAE,YAAY,CAAC,GAAG,cAAc,GAAG,aAAa,GAAG,YAAY,CAAC,CAAA;CAC9G"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { RichTextElement } from './RichTextElement';
|
|
2
|
-
import type { RichTextLeaf } from './RichTextLeaf';
|
|
3
|
-
import type { RootEditorNode } from './RootEditorNode';
|
|
4
|
-
export declare const defaultDeserialize: <CustomElements extends RichTextElement<never, never> = never, CustomLeaves extends RichTextLeaf = never>(source: string) => RootEditorNode<CustomElements, CustomLeaves>;
|
|
5
|
-
//# sourceMappingURL=defaultDeserialize.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaultDeserialize.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextRenderer/defaultDeserialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,eAAO,MAAM,kBAAkB,oHAItB,MAAM,iDAUd,CAAA"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export * from './BuiltinElements';
|
|
2
|
-
export * from './BuiltinLeaves';
|
|
3
|
-
export * from './ReferenceRenderer';
|
|
4
|
-
export * from './RichTextBlock';
|
|
5
|
-
export * from './RichTextElement';
|
|
6
|
-
export * from './RichTextElementMetadata';
|
|
7
|
-
export * from './RichTextLeaf';
|
|
8
|
-
export * from './RichTextLeafMetadata';
|
|
9
|
-
export * from './RichTextReference';
|
|
10
|
-
export * from './RichTextRenderer';
|
|
11
|
-
export * from './RichTextRendererError';
|
|
12
|
-
export * from './RootEditorNode';
|
|
13
|
-
export type { RenderChildrenOptions } from './renderChildren';
|
|
14
|
-
export type { RenderElement } from './ElementRenderer';
|
|
15
|
-
export type { RenderLeaf } from './LeafRenderer';
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextRenderer/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA;AACzC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,kBAAkB,CAAA;AAChC,YAAY,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAC7D,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ReactElement } from 'react';
|
|
2
|
-
import type { BuiltinElements } from './BuiltinElements';
|
|
3
|
-
import type { BuiltinLeaves } from './BuiltinLeaves';
|
|
4
|
-
import { RenderElement } from './ElementRenderer';
|
|
5
|
-
import { RenderLeaf } from './LeafRenderer';
|
|
6
|
-
import type { RichTextElement } from './RichTextElement';
|
|
7
|
-
import type { RichTextLeaf } from './RichTextLeaf';
|
|
8
|
-
export interface RenderChildrenOptions<CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = never> {
|
|
9
|
-
renderElement?: RenderElement<CustomElements, CustomLeaves>;
|
|
10
|
-
renderLeaf?: RenderLeaf<CustomLeaves>;
|
|
11
|
-
attributeNamePrefix?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare const renderChildren: <CustomElements extends RichTextElement<never, never> = never, CustomLeaves extends RichTextLeaf = never>(children: BuiltinLeaves | CustomElements | CustomLeaves | BuiltinElements<CustomElements, CustomLeaves> | (BuiltinLeaves | CustomElements | CustomLeaves | BuiltinElements<CustomElements, CustomLeaves>)[], options: RenderChildrenOptions<CustomElements, CustomLeaves>) => ReactElement;
|
|
14
|
-
//# sourceMappingURL=renderChildren.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderChildren.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextRenderer/renderChildren.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAmB,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAgB,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,MAAM,WAAW,qBAAqB,CACrC,cAAc,SAAS,eAAe,GAAG,KAAK,EAC9C,YAAY,SAAS,YAAY,GAAG,KAAK;IAEzC,aAAa,CAAC,EAAE,aAAa,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;IAC3D,UAAU,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,CAAA;IACrC,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,eAAO,MAAM,cAAc,0XAWxB,YAqBF,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { BuiltinElements } from './BuiltinElements';
|
|
2
|
-
import type { RichTextElement } from './RichTextElement';
|
|
3
|
-
import type { RichTextElementMetadata } from './RichTextElementMetadata';
|
|
4
|
-
import type { RichTextLeaf } from './RichTextLeaf';
|
|
5
|
-
import type { RichTextReference } from './RichTextReference';
|
|
6
|
-
import type { RichTextRenderMetadata } from './RichTextRenderMetadata';
|
|
7
|
-
export declare const resolveRichTextElementMetadata: <CustomElements extends RichTextElement<never, never> = never, CustomLeaves extends RichTextLeaf = never, Reference extends RichTextReference = RichTextReference>(element: CustomElements | BuiltinElements<CustomElements, CustomLeaves>, metadata: RichTextRenderMetadata<CustomElements, CustomLeaves, Reference>) => RichTextElementMetadata<CustomElements, CustomLeaves, Reference>;
|
|
8
|
-
//# sourceMappingURL=resolveRichTextElementMetadata.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveRichTextElementMetadata.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextRenderer/resolveRichTextElementMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEtE,eAAO,MAAM,8BAA8B,4XAwC1C,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type { RichTextElement } from './RichTextElement'
|
|
2
|
-
import type { RichTextLeaf } from './RichTextLeaf'
|
|
3
|
-
|
|
4
|
-
export type BuiltinElements<
|
|
5
|
-
CustomElements extends RichTextElement = never,
|
|
6
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
7
|
-
> =
|
|
8
|
-
| RichTextAnchorElement<CustomElements, CustomLeaves>
|
|
9
|
-
| RichTextHeadingElement<CustomElements, CustomLeaves>
|
|
10
|
-
| RichTextHorizontalRuleElement<CustomElements, CustomLeaves>
|
|
11
|
-
| RichTextListItemElement<CustomElements, CustomLeaves>
|
|
12
|
-
| RichTextOrderedListElement<CustomElements, CustomLeaves>
|
|
13
|
-
| RichTextParagraphElement<CustomElements, CustomLeaves>
|
|
14
|
-
| RichTextReferenceElement<CustomElements, CustomLeaves>
|
|
15
|
-
| RichTextScrollTargetElement<CustomElements, CustomLeaves>
|
|
16
|
-
| RichTextTableCellElement<CustomElements, CustomLeaves>
|
|
17
|
-
| RichTextTableElement<CustomElements, CustomLeaves>
|
|
18
|
-
| RichTextTableRowElement<CustomElements, CustomLeaves>
|
|
19
|
-
| RichTextUnorderedListElement<CustomElements, CustomLeaves>
|
|
20
|
-
|
|
21
|
-
export interface RichTextAnchorElement<
|
|
22
|
-
CustomElements extends RichTextElement = never,
|
|
23
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
24
|
-
> extends RichTextElement<CustomElements, CustomLeaves> {
|
|
25
|
-
type: 'anchor'
|
|
26
|
-
href: string
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface RichTextHeadingElement<
|
|
30
|
-
CustomElements extends RichTextElement = never,
|
|
31
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
32
|
-
> extends RichTextElement<CustomElements, CustomLeaves> {
|
|
33
|
-
type: 'heading'
|
|
34
|
-
level: 1 | 2 | 3 | 4 | 5 | 6
|
|
35
|
-
isNumbered?: boolean
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface RichTextOrderedListElement<
|
|
39
|
-
CustomElements extends RichTextElement = never,
|
|
40
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
41
|
-
> extends RichTextElement<CustomElements, CustomLeaves> {
|
|
42
|
-
type: 'orderedList'
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface RichTextUnorderedListElement<
|
|
46
|
-
CustomElements extends RichTextElement = never,
|
|
47
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
48
|
-
> extends RichTextElement<CustomElements, CustomLeaves> {
|
|
49
|
-
type: 'unorderedList'
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface RichTextListItemElement<
|
|
53
|
-
CustomElements extends RichTextElement = never,
|
|
54
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
55
|
-
> extends RichTextElement<CustomElements, CustomLeaves> {
|
|
56
|
-
type: 'listItem'
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface RichTextHorizontalRuleElement<
|
|
60
|
-
CustomElements extends RichTextElement = never,
|
|
61
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
62
|
-
> extends RichTextElement<CustomElements, CustomLeaves> {
|
|
63
|
-
type: 'horizontalRule'
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface RichTextParagraphElement<
|
|
67
|
-
CustomElements extends RichTextElement = never,
|
|
68
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
69
|
-
> extends RichTextElement<CustomElements, CustomLeaves> {
|
|
70
|
-
type: 'paragraph'
|
|
71
|
-
isNumbered?: boolean
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface RichTextReferenceElement<
|
|
75
|
-
CustomElements extends RichTextElement = never,
|
|
76
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
77
|
-
> extends RichTextElement<CustomElements, CustomLeaves> {
|
|
78
|
-
type: 'reference'
|
|
79
|
-
referenceId: string
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface RichTextScrollTargetElement<
|
|
83
|
-
CustomElements extends RichTextElement = never,
|
|
84
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
85
|
-
> extends RichTextElement<CustomElements, CustomLeaves> {
|
|
86
|
-
type: 'scrollTarget'
|
|
87
|
-
identifier: string
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface RichTextTableElement<
|
|
91
|
-
CustomElements extends RichTextElement = never,
|
|
92
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
93
|
-
> extends RichTextElement<CustomElements, CustomLeaves> {
|
|
94
|
-
type: 'table'
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface RichTextTableCellElement<
|
|
98
|
-
CustomElements extends RichTextElement = never,
|
|
99
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
100
|
-
> extends RichTextElement<CustomElements, CustomLeaves> {
|
|
101
|
-
type: 'tableCell'
|
|
102
|
-
headerScope?: 'row'
|
|
103
|
-
justify?: 'start' | 'center' | 'end'
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export interface RichTextTableRowElement<
|
|
107
|
-
CustomElements extends RichTextElement = never,
|
|
108
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
109
|
-
> extends RichTextElement<CustomElements, CustomLeaves> {
|
|
110
|
-
type: 'tableRow'
|
|
111
|
-
headerScope?: 'table'
|
|
112
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { RichTextLeaf } from './RichTextLeaf'
|
|
2
|
-
|
|
3
|
-
export type BuiltinLeaves = RichTextBoldLeaf &
|
|
4
|
-
RichTextCodeLeaf &
|
|
5
|
-
RichTextHighlightLeaf &
|
|
6
|
-
RichTextItalicLeaf &
|
|
7
|
-
RichTextStrikeThroughLeaf &
|
|
8
|
-
RichTextUnderlineLeaf
|
|
9
|
-
|
|
10
|
-
export interface RichTextBoldLeaf extends RichTextLeaf {
|
|
11
|
-
isBold?: boolean
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface RichTextCodeLeaf extends RichTextLeaf {
|
|
15
|
-
isCode?: boolean
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface RichTextHighlightLeaf extends RichTextLeaf {
|
|
19
|
-
isHighlighted?: boolean
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface RichTextItalicLeaf extends RichTextLeaf {
|
|
23
|
-
isItalic?: boolean
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface RichTextStrikeThroughLeaf extends RichTextLeaf {
|
|
27
|
-
isStruckThrough?: boolean
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface RichTextUnderlineLeaf extends RichTextLeaf {
|
|
31
|
-
isUnderlined?: boolean
|
|
32
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { ComponentType, ReactElement } from 'react'
|
|
2
|
-
import { createElement } from 'react'
|
|
3
|
-
import type { BuiltinElements } from './BuiltinElements'
|
|
4
|
-
import type { BuiltinLeaves } from './BuiltinLeaves'
|
|
5
|
-
import type { RenderChildrenOptions } from './renderChildren'
|
|
6
|
-
import { renderChildren } from './renderChildren'
|
|
7
|
-
import { RenderElementFallback } from './RenderElementFallback'
|
|
8
|
-
import { resolveRichTextElementMetadata } from './resolveRichTextElementMetadata'
|
|
9
|
-
import type { RichTextElement } from './RichTextElement'
|
|
10
|
-
import type { RichTextElementMetadata } from './RichTextElementMetadata'
|
|
11
|
-
import type { RichTextLeaf } from './RichTextLeaf'
|
|
12
|
-
import type { RichTextReference } from './RichTextReference'
|
|
13
|
-
import { useRichTextRenderMetadata } from './RichTextRenderMetadataContext'
|
|
14
|
-
|
|
15
|
-
export type RenderElement<
|
|
16
|
-
CustomElements extends RichTextElement = never,
|
|
17
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
18
|
-
Reference extends RichTextReference = RichTextReference,
|
|
19
|
-
> = ComponentType<
|
|
20
|
-
{
|
|
21
|
-
element: CustomElements | BuiltinElements<CustomElements, CustomLeaves>
|
|
22
|
-
children: ReactElement
|
|
23
|
-
|
|
24
|
-
fallback: ReactElement
|
|
25
|
-
|
|
26
|
-
renderChildren: (
|
|
27
|
-
children:
|
|
28
|
-
| CustomElements
|
|
29
|
-
| BuiltinElements<CustomElements, CustomLeaves>
|
|
30
|
-
| CustomLeaves
|
|
31
|
-
| BuiltinLeaves
|
|
32
|
-
| Array<CustomElements | BuiltinElements<CustomElements, CustomLeaves> | CustomLeaves | BuiltinLeaves>,
|
|
33
|
-
options: RenderChildrenOptions<CustomElements, CustomLeaves>,
|
|
34
|
-
) => ReactElement
|
|
35
|
-
renderChildrenOptions: RenderChildrenOptions<CustomElements, CustomLeaves>
|
|
36
|
-
} & RichTextElementMetadata<CustomElements, CustomLeaves, Reference>
|
|
37
|
-
>
|
|
38
|
-
|
|
39
|
-
export interface ElementRendererProps<
|
|
40
|
-
CustomElements extends RichTextElement = never,
|
|
41
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
42
|
-
> {
|
|
43
|
-
element: CustomElements | BuiltinElements<CustomElements, CustomLeaves>
|
|
44
|
-
children: ReactElement
|
|
45
|
-
options: RenderChildrenOptions<CustomElements, CustomLeaves>
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function ElementRenderer<
|
|
49
|
-
CustomElements extends RichTextElement = never,
|
|
50
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
51
|
-
>({ element, children, options }: ElementRendererProps<CustomElements, CustomLeaves>) {
|
|
52
|
-
const metadata = useRichTextRenderMetadata<CustomElements, CustomLeaves>()
|
|
53
|
-
const elementMetadata = resolveRichTextElementMetadata<CustomElements, CustomLeaves>(element, metadata)
|
|
54
|
-
|
|
55
|
-
const fallback = (
|
|
56
|
-
<RenderElementFallback element={element as BuiltinElements} options={options}>
|
|
57
|
-
{children}
|
|
58
|
-
</RenderElementFallback>
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
return options.renderElement
|
|
62
|
-
? createElement(options.renderElement, {
|
|
63
|
-
...elementMetadata,
|
|
64
|
-
element,
|
|
65
|
-
fallback,
|
|
66
|
-
children,
|
|
67
|
-
renderChildren,
|
|
68
|
-
renderChildrenOptions: options,
|
|
69
|
-
})
|
|
70
|
-
: fallback
|
|
71
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { ComponentType, ReactElement } from 'react'
|
|
2
|
-
import { createElement } from 'react'
|
|
3
|
-
import type { BuiltinLeaves } from './BuiltinLeaves'
|
|
4
|
-
import { RenderLeafFallback } from './RenderLeafFallback'
|
|
5
|
-
import type { RichTextLeaf } from './RichTextLeaf'
|
|
6
|
-
import type { RichTextLeafMetadata } from './RichTextLeafMetadata'
|
|
7
|
-
import { useRichTextRenderMetadata } from './RichTextRenderMetadataContext'
|
|
8
|
-
|
|
9
|
-
export type RenderLeaf<CustomLeaves extends RichTextLeaf> = ComponentType<
|
|
10
|
-
{
|
|
11
|
-
leaf: CustomLeaves | BuiltinLeaves
|
|
12
|
-
fallback: ReactElement
|
|
13
|
-
} & RichTextLeafMetadata
|
|
14
|
-
>
|
|
15
|
-
|
|
16
|
-
export interface LeafRendererProps<CustomLeaves extends RichTextLeaf = never> {
|
|
17
|
-
renderLeaf?: RenderLeaf<CustomLeaves>
|
|
18
|
-
leaf: CustomLeaves | BuiltinLeaves
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function LeafRenderer<CustomLeaves extends RichTextLeaf = never>({
|
|
22
|
-
leaf,
|
|
23
|
-
renderLeaf,
|
|
24
|
-
}: LeafRendererProps<CustomLeaves>) {
|
|
25
|
-
const formatVersion = useRichTextRenderMetadata().formatVersion
|
|
26
|
-
const fallback = <RenderLeafFallback leaf={leaf} />
|
|
27
|
-
|
|
28
|
-
return renderLeaf
|
|
29
|
-
? createElement(
|
|
30
|
-
renderLeaf,
|
|
31
|
-
{
|
|
32
|
-
formatVersion,
|
|
33
|
-
leaf,
|
|
34
|
-
fallback,
|
|
35
|
-
},
|
|
36
|
-
leaf.text,
|
|
37
|
-
)
|
|
38
|
-
: fallback
|
|
39
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ReferenceRenderer } from './ReferenceRenderer'
|
|
2
|
-
import type { RichTextElement } from './RichTextElement'
|
|
3
|
-
import type { RichTextLeaf } from './RichTextLeaf'
|
|
4
|
-
import type { RichTextReference } from './RichTextReference'
|
|
5
|
-
import type { RootEditorNode } from './RootEditorNode'
|
|
6
|
-
|
|
7
|
-
export interface NormalizedRichTextBlock<
|
|
8
|
-
CustomElements extends RichTextElement = never,
|
|
9
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
10
|
-
> {
|
|
11
|
-
content: RootEditorNode<CustomElements, CustomLeaves>
|
|
12
|
-
referenceRenderers: Record<string, ReferenceRenderer<RichTextReference, CustomElements, CustomLeaves>>
|
|
13
|
-
references: Map<string, RichTextReference> | undefined
|
|
14
|
-
referencesField: string | undefined
|
|
15
|
-
referenceDiscriminationField: string | undefined
|
|
16
|
-
id: string | undefined
|
|
17
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ReactElement, ReactNode } from 'react'
|
|
2
|
-
import type { BuiltinElements } from './BuiltinElements'
|
|
3
|
-
import type { RichTextElement } from './RichTextElement'
|
|
4
|
-
import type { RichTextElementMetadata } from './RichTextElementMetadata'
|
|
5
|
-
import type { RichTextLeaf } from './RichTextLeaf'
|
|
6
|
-
import type { RichTextReference } from './RichTextReference'
|
|
7
|
-
|
|
8
|
-
export type ReferenceRendererProps<
|
|
9
|
-
Reference extends RichTextReference = RichTextReference,
|
|
10
|
-
CustomElements extends RichTextElement = never,
|
|
11
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
12
|
-
> = {
|
|
13
|
-
element: CustomElements | BuiltinElements<CustomElements, CustomLeaves>
|
|
14
|
-
children: ReactElement
|
|
15
|
-
} & {
|
|
16
|
-
[Prop in keyof RichTextElementMetadata<CustomElements, CustomLeaves, Reference>]: Exclude<
|
|
17
|
-
RichTextElementMetadata<CustomElements, CustomLeaves, Reference>[Prop],
|
|
18
|
-
undefined
|
|
19
|
-
>
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type ReferenceRenderer<
|
|
23
|
-
Reference extends RichTextReference = RichTextReference,
|
|
24
|
-
CustomElements extends RichTextElement = never,
|
|
25
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
26
|
-
> = (props: ReferenceRendererProps<Reference, CustomElements, CustomLeaves>) => ReactNode
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { createElement, ReactElement } from 'react'
|
|
2
|
-
import type { BuiltinElements, RichTextReferenceElement, RichTextTableRowElement } from './BuiltinElements'
|
|
3
|
-
import { renderChildren, RenderChildrenOptions } from './renderChildren'
|
|
4
|
-
import { resolveRichTextElementMetadata } from './resolveRichTextElementMetadata'
|
|
5
|
-
import type { RichTextElement } from './RichTextElement'
|
|
6
|
-
import type { RichTextLeaf } from './RichTextLeaf'
|
|
7
|
-
import { RichTextRendererError } from './RichTextRendererError'
|
|
8
|
-
import { useRichTextRenderMetadata } from './RichTextRenderMetadataContext'
|
|
9
|
-
|
|
10
|
-
export interface RenderElementFallbackProps<
|
|
11
|
-
CustomElements extends RichTextElement = never,
|
|
12
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
13
|
-
> {
|
|
14
|
-
element: BuiltinElements<CustomElements, CustomLeaves>
|
|
15
|
-
children: ReactElement
|
|
16
|
-
options: RenderChildrenOptions<CustomElements, CustomLeaves>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const getElementDataAttributes = <
|
|
20
|
-
CustomElements extends RichTextElement = never,
|
|
21
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
22
|
-
>(
|
|
23
|
-
element: RichTextElement<CustomElements, CustomLeaves>,
|
|
24
|
-
attributeNamePrefix: string = 'contember-',
|
|
25
|
-
): {
|
|
26
|
-
[dataAttribute: string]: string | number | boolean
|
|
27
|
-
} => {
|
|
28
|
-
const { children, referenceId, ...extendedSpecifics } = element
|
|
29
|
-
|
|
30
|
-
return Object.fromEntries(
|
|
31
|
-
Object.entries(extendedSpecifics)
|
|
32
|
-
.filter(([, value]) => {
|
|
33
|
-
const t = typeof value
|
|
34
|
-
return t === 'string' || t === 'number' || t === 'boolean'
|
|
35
|
-
})
|
|
36
|
-
.map(([attribute, value]) => [`data-${attributeNamePrefix}${attribute.toLowerCase()}`, value]),
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function RenderElementFallback<
|
|
41
|
-
CustomElements extends RichTextElement = never,
|
|
42
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
43
|
-
>({ element, children, options }: RenderElementFallbackProps<CustomElements, CustomLeaves>) {
|
|
44
|
-
const attributes = getElementDataAttributes(element, options.attributeNamePrefix)
|
|
45
|
-
|
|
46
|
-
switch (element.type) {
|
|
47
|
-
case 'anchor':
|
|
48
|
-
return (
|
|
49
|
-
<a {...attributes} href={element.href}>
|
|
50
|
-
{children}
|
|
51
|
-
</a>
|
|
52
|
-
)
|
|
53
|
-
case 'heading':
|
|
54
|
-
return createElement(`h${element.level}`, attributes, children) // TODO numbered
|
|
55
|
-
case 'horizontalRule':
|
|
56
|
-
return <hr {...attributes} />
|
|
57
|
-
case 'listItem':
|
|
58
|
-
return <li {...attributes}>{children}</li>
|
|
59
|
-
case 'orderedList':
|
|
60
|
-
return <ol {...attributes}>{children}</ol>
|
|
61
|
-
case 'paragraph':
|
|
62
|
-
return <p {...attributes}>{children}</p>
|
|
63
|
-
case 'reference': {
|
|
64
|
-
return <ReferenceElementFallback element={element} children={children} />
|
|
65
|
-
}
|
|
66
|
-
case 'scrollTarget':
|
|
67
|
-
return (
|
|
68
|
-
<span {...attributes} id={element.identifier}>
|
|
69
|
-
{children}
|
|
70
|
-
</span>
|
|
71
|
-
)
|
|
72
|
-
case 'table': {
|
|
73
|
-
const firstRow = element.children[0] as RichTextTableRowElement<CustomElements, CustomLeaves> | undefined
|
|
74
|
-
if (!firstRow || firstRow.headerScope !== 'table') {
|
|
75
|
-
return (
|
|
76
|
-
<table {...attributes}>
|
|
77
|
-
<tbody>{children}</tbody>
|
|
78
|
-
</table>
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
return (
|
|
82
|
-
<table {...attributes}>
|
|
83
|
-
<thead>{renderChildren<CustomElements, CustomLeaves>([firstRow], options)}</thead>
|
|
84
|
-
<tbody>{renderChildren<CustomElements, CustomLeaves>(element.children.slice(1) as any, options)}</tbody>
|
|
85
|
-
</table>
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
case 'tableRow':
|
|
89
|
-
return <tr {...attributes}>{children}</tr>
|
|
90
|
-
case 'tableCell': {
|
|
91
|
-
if (element.headerScope) {
|
|
92
|
-
return (
|
|
93
|
-
<th {...attributes} scope={element.headerScope}>
|
|
94
|
-
{children}
|
|
95
|
-
</th>
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
return <td {...attributes}>{children}</td>
|
|
99
|
-
}
|
|
100
|
-
case 'unorderedList':
|
|
101
|
-
return <ul {...attributes}>{children}</ul>
|
|
102
|
-
default: {
|
|
103
|
-
if (import.meta.env.DEV) {
|
|
104
|
-
throw new RichTextRendererError(
|
|
105
|
-
`RichTextRenderer: unknown element of type '${(element as { type: string }).type}'.`,
|
|
106
|
-
)
|
|
107
|
-
} else {
|
|
108
|
-
return children // At least render the text contents
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function ReferenceElementFallback<
|
|
115
|
-
CustomElements extends RichTextElement = never,
|
|
116
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
117
|
-
>({ element, children }: { element: RichTextReferenceElement<CustomElements, CustomLeaves>; children: ReactElement }) {
|
|
118
|
-
const metadata = useRichTextRenderMetadata<CustomElements, CustomLeaves>()
|
|
119
|
-
const elementMetadata = resolveRichTextElementMetadata<CustomElements, CustomLeaves>(element, metadata)
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
elementMetadata.referenceRenderer === undefined ||
|
|
123
|
-
elementMetadata.referenceType === undefined ||
|
|
124
|
-
elementMetadata.reference === undefined
|
|
125
|
-
) {
|
|
126
|
-
if (import.meta.env.DEV) {
|
|
127
|
-
throw new RichTextRendererError(
|
|
128
|
-
`RichTextRenderer: cannot render reference of type '${elementMetadata.referenceType}'.`,
|
|
129
|
-
)
|
|
130
|
-
} else {
|
|
131
|
-
return children // At least render the text contents
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return (
|
|
136
|
-
<>
|
|
137
|
-
{elementMetadata.referenceRenderer?.({
|
|
138
|
-
referenceType: elementMetadata.referenceType,
|
|
139
|
-
referenceRenderer: elementMetadata.referenceRenderer,
|
|
140
|
-
reference: elementMetadata.reference,
|
|
141
|
-
formatVersion: elementMetadata.formatVersion,
|
|
142
|
-
element,
|
|
143
|
-
children,
|
|
144
|
-
})}
|
|
145
|
-
</>
|
|
146
|
-
)
|
|
147
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Fragment, ReactNode } from 'react'
|
|
2
|
-
import type { BuiltinLeaves } from './BuiltinLeaves'
|
|
3
|
-
|
|
4
|
-
export interface RenderLeafFallbackProps {
|
|
5
|
-
leaf: BuiltinLeaves
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function jsxN2br(text: string): ReactNode {
|
|
9
|
-
const lines = text.split('\n')
|
|
10
|
-
if (lines.length <= 1) {
|
|
11
|
-
return text
|
|
12
|
-
}
|
|
13
|
-
return lines.map((line, i) => (
|
|
14
|
-
<Fragment key={i}>
|
|
15
|
-
{!!i && <br />}
|
|
16
|
-
{line}
|
|
17
|
-
</Fragment>
|
|
18
|
-
))
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function RenderLeafFallback({ leaf }: RenderLeafFallbackProps) {
|
|
22
|
-
let element = jsxN2br(leaf.text)
|
|
23
|
-
|
|
24
|
-
if ('isCode' in leaf && leaf.isCode === true) {
|
|
25
|
-
element = <code>{element}</code>
|
|
26
|
-
}
|
|
27
|
-
if ('isStruckThrough' in leaf && leaf.isStruckThrough === true) {
|
|
28
|
-
element = <s>{element}</s>
|
|
29
|
-
}
|
|
30
|
-
if ('isHighlighted' in leaf && leaf.isHighlighted === true) {
|
|
31
|
-
element = <em>{element}</em>
|
|
32
|
-
}
|
|
33
|
-
if ('isUnderlined' in leaf && leaf.isUnderlined === true) {
|
|
34
|
-
element = <u>{element}</u>
|
|
35
|
-
}
|
|
36
|
-
if ('isItalic' in leaf && leaf.isItalic === true) {
|
|
37
|
-
element = <i>{element}</i>
|
|
38
|
-
}
|
|
39
|
-
if ('isBold' in leaf && leaf.isBold === true) {
|
|
40
|
-
element = <b>{element}</b>
|
|
41
|
-
}
|
|
42
|
-
return <>{element}</>
|
|
43
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type RichTextBlock = Readonly<Record<string, unknown>>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { RichTextLeaf } from './RichTextLeaf'
|
|
2
|
-
|
|
3
|
-
export interface RichTextElement<
|
|
4
|
-
CustomElements extends RichTextElement = never,
|
|
5
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
6
|
-
> {
|
|
7
|
-
type: string
|
|
8
|
-
children: RichTextElement<CustomElements, CustomLeaves>[] | Array<CustomLeaves | RichTextLeaf>
|
|
9
|
-
referenceId?: string
|
|
10
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ReferenceRenderer } from './ReferenceRenderer'
|
|
2
|
-
import type { RichTextElement } from './RichTextElement'
|
|
3
|
-
import type { RichTextLeaf } from './RichTextLeaf'
|
|
4
|
-
import type { RichTextReference } from './RichTextReference'
|
|
5
|
-
|
|
6
|
-
export interface RichTextElementMetadata<
|
|
7
|
-
CustomElements extends RichTextElement = never,
|
|
8
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
9
|
-
Reference extends RichTextReference = RichTextReference,
|
|
10
|
-
> {
|
|
11
|
-
formatVersion: number
|
|
12
|
-
reference: Reference | undefined
|
|
13
|
-
referenceType: string | undefined
|
|
14
|
-
referenceRenderer: ReferenceRenderer<Reference, CustomElements, CustomLeaves> | undefined
|
|
15
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ReferenceRenderer } from './ReferenceRenderer'
|
|
2
|
-
import type { RichTextElement } from './RichTextElement'
|
|
3
|
-
import type { RichTextLeaf } from './RichTextLeaf'
|
|
4
|
-
import type { RichTextReference } from './RichTextReference'
|
|
5
|
-
|
|
6
|
-
export interface RichTextRenderMetadata<
|
|
7
|
-
CustomElements extends RichTextElement = never,
|
|
8
|
-
CustomLeaves extends RichTextLeaf = never,
|
|
9
|
-
Reference extends RichTextReference = RichTextReference,
|
|
10
|
-
> {
|
|
11
|
-
formatVersion: number
|
|
12
|
-
referenceRenderers: Record<string, ReferenceRenderer<Reference, CustomElements, CustomLeaves>>
|
|
13
|
-
references: Map<string, RichTextReference> | undefined
|
|
14
|
-
referencesField: string | undefined
|
|
15
|
-
referenceDiscriminationField: string | undefined
|
|
16
|
-
}
|