Skip to main content

extension-doc

package @remirror/extension-doc

class DocExtension

This is the default parent node. It is required in the Prosemirror Schema and a representation of the doc is required as the top level node in all editors.

Extra attributes are disallowed for the doc extension.

Signature:

export declare class DocExtension extends NodeExtension<DocOptions> 

Extends: NodeExtension<DocOptions>

(Some inherited members may not be shown because they are not represented in the documentation.)

property name

Signature:

get name(): "doc";

method createNodeSpec

Create the node spec for the doc the content that you've provided.

Signature:

createNodeSpec(_: ApplySchemaAttributes, override: NodeSpecOverride): NodeExtensionSpec;

Parameters:

ParameterTypeDescription
_ApplySchemaAttributes
overrideNodeSpecOverride

Returns:

NodeExtensionSpec

method isDefaultDocNode

Signature:

isDefaultDocNode({ state, options, }?: IsDefaultDocNodeHelperOptions): Helper<boolean>;

Parameters:

ParameterTypeDescription
{ state, options, }IsDefaultDocNodeHelperOptions(Optional)

Returns:

Helper<boolean>

method setDocAttributes

Update the attributes for the doc node.

Signature:

setDocAttributes(attrs: ProsemirrorAttributes): CommandFunction;

Parameters:

ParameterTypeDescription
attrsProsemirrorAttributes

Returns:

CommandFunction

interface DocOptions

Signature:

export interface DocOptions 

property content

Adjust the content allowed in this prosemirror document.

This will alter the schema if changed after initialization and can cause errors. It should only be set **once** per editor.

Signature:

content?: Static<string>;

Remarks:

This field controls what sequences of child nodes are valid for this node type.

Taken from https://prosemirror.net/docs/guide/\#schema.content\_expressions

You can say, for example "paragraph" for “one paragraph”, or "paragraph+" to express “one or more paragraphs”. Similarly, "paragraph*" means “zero or more paragraphs” and "caption?" means “zero or one caption node”. You can also use regular-expression-like ranges, such as {2} (“exactly two”) {1, 5} (“one to five”) or {2,} (“two or more”) after node names.

Such expressions can be combined to create a sequence, for example "heading paragraph+" means ‘first a heading, then one or more paragraphs’. You can also use the pipe | operator to indicate a choice between two expressions, as in "(paragraph | blockquote)+".

Some groups of element types will appear multiple types in your schema—for example you might have a concept of “block” nodes, that may appear at the top level but also nested inside of blockquotes. You can create a node group by giving your node specs a group property, and then refer to that group by its name in your expressions.

property docAttributes

The doc node doesn't support extraAttribute. If you need to add support for adding new attributes then this property can be used to apply attributes directly to the doc node.

Signature:

docAttributes?: Static<string[]> | Static<Record<string, string | null>>;

Remarks:

Passing an array of strings, will initialise each key with the value null

new DocExtension({ docAttributes: ['key1', 'key2'] })

Passing an object, will initialise each key with an initial value

new DocExtension({
docAttributes: {
key1: 'value1',
key2: null
}
})