Skip to main content

extension-entity-reference

package @remirror/extension-entity-reference

class EntityReferenceExtension​

Signature:

export declare class EntityReferenceExtension extends MarkExtension<EntityReferenceOptions> 

Extends: MarkExtension<EntityReferenceOptions>

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

property name​

Signature:

get name(): string;

method addEntityReference​

Signature:

addEntityReference(id?: string, attrs?: ProsemirrorAttributes): CommandFunction;

Parameters:

ParameterTypeDescription
idstring(Optional)
attrsProsemirrorAttributes(Optional)

Returns:

CommandFunction

method createEventHandlers​

Track click events passed through to the editor.

Signature:

createEventHandlers(): CreateEventHandlers;

Returns:

CreateEventHandlers

method createMarkSpec​

Signature:

createMarkSpec(extra: ApplySchemaAttributes, override: MarkSpecOverride): MarkExtensionSpec;

Parameters:

ParameterTypeDescription
extraApplySchemaAttributes
overrideMarkSpecOverride

Returns:

MarkExtensionSpec

method createPlugin​

Create the extension plugin for inserting decorations into the editor.

Signature:

createPlugin(): CreateExtensionPlugin<EntityReferenceState>;

Returns:

CreateExtensionPlugin<EntityReferenceState>

method getDisjoinedEntityReferences​

Get all disjoined entityReference attributes from the document.

Signature:

getDisjoinedEntityReferences(doc: ProsemirrorNode): Helper<EntityReferenceMetaData[][]>;

Parameters:

ParameterTypeDescription
docProsemirrorNode

Returns:

Helper<EntityReferenceMetaData[][]>

method getEntityReferenceById​

Signature:

getEntityReferenceById(entityReferenceId: string, state?: EditorState): Helper<EntityReferenceMetaData | undefined>;

Parameters:

ParameterTypeDescription
entityReferenceIdstringThe entity's reference Id.
stateEditorState(Optional)

Returns:

Helper<EntityReferenceMetaData | undefined>

EntityReference attributes from the editor's content, undefined if it doesn't exist.

method getEntityReferences​

Disjoined entityReferences are analog to ProseMirror's marks. When adding a mark that spans two (or more) nodes (like paragraphs), it will be stored as two (or more) marks on each node separately. The same is true for disjoined entityReferences. Therefore, a entityReference that spans multiple paragraphs is internally stored as multiple marks (all having the same entityReference ID as attribute).

To get the actual entityReferences (for which each entityReference ID is unique), call joinDisjoinedEntityReferences.

Signature:

getEntityReferences(state?: EditorState): Helper<EntityReferenceMetaData[]>;

Parameters:

ParameterTypeDescription
stateEditorState(Optional)

Returns:

Helper<EntityReferenceMetaData[]>

method getEntityReferencesAt​

Signature:

getEntityReferencesAt(pos?: PrimitiveSelection, state?: EditorState): Helper<EntityReferenceMetaData[]>;

Parameters:

ParameterTypeDescription
posPrimitiveSelection(Optional) the position in the root document to find entityReference marks.
stateEditorState(Optional)

Returns:

Helper<EntityReferenceMetaData[]>

all entityReferences at a specific position in the editor.

method removeEntityReference​

Signature:

removeEntityReference(entityReferenceId: string): CommandFunction;

Parameters:

ParameterTypeDescription
entityReferenceIdstring

Returns:

CommandFunction

method scrollToEntityReference​

Dispatch a transaction that selects the range of the entity reference then scrolls to it.

Signature:

scrollToEntityReference(entityReferenceId: string): CommandFunction;

Parameters:

ParameterTypeDescription
entityReferenceIdstringThe entity's reference Id.

Returns:

CommandFunction

True if the scrolling was applied, else it returns false

variable centeredEntityReferencePositioner​

Render a positioner which captures the selected entityReference.

Signature:

centeredEntityReferencePositioner: Positioner<{
from: Coords;
to: Coords;
}>

Remarks:

This extends the selection positioner. The difference is that the from and to coordinates are picked from the shortest entity reference selected.

variable findMinMaxRange​

Helper function to extract the extreme boundaries of the passed array of highlights. minimum from and the maximum to

Signature:

findMinMaxRange: (array: Array<Pick<EntityReferenceMetaData, 'from' | 'to'>>) => [number, number]

variable getShortestEntityReference​

This helper can be used when reacting to clicks on overlapping highlights. In that case, the app should show the shortest entity because longer entities typical have other click areas.

Signature:

getShortestEntityReference: <T extends EntityReferenceMarkText>(entityReferences: T[]) => T | undefined

interface EntityReferenceAttributes​

Signature:

export interface EntityReferenceAttributes 

property id​

Unique identifier of the entity references

Signature:

id: string;

interface EntityReferenceMetaData​

Signature:

export interface EntityReferenceMetaData extends EntityReferenceAttributes, FromToProps 

Extends: EntityReferenceAttributes, FromToProps

property attrs​

Only present if you have configured extra attributes for the entity reference mark

Signature:

attrs?: ProsemirrorAttributes;

property from​

The starting position in the document.

Signature:

from: number;

property id​

Unique identifier of the entity references

Signature:

id: string;

property text​

Text content of the node

Signature:

text: string;

property to​

The ending position in the document.

Signature:

to: number;