@stesura/core/helpers
Helpers that read or derive editor state (document, selection, marks, styles, numbering, sections, tables) and convert attrs to CSS. None of them dispatch except clearContent, startImageUpload and unWrap.
Core ProseMirror utilities
applyTrForEachNodeType
Parameters:| Name | Type | Default |
|---|---|---|
nodeTypes | string[] | |
callback | (type: string) => boolean |
attrAwareTokenEncoder
Parameters:| Name | Type | Default |
|---|---|---|
attrNames | readonly string[] |
blockHasNoText
Parameters:| Name | Type | Default |
|---|---|---|
node | Node |
canWrapInInlineNode
Parameters:| Name | Type | Default |
|---|---|---|
selection | Selection | |
state | EditorState |
clearContent
Parameters:| Name | Type | Default |
|---|---|---|
view | EditorView | |
schema | Schema<any, any> |
combineTransactionSteps
Parameters:| Name | Type | Default |
|---|---|---|
oldDoc | Node | |
transactions | Transaction[] |
convertContentToSchema
Parameters:createNodeFromContent
Parameters:| Name | Type | Default |
|---|---|---|
content | string | JSONContent | JSONContent[] | Node | Fragment | |
schema | Schema<any, any> | |
options | CreateNodeFromContentOptions |
defaultBlockAt
Parameters:| Name | Type | Default |
|---|---|---|
match | ContentMatch |
docChanged
Parameters:| Name | Type | Default |
|---|---|---|
__0 | AppendTransactionProps |
docIsEmpty
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
docNodeIsEmpty
Parameters:| Name | Type | Default |
|---|---|---|
doc | Node |
elementFromString
Parameters:| Name | Type | Default |
|---|---|---|
value | string |
emitProfile
Parameters:| Name | Type | Default |
|---|---|---|
event | ProfilerEvent |
filterFragment
Parameters:| Name | Type | Default |
|---|---|---|
fragment | Fragment | |
shouldRemove | (node: Node, pos: number) => boolean | |
transform | (node: Node, pos: number) => Node |
findChildrenInRange
Parameters:| Name | Type | Default |
|---|---|---|
node | Node | |
range | Range | |
predicate | FindPredicate | |
expandSlice | boolean |
findNode
Parameters:| Name | Type | Default |
|---|---|---|
node | Node | |
predicate | (node: Node) => boolean |
findNodes
Parameters:| Name | Type | Default |
|---|---|---|
node | Node | |
predicate | (node: Node) => boolean |
findWordBoundary
Parameters:| Name | Type | Default |
|---|---|---|
doc | Node | |
pos | number | |
direction | 1 | -1 |
forEachNode
Parameters:| Name | Type | Default |
|---|---|---|
range | NodeRange | |
callback | (node: Node, pos: number) => void |
getAddedAndRemovedNodes
Parameters:| Name | Type | Default |
|---|---|---|
__0 | AddedAndRemovedNodePropsAlso report ancestors spanning a change. Default: only nodes starting inside it. |
{ removed: { node: Node; pos: number; }[] | undefined; added: { node: Node; pos: number; }[] | undefined; changes?: never; } | { removed: { node: Node; pos: number; }[] | undefined; added: { ...; }[] | undefined; changes: readonly Change<...>[]; }removed (positions in oldState), added (positions in newState)
and the ChangeSet changes, which are absent on the early exits.
getAttributes
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
typeOrName | string | NodeType | MarkType |
getChangeDeletions
Parameters:| Name | Type | Default |
|---|---|---|
changes | Change<any>[] | readonly Change<any>[] |
getChangedRanges
Parameters:| Name | Type | Default |
|---|---|---|
transform | Transform |
getChangeInsertions
Parameters:| Name | Type | Default |
|---|---|---|
changes | Change<any>[] | readonly Change<any>[] |
getDomRangeFromSelection
Parameters:| Name | Type | Default |
|---|---|---|
view | EditorView | |
selection | Selection |
getEditorId
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getMarkAttributes
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
typeOrName | string | MarkType |
getMarkRange
Parameters:| Name | Type | Default |
|---|---|---|
$pos | ResolvedPos | |
type | MarkType | |
attributes | Attrs |
getMarksBetween
Parameters:| Name | Type | Default |
|---|---|---|
from | number | |
to | number | |
doc | Node |
getMarkType
Parameters:| Name | Type | Default |
|---|---|---|
nameOrType | string | MarkType | |
schema | Schema<any, any> |
getNodeAttributes
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
typeOrName | string | NodeType |
getNodeSpecAttrs
Parameters:| Name | Type | Default |
|---|---|---|
node | Node | |
childIndex | numberRead the nested spec at this index instead (e.g. |
getNodeSpecDataAttrs
Parameters:| Name | Type | Default |
|---|---|---|
node | Node | |
childIndex | number |
getNodeSpecReactProps
Parameters:| Name | Type | Default |
|---|---|---|
node | Node | |
childIndex | number |
getNodeType
Parameters:| Name | Type | Default |
|---|---|---|
nameOrType | string | NodeType | |
schema | Schema<any, any> |
getParagraphOrHeading
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getParentEditorId
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getProfilerHook
Parameters:getRectFromCoords
Parameters:| Name | Type | Default |
|---|---|---|
coords | { top: number; left: number; right: number; bottom: number; } |
{ x: number; y: number; width: number; height: number; top: number; right: number; bottom: number; left: number; }getSchemaTypeByName
Parameters:| Name | Type | Default |
|---|---|---|
name | string | |
schema | Schema<any, any> |
getSchemaTypeNameByName
Parameters:| Name | Type | Default |
|---|---|---|
name | string | |
schema | Schema<any, any> |
isAddMarkStep
Parameters:| Name | Type | Default |
|---|---|---|
step | Step |
isAddNodeMarkStep
Parameters:| Name | Type | Default |
|---|---|---|
step | Step |
isAttrStep
Parameters:| Name | Type | Default |
|---|---|---|
step | Step |
isCollabOrHistoryTransaction
Parameters:| Name | Type | Default |
|---|---|---|
tr | Transaction |
isCollabTransaction
Parameters:| Name | Type | Default |
|---|---|---|
tr | Transaction |
isDocAttrStep
Parameters:| Name | Type | Default |
|---|---|---|
step | Step |
isHistoryTransaction
Parameters:| Name | Type | Default |
|---|---|---|
tr | Transaction |
isMarkActive
Parameters:| Name | Type | Default |
|---|---|---|
mark | MarkType | |
state | EditorState |
isNodeActive
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
typeOrName | string | NodeType | |
attributes | Attrs |
isRemoteCollabTransaction
Parameters:| Name | Type | Default |
|---|---|---|
tr | Transaction |
isRemoveMarkStep
Parameters:| Name | Type | Default |
|---|---|---|
step | Step |
isRemoveNodeMarkStep
Parameters:| Name | Type | Default |
|---|---|---|
step | Step |
isReplaceAroundStep
Parameters:| Name | Type | Default |
|---|---|---|
step | Step |
isReplaceStep
Parameters:| Name | Type | Default |
|---|---|---|
step | Step |
isSimpleTextTransaction
Parameters:| Name | Type | Default |
|---|---|---|
tr | Transaction |
isTextSelection
Parameters:| Name | Type | Default |
|---|---|---|
value | unknown |
nodeHasContent
Parameters:| Name | Type | Default |
|---|---|---|
node | Node |
nodeIsInOrAroundSelection
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
callback | (node: Node) => boolean |
pmBench
Parameters:| Name | Type | Default |
|---|---|---|
label | string | |
fn | () => T |
pmBenchEnd
Parameters:| Name | Type | Default |
|---|---|---|
label | string | |
start | number | |
info | Record<string, unknown> |
pmBenchStart
Parameters:posToDOMRect
Parameters:| Name | Type | Default |
|---|---|---|
view | EditorView | |
from | number | |
to | number |
profilerActive
Parameters:ProfilerDispatchEvent
ProfilerEvent
ProfilerLayoutBlockDrift
| Name | Type | Default |
|---|---|---|
nodeId | string | |
type | string | |
page | number | |
expected | number | |
actual | number | |
drift | number | |
step | number |
ProfilerLayoutPageDrift
| Name | Type | Default |
|---|---|---|
page | number | |
nodeId | string | |
drift | number | |
step | number |
ProfilerPaginationLayoutCheckEvent
ProfilerReactCommitEvent
| Name | Type | Default |
|---|---|---|
type | "reactCommit" | |
editorId | string | |
phase | "mount" | "update" | "nested-update" | |
ms | numberReact’s actualDuration: time spent rendering the committed update. | |
at | number |
returnDocChanges
Parameters:| Name | Type | Default |
|---|---|---|
__0 | AppendTransactionProps |
selectionSpansEntireNode
Parameters:| Name | Type | Default |
|---|---|---|
selection | Selection | SelectionRange |
selectionToInsertionEnd
Parameters:| Name | Type | Default |
|---|---|---|
tr | Transaction | |
startLen | number | |
bias | number |
unWrap
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
dispatch | (tr: Transaction) => void | |
getPos | () => number |
Accessibility
checkAccessibility
Parameters:| Name | Type | Default |
|---|---|---|
doc | Node |
Borders
borderStyleToCSS
| Name | Type | Default |
|---|---|---|
single | string | |
dashed | string | |
dotted | string | |
double | string | |
groove | string | |
ridge | string | |
inset | string | |
outset | string | |
none | string |
createDefaultBorderOptions
Parameters:createDefaultBorders
Parameters:deriveBorderOptions
Parameters:| Name | Type | Default |
|---|---|---|
borders | Borders |
generateTableBorderStyles
Parameters:| Name | Type | Default |
|---|---|---|
borders | TableBorders | |
showOutline | boolean |
getBordersAndNodeType
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getEffectiveCellBorders
Parameters:| Name | Type | Default |
|---|---|---|
table | Node | |
tableMap | TableMap | |
cellPos | number |
parseBorderStyles
Parameters:| Name | Type | Default |
|---|---|---|
borderCSSValue | string |
returnAllBorderStyles
Parameters:| Name | Type | Default |
|---|---|---|
borders | Borders |
returnAllBorderStylesObject
Parameters:| Name | Type | Default |
|---|---|---|
borders | Borders | |
showOutline | boolean |
returnBorderClasses
Parameters:| Name | Type | Default |
|---|---|---|
border | keyof SelectedBorders | "none" | "horizontalRule" | |
currentBorders | Borders |
returnBorderCSSValue
Parameters:| Name | Type | Default |
|---|---|---|
options | Mutable<Omit<IBorderOptions, "style"> & { style: BorderStyle; }> | |
showOutline | boolean |
returnBorderStyles
Parameters:returnCellBorderStyles
Parameters:| Name | Type | Default |
|---|---|---|
borders | CellBorders |
Canvas Gradient
CanvasGradient
| Name | Type | Default |
|---|---|---|
from | stringAny CSS color; resolved to | |
to | string | |
direction | CanvasGradientDirection |
canvasGradientCss
Parameters:| Name | Type | Default |
|---|---|---|
__0 | CanvasGradient |
CanvasVars
| Name | Type | Default |
|---|---|---|
solid | string | null | |
from | string | null | |
to | string | null | |
direction | string |
colorAtFraction
Parameters:| Name | Type | Default |
|---|---|---|
from | Rgb | |
to | Rgb | |
fraction | number |
gapGradientCss
Parameters:| Name | Type | Default |
|---|---|---|
gradient | CanvasGradient | |
rect | { x: number; y: number; width: number; height: number; } | |
boxWidth | number | |
boxHeight | number |
gradientAngleDeg
Parameters:| Name | Type | Default |
|---|---|---|
direction | CanvasGradientDirection | |
boxWidth | number | |
boxHeight | number |
gradientFractionAt
Parameters:| Name | Type | Default |
|---|---|---|
direction | CanvasGradientDirection | |
x | number | |
y | number | |
width | number | |
height | number |
isCanvasGradientDirection
Parameters:| Name | Type | Default |
|---|---|---|
value | string |
isDarkScheme
Parameters:| Name | Type | Default |
|---|---|---|
el | Element |
parseColor
Parameters:| Name | Type | Default |
|---|---|---|
value | string |
resolveCanvas
Parameters:| Name | Type | Default |
|---|---|---|
__0 | CanvasVars |
ResolvedCanvas
Rgb
| Name | Type | Default |
|---|---|---|
r | number | |
g | number | |
b | number | |
a | number |
Code Block
isCodeBlockNode
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
isInCodeBlock
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
toLanguage
Parameters:| Name | Type | Default |
|---|---|---|
language | string |
toTheme
Parameters:| Name | Type | Default |
|---|---|---|
theme | string |
Comments
getNodeCommentEntries
Parameters:| Name | Type | Default |
|---|---|---|
node | Node |
nodeTypeSupportsNodeComments
Parameters:| Name | Type | Default |
|---|---|---|
type | NodeType |
Config Plugin
getAllowedFileHosts
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getToaster
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
isPrintMount
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
Cross-References
toCrossRefType
Parameters:| Name | Type | Default |
|---|---|---|
type | string |
Document initialisation
compactDocJson
On a style-heavy DOCX import the compacted JSON is typically 2–3× smaller.
import { compactDocJson } from "@stesura/core/helpers";
const contentJson = JSON.stringify(compactDocJson(doc.toJSON(), schema));See DOCX Import & Export → Persisting the imported document for the full pipeline.
Parameters:| Name | Type | Default |
|---|---|---|
json | JSONContent | |
schema | Schema<any, any> |
createDocContent
Parameters:| Name | Type | Default |
|---|---|---|
schema | Schema<any, any> | |
blocks | DocContentBlock[] |
createInitialDoc
Parameters:| Name | Type | Default |
|---|---|---|
schema | Schema<any, any> | |
initialContent | string | JSONContent | JSONContent[] | Node | Fragment |
DocContentBlock
| Name | Type | Default |
|---|---|---|
type | "heading" | "paragraph" | |
text | string |
normalizeDocJsonIds
Parameters:| Name | Type | Default |
|---|---|---|
json | JSONContent | |
schema | Schema<any, any> |
Formatting
formattingAttrsToCss
Parameters:| Name | Type | Default |
|---|---|---|
formatting | IndentAttrs |
getDocumentDirection
Parameters:| Name | Type | Default |
|---|---|---|
doc | Node |
getInheritedDirection
Parameters:| Name | Type | Default |
|---|---|---|
$pos | ResolvedPos |
getNodeAndStyleSheet
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getNodeFormattingFromNode
Parameters:| Name | Type | Default |
|---|---|---|
node | Node | |
state | EditorState |
getNodeFormattingFromSelection
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getResolvedDirection
Parameters:| Name | Type | Default |
|---|---|---|
node | Node | |
state | EditorState |
getSectionDirection
Parameters:| Name | Type | Default |
|---|---|---|
sectionAttrs | Attrs | |
doc | Node |
isTextDirection
Parameters:| Name | Type | Default |
|---|---|---|
value | unknown |
parseLineHeight
Parameters:| Name | Type | Default |
|---|---|---|
lineHeight | string | number |
parseSpecial
Parameters:| Name | Type | Default |
|---|---|---|
special | string |
returnFormattingStyles
Parameters:| Name | Type | Default |
|---|---|---|
options | IndentAttrs | |
isNumbered | boolean | |
followBy | "tab" | "space" | "nothing" | |
tabStop | number |
spacingAttrsToCss
Parameters:| Name | Type | Default |
|---|---|---|
spacing | SpacingAttrs |
spacingAttrsToReactStyle
Parameters:| Name | Type | Default |
|---|---|---|
spacing | SpacingAttrs |
spacingToDom
Parameters:| Name | Type | Default |
|---|---|---|
node | Node |
{ style: string; "data-spacing-before": number | null; "data-spacing-after": number | null; "data-spacing-contextual": string | null; "data-margin-top": number | null; "data-padding-top": number | null; "data-padding-bottom": number | null; }Header / Footer
detectExistingVariants
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
sectionId | string |
findHeaderFooterContentInFragment
Parameters:| Name | Type | Default |
|---|---|---|
fragment | Fragment | |
sectionId | string | |
target | "header" | "footer" | |
variant | string |
findHeaderFooterContentPos
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
sectionId | string | |
target | "header" | "footer" | |
variant | HeaderFooterVariant |
getHeaderFooterContent
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
sectionId | string | |
target | "header" | "footer" | |
variant | HeaderFooterVariant |
Highlight
getHighlightPluginState
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
isHighlightColor
Parameters:| Name | Type | Default |
|---|---|---|
value | string |
Math
isMathNodeType
Parameters:| Name | Type | Default |
|---|---|---|
type | NodeType |
marksToMathMarks
Parameters:| Name | Type | Default |
|---|---|---|
marks | readonly Mark[] |
mathNodeMarks
Parameters:| Name | Type | Default |
|---|---|---|
node | Node |
mathNodeStyle
Parameters:| Name | Type | Default |
|---|---|---|
node | Node |
MathStyle
| Name | Type | Default |
|---|---|---|
color | string | |
fontSize | numberPoints, matching the | |
bgColor | string |
selectedMathNode
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
Files
effectiveRotation
Parameters:| Name | Type | Default |
|---|---|---|
nativeDegrees | number | |
attr | FileRotation |
fileDisplayName
Parameters:| Name | Type | Default |
|---|---|---|
attrs | Pick<FileAttrs, "name" | "src"> |
fileKind
Parameters:| Name | Type | Default |
|---|---|---|
attrs | Pick<FileAttrs, "mimeType"> |
isPdfFileNode
Parameters:| Name | Type | Default |
|---|---|---|
node | Node |
isPdfPreview
Parameters:| Name | Type | Default |
|---|---|---|
node | Node | |
config | PdfPreviewConfig |
toFileRotation
Parameters:| Name | Type | Default |
|---|---|---|
value | unknown |
Images
dataURIToFile
Parameters:| Name | Type | Default |
|---|---|---|
dataURI | string | |
name | string |
getImageWrap
Parameters:| Name | Type | Default |
|---|---|---|
wrap | string |
imageAltFromDom
Parameters:| Name | Type | Default |
|---|---|---|
img | Element |
imageAltToDom
Parameters:| Name | Type | Default |
|---|---|---|
state | ImageAltState |
imageCropLayout
Parameters:| Name | Type | Default |
|---|---|---|
width | number | |
height | number | |
crop | ImageCrop |
imageTransformCss
Parameters:| Name | Type | Default |
|---|---|---|
transform | ImageTransform |
ImageUploadReturn
| Name | Type | Default |
|---|---|---|
url | string | |
alt | string |
sanitizeImageSrc
Parameters:| Name | Type | Default |
|---|---|---|
src | string |
setImageUploadStrategy
Parameters:| Name | Type | Default |
|---|---|---|
strategy | (file: File) => Promise<string> |
startImageUpload
Parameters:| Name | Type | Default |
|---|---|---|
view | EditorView | |
fileOrUrl | string | File | |
alt | string | |
schema | Schema<any, any> | |
pos | number |
toImageAlign
Parameters:| Name | Type | Default |
|---|---|---|
align | string |
toImageAnchoredSide
Parameters:| Name | Type | Default |
|---|---|---|
side | string |
toImageAnchoredWrap
Parameters:| Name | Type | Default |
|---|---|---|
wrap | string |
toImageCrop
Parameters:| Name | Type | Default |
|---|---|---|
raw | unknown |
toImageTransform
Parameters:| Name | Type | Default |
|---|---|---|
raw | unknown |
Tab Stops
computeTabWidths
Parameters:| Name | Type | Default |
|---|---|---|
__0 | { start: number; tabs: MeasuredTab[]; stops: TabStop[] | null; defaultInterval?: number; hangingStop?: number | null; } |
hangingTabStop
Parameters:| Name | Type | Default |
|---|---|---|
indent | IndentAttrs |
MeasuredTab
| Name | Type | Default |
|---|---|---|
following | numberWidth of the text after this tab, up to the next tab or the line’s end. | |
beforeDecimal | numberWidth of that text up to its first ”.”, for a decimal stop. |
parseTabStops
Parameters:| Name | Type | Default |
|---|---|---|
value | unknown |
resolveTabStops
Parameters:| Name | Type | Default |
|---|---|---|
node | Node | |
styleSheet | StyleSheet |
TabLayout
| Name | Type | Default |
|---|---|---|
width | number | |
leader | TabStopLeader |
Invisible Characters
isShowingInvisibleCharacters
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
Language
getDocumentLanguage
Parameters:| Name | Type | Default |
|---|---|---|
doc | Node |
getLanguageFromSelection
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getSelectionLanguage
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getStyleLanguage
Parameters:| Name | Type | Default |
|---|---|---|
styleSheet | StyleSheet | |
styleSheetId | string |
resolveBlockLanguage
Parameters:| Name | Type | Default |
|---|---|---|
node | Node | |
styleSheet | StyleSheet | |
documentLanguage | string |
resolveLanguageAtPos
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
pos | number |
SelectionLanguage
toLangTag
Parameters:| Name | Type | Default |
|---|---|---|
value | string |
Numbering
buildTabStopCss
Parameters:| Name | Type | Default |
|---|---|---|
listConfigs | Record<string, ILevelsOptions[]> |
createListFormatOptions
Parameters:| Name | Type | Default |
|---|---|---|
lang | string | |
gender | NumberGender |
createPickableListFormatOptions
Parameters:| Name | Type | Default |
|---|---|---|
lang | string | |
gender | NumberGender |
findNextNumberedNode
Parameters:| Name | Type | Default |
|---|---|---|
doc | Node | |
currentPos | number |
findPreviousNumberedNode
Parameters:| Name | Type | Default |
|---|---|---|
doc | Node | |
currentPos | number |
getDocListConfigs
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getEffectiveNumbering
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
node | Node |
getEffectiveNumberingAtSelection
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getEffectiveNumberingAtSelectionAnchor
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getFormatOptionLabel
Parameters:| Name | Type | Default |
|---|---|---|
option | ListFormatOption |
getFormatPreviewLabel
Parameters:| Name | Type | Default |
|---|---|---|
__0 | { format: LevelFormat; number: number; lang?: string; } |
getLevelPreviewLabel
Parameters:| Name | Type | Default |
|---|---|---|
__0 | { text?: string; levels: ILevelsOptions[]; lang?: string; count?: { level: number; number: number; }; } |
getListConfig
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
listRef | string |
getListConfigCustom
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getListConfigs
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getNumberingAttrsAtSelectionAnchor
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getStyleForListLevel
Parameters:| Name | Type | Default |
|---|---|---|
resolvedSheet | StyleSheet | |
listRef | string | |
level | number |
getStyleNumbering
Parameters:| Name | Type | Default |
|---|---|---|
resolvedSheet | StyleSheet | |
styleId | string |
getStyleNumberingBinding
Parameters:| Name | Type | Default |
|---|---|---|
resolvedSheet | StyleSheet |
indentsAreEqual
Parameters:| Name | Type | Default |
|---|---|---|
a | IndentAttrs | |
b | IndentAttrs |
isInheritedListRef
Parameters:| Name | Type | Default |
|---|---|---|
listRef | unknown |
listLevelsAreEqual
Parameters:| Name | Type | Default |
|---|---|---|
levels | ILevelsOptions[] | |
otherLevels | ILevelsOptions[] |
localeHasNumberGenderVariants
Parameters:| Name | Type | Default |
|---|---|---|
lang | string |
nodeIsInInstance
Parameters:| Name | Type | Default |
|---|---|---|
node | Node | |
listRef | string | |
instanceId | string |
nodeIsNumbered
Parameters:| Name | Type | Default |
|---|---|---|
attrs | Attrs |
numberingListRef
Parameters:| Name | Type | Default |
|---|---|---|
numbering | NumberingAttrs |
renderLevelNumber
Parameters:| Name | Type | Default |
|---|---|---|
levelConfig | Pick<ILevelsOptions, "format" | "gender" | "casing"> | |
value | number | |
lang | string |
resolveEffectiveNumbering
Parameters:| Name | Type | Default |
|---|---|---|
resolvedSheet | StyleSheet | |
node | Node |
resolveTabStopAtSelection
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
returnComputedListRef
Parameters:| Name | Type | Default |
|---|---|---|
__0 | { state: EditorState; levels: ILevelsOptions[]; prevListRef: string | undefined; } |
StyleNumberingBinding
styleNumbersNode
Parameters:| Name | Type | Default |
|---|---|---|
resolvedSheet | StyleSheet | |
node | Node |
Page Number
collectPageNumbering
Parameters:| Name | Type | Default |
|---|---|---|
doc | Node |
formatPageNumber
Parameters:| Name | Type | Default |
|---|---|---|
n | number | |
format | PageNumberFormat |
sectionFirstPageNumbers
Parameters:| Name | Type | Default |
|---|---|---|
pageCounts | Map<string, number> | |
pageNumbering | Map<string, PageNumberingAttrs> |
toPageType
Parameters:| Name | Type | Default |
|---|---|---|
pageType | string |
Recreate Transform
recreateTransform
Parameters:RecreateTransformOptions
| Name | Type | Default |
|---|---|---|
complexSteps | boolean | |
wordDiffs | boolean | |
simplifyDiff | boolean |
Search
classifySearchMatch
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
pos | number |
CommentSearchMatch
| Name | Type | Default |
|---|---|---|
threadId | string | |
commentId | string | |
start | numberFirst occurrence range in the comment’s flattened text. | |
end | number |
CommentSearchQueryConfig
| Name | Type | Default |
|---|---|---|
search | string | |
caseSensitive | boolean | |
wholeWord | boolean | |
literal | booleanWhen true, don’t unquote |
findCommentMatches
Parameters:| Name | Type | Default |
|---|---|---|
threads | readonly Thread[] | |
config | CommentSearchQueryConfig |
flattenCommentBody
Parameters:| Name | Type | Default |
|---|---|---|
body | JSONContent |
getMatchHighlights
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getSearchState
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
SearchMatchRegion
| Name | Type | Default |
|---|---|---|
kind | "body" | "footnote" | "endnote" | "headerFooter" | "comment" |
setSearchState
Parameters:| Name | Type | Default |
|---|---|---|
tr | Transaction | |
query | SearchQuery | |
range | { from: number; to: number; } |
Plugins
filterPlugins
Parameters:| Name | Type | Default |
|---|---|---|
plugins | Plugin<any>[] | |
excludePlugins | string[] |
getPluginKeyLabel
Parameters:| Name | Type | Default |
|---|---|---|
p | Plugin<any> |
Section
createHeaderFooterContent
Parameters:| Name | Type | Default |
|---|---|---|
schema | Schema<any, any> | |
variant | HeaderFooterVariant |
createSection
Parameters:| Name | Type | Default |
|---|---|---|
schema | Schema<any, any> | |
contentToInsert | Slice | |
currentSection | Node |
findParentSection
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
findParentSectionAtPos
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
pos | number |
findSectionById
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
sectionId | string |
getDefaultSectionContentWidth
Parameters:getSectionAttrsById
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
sectionId | string |
getSectionContentWidth
Parameters:| Name | Type | Default |
|---|---|---|
sectionAttrs | SectionAttrs |
getSectionContentWidthAtPos
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
pos | number |
getSectionRangesAndWidth
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getWidthOfSectionAtPos
Parameters:| Name | Type | Default |
|---|---|---|
sectionRanges | SectionRange[] | |
pos | number |
Style Gallery
GalleryStyle
| Name | Type | Default |
|---|---|---|
id | string | |
style | StyleDefinition |
getGalleryStyles
Parameters:| Name | Type | Default |
|---|---|---|
styleSheet | StyleSheet |
getQuickStyles
Parameters:| Name | Type | Default |
|---|---|---|
styleSheet | StyleSheet | |
usedStyleIds | Set<string> | |
activeStyleId | string |
getUsedStyleIds
Parameters:| Name | Type | Default |
|---|---|---|
stateOrDoc | EditorState | Node |
Style Sheet
generateStyleSheetCSS
Parameters:| Name | Type | Default |
|---|---|---|
styleSheet | StyleSheet | |
editorId | string |
getResolvedStyleDefinition
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
styleDefinitionId | string |
getResolvedStyleSheet
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getResolvedStyleSheetFromDoc
Parameters:| Name | Type | Default |
|---|---|---|
doc | Node |
getSelectionCharacterStyleId
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getStyleOutlineLevel
Parameters:| Name | Type | Default |
|---|---|---|
styleSheet | StyleSheet | |
styleSheetId | string |
getStylePaginationProps
Parameters:| Name | Type | Default |
|---|---|---|
resolvedStyle | StyleDefinition |
getStyleSheet
Parameters:| Name | Type | Default |
|---|---|---|
stateOrDoc | EditorState | Node |
getStyleSheetOverrides
Parameters:| Name | Type | Default |
|---|---|---|
stateOrDoc | EditorState | Node |
isChangingHeadingLevel
Parameters:| Name | Type | Default |
|---|---|---|
node | Node | |
newLevel | number |
isCharacterStyle
Parameters:| Name | Type | Default |
|---|---|---|
style | StyleDefinition |
mergeStyleDefinition
Parameters:| Name | Type | Default |
|---|---|---|
base | StyleDefinition | |
overlay | Partial<StyleDefinition> |
mergeStyleSheets
Parameters:| Name | Type | Default |
|---|---|---|
base | StyleSheet | |
overlay | StyleSheet |
normalizeStyleDefinition
Parameters:| Name | Type | Default |
|---|---|---|
styleId | string | |
styleDef | Partial<StyleDefinition> |
paragraphStyleIds
Parameters:| Name | Type | Default |
|---|---|---|
styleSheet | StyleSheet |
paragraphStylesToCss
Parameters:| Name | Type | Default |
|---|---|---|
paragraphStyle | ParagraphStyle |
pruneStyleAgainstBase
Parameters:| Name | Type | Default |
|---|---|---|
override | Partial<StyleDefinition> | |
base | Partial<StyleDefinition> | undefined |
pruneStyleAgainstDefault
Parameters:| Name | Type | Default |
|---|---|---|
styleId | string | |
override | Partial<StyleDefinition> |
resolveStyleDefinition
Parameters:| Name | Type | Default |
|---|---|---|
styleSheet | StyleSheet | |
styleName | string | |
prevBasedOn | string[] |
resolveStyleSheet
Parameters:| Name | Type | Default |
|---|---|---|
styleSheet | StyleSheet |
shouldReplaceEntireNode
Parameters:| Name | Type | Default |
|---|---|---|
node | Node | |
newElementType | string | |
newLevel | number |
styleIsHeading
Parameters:| Name | Type | Default |
|---|---|---|
styleSheet | StyleSheet | |
styleSheetId | string |
textStyleToCss
Parameters:| Name | Type | Default |
|---|---|---|
textStyle | TextStyle |
Tables
findTable
Parameters:| Name | Type | Default |
|---|---|---|
$pos | ResolvedPos |
fitTableColumns
Parameters:| Name | Type | Default |
|---|---|---|
table | Node | |
availableWidth | numbercontent width of the destination (page width − margins). | |
minWidth | numberfloor for every column, px. |
getColumnsWidths
Parameters:| Name | Type | Default |
|---|---|---|
tableMap | TableMap | |
table | Node |
getColumnsWidthsFromSelection
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getRowHeightFromSelection
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getSelectedColumIndexes
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getTableWidth
Parameters:| Name | Type | Default |
|---|---|---|
columnWidths | (number | null)[] |
isInTable
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
isWholeTableSelected
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
testOnly | booleanShort-circuits to “the selection is a CellSelection inside a table”, skipping the coverage check. For callers that only need to know a table is involved. |
loopThroughCells
Parameters:| Name | Type | Default |
|---|---|---|
table | FindNodeResult | |
tableMap | TableMap | |
callBack | ({ node, pos, colIndex, rowIndex, }: { node: Node; pos: number; colIndex: number; rowIndex: number; }) => boolean | void |
rowHasMergedCellsVertically
Parameters:| Name | Type | Default |
|---|---|---|
tableMap | TableMap | |
rowIndex | number |
selectionCell
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
setTableColumnWidths
Parameters:| Name | Type | Default |
|---|---|---|
table | Node | |
columns | number[] |
Text Style
capsFromCss
Parameters:| Name | Type | Default |
|---|---|---|
textTransform | string | |
fontVariant | string |
capsToCss
Parameters:| Name | Type | Default |
|---|---|---|
caps | Caps |
EffectiveFontFamily
getEffectiveFontFamily
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getEffectiveFontSize
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getNodeBackgroundColor
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getStyleSheetBackgroundColor
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
getTextStyles
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState |
isInheritedOrDefault
Parameters:| Name | Type | Default |
|---|---|---|
value | string |
isOff
Parameters:| Name | Type | Default |
|---|---|---|
attrs | { off?: readonly TextStyleOff[] | null; } | |
name | string |
resolveFontFamily
Parameters:| Name | Type | Default |
|---|---|---|
raw | string |
withOff
Parameters:| Name | Type | Default |
|---|---|---|
attrs | T | |
name | TextStyleOff | |
on | boolean |
Other exports
| Export | Type | Description |
|---|---|---|
CanvasGradientDirection | "to bottom" | "to top" | "to right" | "to left" | "to bottom right" | "to bottom left" | "to top right" | "to top left" | Directions a theme may declare. Mirrors the CSS to … keywords. |
CASED_LIST_FORMATS | readonly LevelFormatValue[] | The spelled-out formats whose output depends on casing. |
CellSelection | class | Re-exported from prosemirror-tables. |
cssStyleToBorder | Record<string, BorderStyle> | Inverse of borderStyleToCSS, for parsing pasted CSS. |
DEFAULT_FILE_HEIGHT | 600 | Preview height (px) of an unpaginated file node whose height is unset or zero. |
FILE_ROTATIONS | readonly FileRotation[] | [0, 90, 180, 270], in the order the chrome steps through them. |
GENDERED_LIST_FORMATS | readonly LevelFormatValue[] | The formats whose output depends on gender. |
ProfilerPluginHookKind | "stateApply" | "appendTr" | "filterTr" | Which plugin hook a pluginHook timing was measured on. |
RecreateTransform | class (type-only export) | Implementation behind recreateTransform. |
TableMap | class | Re-exported from prosemirror-tables. |
TEXT_STYLE_OFF | readonly TextStyleOff[] | Canonical order of textStyle.off; write it through withOff. |