@eigenpal/docx-editor-core/prosemirror/template/prosemirror-plugin

Template ProseMirror Plugin

Simple plugin that finds template tags using regex and creates decorations. No separate parsing layer - everything happens here.

Functions (4)

createTemplatePluginfunctionSource ↗

Create the template plugin

declare function createTemplatePlugin(): Plugin<TemplatePluginState>;

getTemplateTagsfunctionSource ↗

Get tags from editor state

declare function getTemplateTags(state: prosemirror_state.EditorState): TemplateTag[];

setHoveredElementfunctionSource ↗

Set hovered tag

declare function setHoveredElement(view: EditorView, id: string | undefined): void;

setSelectedElementfunctionSource ↗

Set selected tag

declare function setSelectedElement(view: EditorView, id: string | undefined): void;

Interfaces (1)

TemplateTaginterfaceSource ↗

A found template tag

interface TemplateTag
MemberTypeSummary
fromnumber
idstring
insideSection?booleanTrue if this variable is inside a section (shown in section's nested vars)
namestring
nestedVars?string[]For sections: nested variable names
rawTagstring
tonumber
typeTagType

Type aliases (1)

TagTypetypeSource ↗

Template tag types

type TagType = 'variable' | 'sectionStart' | 'sectionEnd' | 'invertedStart' | 'raw';

Variables (2)

TEMPLATE_DECORATION_STYLESconstSource ↗

CSS styles for template decorations

TEMPLATE_DECORATION_STYLES = "\n.docx-template-tag {\n  cursor: pointer;\n  transition: background-color 0.1s;\n}\n\n.docx-template-tag:hover,\n.docx-template-tag.hovered {\n  filter: brightness(0.95);\n}\n\n.docx-template-tag.selected {\n  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);\n}\n"

templatePluginKeyconstSource ↗

Plugin key

templatePluginKey: PluginKey<TemplatePluginState>

On this page