prosemirror-paste-rules
package prosemirror-paste-rules
function isInCode()
Check whether the current selection is completely contained within a code block or mark.
Signature:
export declare function isInCode(selection: Selection, { contained }?: IsInCodeOptions): boolean;
Parameters:
Parameter | Type | Description |
---|---|---|
selection | Selection | |
{ contained } | IsInCodeOptions | (Optional) |
Returns:
boolean
function pasteRules()
Create the paste plugin handler.
Signature:
export declare function pasteRules(pasteRules: PasteRule[]): Plugin;
Parameters:
Parameter | Type | Description |
---|---|---|
pasteRules | PasteRule[] |
Returns:
Plugin
interface FileDropHandlerProps
Signature:
export interface FileDropHandlerProps
property event
Signature:
event: DragEvent;
property files
All the matching files
Signature:
files: File[];
property pos
Signature:
pos: number;
property type
Signature:
type: 'drop';
property view
Signature:
view: EditorView;
interface FilePasteHandlerProps
Signature:
export interface FilePasteHandlerProps
property event
Signature:
event: ClipboardEvent;
property files
All the matching files
Signature:
files: File[];
property selection
Signature:
selection: Selection;
property type
Signature:
type: 'paste';
property view
Signature:
view: EditorView;
interface FilePasteRule
For handling pasting files and also file drops.
Signature:
export interface FilePasteRule extends BasePasteRule
Extends: BasePasteRule
(Some inherited members may not be shown because they are not represented in the documentation.)
property fileHandler
Return false
to defer to the next image handler.
The file
Signature:
fileHandler: (props: FileHandlerProps) => boolean;
property ignoredNodes
The names of nodes for which this paste rule can be ignored. This means that if content is within any of the nodes provided the transformation will be ignored.
Signature:
ignoredNodes?: string[];
property regexp
A regex test for the file type.
Signature:
regexp?: RegExp;
property type
Signature:
type: 'file';
interface IsInCodeOptions
Signature:
export interface IsInCodeOptions
property contained
When this is set to true ensure the selection is fully contained within a code block. This means that selections that span multiple characters must all be within a code region for it to return true.
Signature:
contained?: boolean;
interface MarkPasteRule
For adding marks to text when a paste rule is activated.
Signature:
export interface MarkPasteRule extends BaseContentPasteRule
Extends: BaseContentPasteRule
(Some inherited members may not be shown because they are not represented in the documentation.)
property markType
The prosemirror mark type instance.
Signature:
markType: MarkType;
property replaceSelection
Set to true
to replace the selection. When the regex matches for the selected text.
Can be a function which receives the text that will be replaced.
Signature:
replaceSelection?: boolean | ((replacedText: string) => boolean);
property transformMatch
A function that transforms the match into the desired text value.
Return an empty string to delete all content.
Return false
to invalidate the match.
Signature:
transformMatch?: (match: RegExpExecArray) => string | null | undefined | false;
property type
The type of rule.
Signature:
type: 'mark';
interface NodePasteRule
Signature:
export interface NodePasteRule extends BaseContentPasteRule
Extends: BaseContentPasteRule
(Some inherited members may not be shown because they are not represented in the documentation.)
property getContent
A function that transforms the match into the content to use when creating a node.
Pass () => {}
to remove the matched text.
If this function is undefined, then the text node that is cut from the match will be used as the content.
Signature:
getContent?: (match: RegExpExecArray) => Fragment | ProsemirrorNode | ProsemirrorNode[] | undefined | void;
property nodeType
The node type to create.
Signature:
nodeType: NodeType;
property type
The type of rule.
Signature:
type: 'node';
interface TextPasteRule
For handling simpler text updates.
Signature:
export interface TextPasteRule extends BaseRegexPasteRule
Extends: BaseRegexPasteRule
(Some inherited members may not be shown because they are not represented in the documentation.)
property transformMatch
A function that transforms the match into the desired text value.
Return an empty string to delete all content.
Return false
to invalidate the match.
Signature:
transformMatch?: (match: RegExpExecArray) => string | null | undefined | false;
property type
The type of rule.
Signature:
type: 'text';
type FileHandlerProps
Signature:
export type FileHandlerProps = FilePasteHandlerProps | FileDropHandlerProps;
References: FilePasteHandlerProps, FileDropHandlerProps
type PasteRule
Signature:
export type PasteRule = FilePasteRule | TextPasteRule | NodePasteRule | MarkPasteRule;
References: FilePasteRule, TextPasteRule, NodePasteRule, MarkPasteRule