Skip to main content
Available since v0.10.0
Field Annotation use is not recommended because of its limited support for advanced document content (e.g., tables, advanced styling). Use the more versatile Structured Content Fields.

Configuration

boolean
default:"false"
Handle drops outside editor viewport
string
default:"'annotation'"
CSS class for field styling
string
default:"'#b015b3'"
Default field border color

Usage

Basic Setup:
Form Template Workflow:

Commands

findFieldAnnotations

Find field annotations matching a predicate function
Added in v0.10.3
Parameters:
function
required
Function to test each annotation node
EditorState
required
ProseMirror editor state
Returns:
Array
Matching field annotations

findFieldAnnotationsBetween

Find all field annotations between two positions
Parameters:
number
required
Start position
number
required
End position
Node
required
ProseMirror document node
Returns:
Array
Field annotations in range

findFieldAnnotationsByFieldId

Find field annotations by field ID(s)
Parameters:
string | Array.<string>
required
Single field ID or array of field IDs
EditorState
required
ProseMirror editor state
Returns:
Array
Matching field annotations

findFirstFieldAnnotationByFieldId

Find the first field annotation matching a field ID
Added in v0.10.2
Parameters:
string
required
Field ID to search for
EditorState
required
ProseMirror editor state
Returns:
Object | null
First matching annotation or null

findHeaderFooterAnnotationsByFieldId

Find field annotations in headers and footers by field ID or array of field IDs.
Added in v0.11.2
Parameters:
string | Array.<string>
required
The field ID or array of field IDs
Editor
required
The main editor instance
Editor
required
The currently active section editor
Returns:
Array
Array of field annotations with their positions

getAllFieldAnnotations

Get all field annotations in the document
Parameters:
EditorState
required
ProseMirror editor state
Returns:
Array
Array of field annotations with positions

getAllFieldAnnotationsWithRect

Get all field annotations with their bounding rectangles
Added in v0.11.0
Parameters:
EditorView
required
ProseMirror editor view
EditorState
required
ProseMirror editor state
Returns:
Array
Annotations with positions and rectangles

Delete & Remove

findRemovedFieldAnnotations

Find field annotation nodes that were removed in a transaction
Added in v0.11.2
Parameters:
Transaction
required
ProseMirror transaction to analyze
Returns:
Array
Array of removed field annotation nodes with their positions

deleteFieldAnnotations

Delete field annotations by field ID
Parameters:
string | Array.<string>
required
Field ID or array of field IDs to delete
Returns: boolean Command success status

deleteFieldAnnotationsByNode

Delete field annotations by node references
Parameters:
Array.<{pos: number, node: Node}>
required
Array of annotation objects to delete
Returns: boolean Command success status

deleteFieldAnnotation

Delete a single field annotation
Parameters:
Object
required
Annotation object to delete
Returns: boolean Command success status

sliceFieldAnnotations

Delete a portion of annotations associated with a field
Parameters:
string | Array.<string>
required
The field ID or array of field IDs
number
required
Index at which to end extraction
Returns: boolean Command success status

Create & Add

addFieldAnnotation

Add field annotation at specified position
Parameters:
number
required
Document position to insert annotation
Object
required
Field annotation attributes
boolean
Whether to focus editor after insertion
Returns: boolean Command success status

addFieldAnnotationAtSelection

Add field annotation at current selection position
Parameters:
Object
default:"{}"
Field annotation attributes
boolean
Whether to focus editor after insertion
Returns: boolean Command success status

Update & Edit

replaceWithFieldAnnotation

Replace text ranges with field annotations
Parameters:
Array.<Object>
required
Array of field replacement objects
object
required
Options object
Returns: boolean Command success status

replaceFieldAnnotationsWithLabelInSelection

Replace field annotations with text labels in current selection
Added in v0.11.0
Parameters:
Object
default:"{}"
Additional options
Returns: boolean Command success status

replaceFieldAnnotationsWithLabel

Replace field annotations with text labels
Added in v0.11.0
Parameters:
string | Array.<string>
required
Field ID(s) to replace
Object
default:"{}"
Replace options
Returns: boolean Command success status

resetFieldAnnotations

Reset all field annotations to their default values
Returns: boolean Command success status

updateFieldAnnotations

Update field annotations by field ID
Parameters:
string | Array.<string>
required
Field ID or array of field IDs
Object
default:"{}"
Attributes to update
Returns: boolean Command success status

updateFieldAnnotation

Update a specific field annotation instance
Parameters:
Object
required
Annotation object with pos and node
Object
default:"{}"
Attributes to update
Returns: boolean Command success status

updateFieldAnnotationsAttributes

Update the attributes of annotations
Parameters:
Array.<{pos: number, node: Node}>
required
Array of annotations to update
object
default:"{}"
Attributes to update
Returns: boolean Command success status

setFieldAnnotationsHiddenByCondition

Hide field annotations based on a condition
Parameters:
function
Function to test each annotation
boolean
Whether to show non-matching annotations
Returns: boolean Command success status

unsetFieldAnnotationsHidden

Show all hidden field annotations
Returns: boolean Command success status

setFieldAnnotationsVisibility

Set visibility for all field annotations
Parameters:
string
default:"'visible'"
Visibility value (‘visible’ or ‘hidden’)
Returns: boolean Command success status

setFieldAnnotationsHighlighted

Set highlighted status for annotations matching predicate
Parameters:
function
Function to test each annotation node
boolean
default:"true"
Whether to highlight matching annotations
Returns: boolean Command success status

toggleFieldAnnotationsFormat

Toggle formatting for field annotations in selection
Parameters:
string
required
Format name (bold, italic, underline)
boolean
Whether to set selection after toggle
Returns: boolean Command success status

setFieldAnnotationsFontFamily

Set font family for field annotations in current selection
Parameters:
string
required
Font family name to apply
boolean
Whether to set node selection after update
Returns: boolean Command success status

setFieldAnnotationsFontSize

Set font size for field annotations in current selection
Parameters:
string
required
Font size value (e.g., ‘12pt’, ‘14px’)
boolean
Whether to set node selection after update
Returns: boolean Command success status

setFieldAnnotationsTextHighlight

Set text highlight color for field annotations in current selection
Parameters:
string
required
Highlight color value (e.g., ‘#ffff00’, ‘yellow’)
boolean
Whether to set node selection after update
Returns: boolean Command success status

setFieldAnnotationsTextColor

Set text color for field annotations in current selection
Parameters:
string
required
Text color value (e.g., ‘#000000’, ‘black’)
boolean
Whether to set node selection after update
Returns: boolean Command success status

Helpers

transactionDeletedAnything

Check if a transaction contains any deletion operations Parameters:
Transaction
required
ProseMirror transaction to check
Returns: boolean True if transaction contains deletions

trackFieldAnnotationsDeletion

Track field annotation deletions in a transaction and emit events
Added in v0.11.2
Parameters:
Editor
required
SuperDoc editor instance
Transaction
required
ProseMirror transaction
Returns: void

handleDropOutside

Handle field annotation drops outside editor boundaries Parameters:
object
required
Drop handling parameters

Events

fieldAnnotationClicked

Field annotation clicked event Event Data:
  • node (Node) - The clicked annotation node
  • nodePos (number) - Position of the node in the document

fieldAnnotationDropped

Field annotation dropped event Event Data:
  • sourceField (object) - The dropped field attributes