import type { Editor } from '@tiptap/core'; import type { NodeSelection, Selection } from '@tiptap/pm/state'; import type { ComponentType, FC, PropsWithChildren, ReactElement, Ref } from 'react'; import type { ACTION_BUTTON_TYPE, AUDIO_TYPE, CODE_BLOCK_TYPE, COLLAPSIBLE_LIST_TYPE, DIVIDER_TYPE, EMOJI_TYPE, EXTERNAL_LINK_TYPE, EXTERNAL_MENTIONS_TYPE, FILE_UPLOAD_TYPE, GALLERY_TYPE, GIPHY_TYPE, HASHTAG_TYPE, HEADERS_MARKDOWN_TYPE, HEADINGS_DROPDOWN_TYPE, HTML_TYPE, IMAGE_TYPE, IMAGE_TYPE_LEGACY, INDENT_TYPE, LINE_SPACING_TYPE, LINK_BUTTON_TYPE, LINK_PREVIEW_TYPE, LINK_TYPE, MAP_TYPE, MENTION_TYPE, POLL_TYPE, PREVIEW, SPOILER_TYPE, TABLE_TYPE, TEXT_COLOR_TYPE, TEXT_HIGHLIGHT_TYPE, UNDO_REDO_TYPE, VERTICAL_EMBED_TYPE, VIDEO_TYPE, VIDEO_TYPE_LEGACY } from 'ricos-content'; import type { MentionData as MentionPluginData, Node } from 'ricos-schema'; import { Decoration_Type, LinkData, Node_Type } from 'ricos-schema'; import type { ClassNameStrategy, GetToolbarSettings, IEditorQuery, IRicosEditor, ModalService, PluginExports, ResolveReferenceElement, RicosPluginToolbarNamesValues, ThemeData, TiptapEditor } from '.'; import type { EditorCommands } from './editorCommandsType'; import type { ModalConfig } from './modalTypes'; import type { RicosServices } from './services'; import type { KeyboardShortcut } from './shortcuts'; import type { ToolbarType } from './toolbarEnums'; import type { FormattingToolbarButtonConfig, IToolbarItem } from './toolbarTypes'; import type { ViewerContextualData } from './viewer'; export { Decoration_Type, LinkData, Node_Type }; export type MentionData = { mention: MentionPluginData; trigger: string; }; export type PluginMapping = Partial<{ [type: string]: { component: ComponentType; classNameStrategies?: { size?: ClassNameStrategy; alignment?: ClassNameStrategy; textWrap?: ClassNameStrategy; }; elementType?: 'inline' | 'block'; }; }>; export type PluginTypeMapper = (...args: any[]) => PluginMapping; export type PluginType = typeof LINK_BUTTON_TYPE | typeof ACTION_BUTTON_TYPE | typeof CODE_BLOCK_TYPE | typeof DIVIDER_TYPE | typeof EMOJI_TYPE | typeof FILE_UPLOAD_TYPE | typeof GALLERY_TYPE | typeof GIPHY_TYPE | typeof HASHTAG_TYPE | typeof HEADERS_MARKDOWN_TYPE | typeof HTML_TYPE | typeof IMAGE_TYPE | typeof IMAGE_TYPE_LEGACY | typeof INDENT_TYPE | typeof LINE_SPACING_TYPE | typeof HEADINGS_DROPDOWN_TYPE | typeof SPOILER_TYPE | typeof EXTERNAL_LINK_TYPE | typeof LINK_TYPE | typeof LINK_PREVIEW_TYPE | typeof MAP_TYPE | typeof EXTERNAL_MENTIONS_TYPE | typeof MENTION_TYPE | typeof TEXT_COLOR_TYPE | typeof TEXT_HIGHLIGHT_TYPE | typeof UNDO_REDO_TYPE | typeof VERTICAL_EMBED_TYPE | typeof VIDEO_TYPE | typeof AUDIO_TYPE | typeof VIDEO_TYPE_LEGACY | typeof POLL_TYPE | typeof COLLAPSIBLE_LIST_TYPE | typeof TABLE_TYPE; interface BasePluginConfig { type: string; } export type MenuGroups = 'basic' | 'advanced' | 'embed' | 'embed_wix'; type MenuConfig = { group?: MenuGroups; tags?: string; }; export type AddButton = { id: string; icon: ComponentType; command: (args: { editorCommands: EditorCommands; }) => boolean; tooltip: string; toolbars: ToolbarType[]; dataHook: string; label: string; modal?: ModalConfig; menuConfig?: MenuConfig; shortcuts?: KeyboardShortcut[]; }; export type Resolver = Record boolean | string>; export type ToolbarButton = { id: string; type?: 'toggle' | 'modal' | 'separator'; renderer?: (toolbarItem: IToolbarItem) => ReactElement; modal?: ModalConfig; icon?: ComponentType; tooltip?: string; dataHook?: string; command?: (args: { [key: string]: any; editorCommands: Editor; attributes: any; value?: any; }) => void; attributes?: Record any; }>; }; export type FloatingToolbarButton = { Component: ComponentType; isVisible: (args: { editorQuery: IEditorQuery['query']; modalService: ModalService; editor: TiptapEditor; nodeId?: string; }) => boolean; }; export type PluginToolbarConfig> = { names: RicosPluginToolbarNamesValues[]; getButtons: (config: PluginConfig, services: RicosServices) => ToolbarButton[]; isVisible?: (selection: Selection | NodeSelection, editor: IRicosEditor) => boolean; resolveReferenceElement?: ResolveReferenceElement; }; export type AddButtonsCreator> = (config: PluginConfig, services: RicosServices) => AddButton[]; export interface EditorPlugin, Exports = object> extends BasePluginConfig { config: PluginConfig; getAddButtons?: AddButtonsCreator; textButtons?: FormattingToolbarButtonConfig[]; /** @deprecated: These are not scoped to and editor and should be avoided */ shortcuts?: KeyboardShortcut[]; toolbar?: PluginToolbarConfig; modals?: ModalConfig[]; floatingToolbarButton?: FloatingToolbarButton; exports?: Partial; /** * @deprecated * @internal * */ __exports?: Exports; } export interface ViewerPlugin> extends BasePluginConfig { config: PluginConfig; typeMapper?: PluginTypeMapper; nodeViewRenderers?: NodeViewRenderers; nodeViewDecorators?: NodeViewDecorator[]; } export type BasePlugin = EditorPlugin & ViewerPlugin; export type EditorPluginCreator, Exports = object> = (config?: PluginConfig) => EditorPlugin; export type ViewerPluginCreator = (config?: PluginConfig) => ViewerPlugin; export interface EditorPluginConfig { toolbar?: { hidden?: string[]; icons?: { [key: string]: (props: any) => JSX.Element; }; }; getIsVisiblePromise?: (...args: any[]) => Promise; } export interface ViewerPluginConfig { } export type LegacyEditorPluginConfig> = Partial<{ [key in PluginType]: PluginConfig; }> & { uiSettings?: UISettings; getToolbarSettings?: GetToolbarSettings; themeData?: ThemeData; [key: string]: any; }; export type LegacyViewerPluginConfig> = Partial<{ [key in PluginType]: PluginConfig; }> & { uiSettings?: UISettings; [PREVIEW]?: any; [key: string]: any; }; export interface LinkPanelSettings { blankTargetToggleVisibilityFn?: () => boolean; nofollowRelToggleVisibilityFn?: () => boolean; showNewTabCheckbox?: boolean; showNoFollowCheckbox?: boolean; showNoReferrerCheckbox?: boolean; showSponsoredCheckbox?: boolean; placeholder?: string; dropDown?: any; externalPopups?: boolean; } export type UISettings = { linkPanel?: LinkPanelSettings; disableRightClick?: boolean; disableDownload?: boolean; }; export interface RicosNodesViewRendererProps { nodes: Node[]; forwardRef?: Ref; isRoot?: boolean; addAnchorsPrefix?: string; shouldParagraphApplyTextStyle?: boolean; } export type RicosNodesViewRenderer = FC; export type CustomClassNames = { alignment?: string; size?: string; textWrap?: string; }; export type NodeViewContainerProps = { node: Node; nodeIndex: number; customClassNames?: CustomClassNames; withHorizontalScroll?: boolean; }; export type NodeViewContainer = FC>; export type NodeViewRendererProps = { node: Node; nodeIndex: number; RicosNodesRenderer: RicosNodesViewRenderer; NodeViewContainer: NodeViewContainer; isRoot?: boolean; shouldParagraphApplyTextStyle?: boolean; SpoilerViewerWrapper?: ComponentType<{ className: unknown; width?: number; }>; }; export type NodeViewRenderer = (props: NodeViewRendererProps) => JSX.Element; export type NodeViewRenderers = Partial>; export type Rule = (node: Node) => boolean; type DecorateArgs = { node: Node; context: ViewerContextualData; element?: T; isRoot: boolean; }; export type Decorate = (args: DecorateArgs) => T; export type NodeViewDecorator = { rule: Rule; decorate: Decorate; isText?: boolean; priority?: number; }; export interface NodeViewDecorators { apply: (element: T, node: Node, isRoot: boolean) => T; applyTextual: (node: Node) => T | undefined; merge: (nodeViewDecorators: NodeViewDecorators) => NodeViewDecorators; getDecorators: () => NodeViewDecorator[]; } //# sourceMappingURL=pluginTypes.d.ts.map