feat: json rich text editor, blocks, asides, general structure
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
import { RTETypeEnum } from "./enums"
|
||||
import type { Attributes, RTEAnchorAttrs, RTEAssetAttrs, RTELinkAttrs } from "./attrs"
|
||||
import type { EmbedByUid } from "../components/jsontohtml"
|
||||
import type { RenderOptions } from "./option"
|
||||
|
||||
export interface RTEDefaultNode {
|
||||
attrs: Attributes
|
||||
children: RTENode[]
|
||||
type: RTETypeEnum
|
||||
uid: string
|
||||
}
|
||||
|
||||
export interface RTELinkNode {
|
||||
attrs: Attributes
|
||||
children: RTENode[]
|
||||
type: RTETypeEnum
|
||||
uid: string
|
||||
}
|
||||
|
||||
export interface RTEReferenceAssetNode extends RTEDefaultNode {
|
||||
attrs: RTEAssetAttrs
|
||||
}
|
||||
|
||||
export interface RTEAnchorNode extends RTEDefaultNode {
|
||||
attrs: RTEAnchorAttrs
|
||||
type: RTETypeEnum.a
|
||||
}
|
||||
|
||||
export interface RTEReferenceLinkNode extends RTEDefaultNode {
|
||||
attrs: RTELinkAttrs
|
||||
}
|
||||
|
||||
export enum RTEMarkType {
|
||||
bold = "bold",
|
||||
break = "break",
|
||||
classnameOrId = "classnameOrId",
|
||||
inlineCode = "inlineCode",
|
||||
italic = "italic",
|
||||
strikethrough = "strikethrough",
|
||||
subscript = "subscript",
|
||||
superscript = "superscript",
|
||||
underline = "underline",
|
||||
}
|
||||
|
||||
type RTETextNodeOptionalKeys = {
|
||||
[key in RTEMarkType]?: boolean
|
||||
}
|
||||
|
||||
export type RTETextNode = RTETextNodeOptionalKeys & {
|
||||
classname?: string
|
||||
id?: string
|
||||
text: string
|
||||
}
|
||||
|
||||
export type RTERegularNode = RTEDefaultNode | RTEAnchorNode
|
||||
|
||||
export type RTEReferenceNode = RTEDefaultNode | RTEAnchorNode
|
||||
|
||||
export type RTENode = RTERegularNode | RTEReferenceNode | RTETextNode
|
||||
|
||||
export type RTERenderMark = (children: React.ReactNode, classname?: string, id?: string) => JSX.Element
|
||||
|
||||
export interface RTEDocument extends RTEDefaultNode {
|
||||
type: RTETypeEnum.doc
|
||||
_version: number
|
||||
}
|
||||
|
||||
export type RTERenderOptionComponent = (node: RTERegularNode, embeds: EmbedByUid, next: RTENext, fullRenderOptions: RenderOptions) => React.ReactNode
|
||||
|
||||
export type RTENext = (nodes: RTENode[], embeds: EmbedByUid, fullRenderOptions: RenderOptions) => string
|
||||
|
||||
Reference in New Issue
Block a user