@stesura/core/stores
Per-editor nanostores atoms, the registry that finds them, and the global user preferences.
createEditorStores({ defaults, extensionStores }) builds one FullEditorStores per editor scope: atoms for the editor mode, TOC, pagination output (page counts, page numbering, the first-layout gate), stylesheet, list configs and block handle. extensionStores is spread into the result; type it by augmenting EditorStoreExtensions. The root editor’s configPlugin (part of basePlugins / stesuraPlugins) creates and registers them with addEditorStoresToMap when its view mounts and removes them on unmount, so integrators never call these; commands and plugins reach the stores through getEditorStores(idOrState) instead of taking a stores parameter. A sub-editor’s state falls through to its parent’s stores. In React, read and write them with useEditorStoreValue / useEditorStore from @stesura/editor-react.
userPreferences holds global atoms shared by every editor. Seed their defaults with initUserPreferences before the first mount.
Functions & values
addEditorStoresToMap
Parameters:| Name | Type | Default |
|---|---|---|
id | string | |
atoms | FullEditorStores |
addMountConfigToMap
Parameters:| Name | Type | Default |
|---|---|---|
id | string | |
state | ConfigPluginState |
createEditorStores
Parameters:| Name | Type | Default |
|---|---|---|
props | { defaults: Partial<EditorStoreDefaults>; extensionStores: Record<string, PreinitializedWritableAtom<unknown>>; } |
disarmAll
Parameters:| Name | Type | Default |
|---|---|---|
editorId | string | |
except | "formatPainter" | "highlight" |
getEditorStores
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState |
getFirstLayoutReady
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState |
getFirstLayoutReadyAtom
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState |
getMountConfig
Parameters:| Name | Type | Default |
|---|---|---|
id | string |
getNodePageNumbersStore
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState |
getPageCountsStore
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState |
getPageNumberingStore
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState |
getProofReadApiFailedFor
Parameters:| Name | Type | Default |
|---|---|---|
editorId | string |
getProofReadLoadingFor
Parameters:| Name | Type | Default |
|---|---|---|
editorId | string |
getRootEditorView
Parameters:| Name | Type | Default |
|---|---|---|
id | string |
getTocBreaksStore
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState |
getTOCstore
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState |
headerFooterEditorRegistry
initUserPreferences
Parameters:| Name | Type | Default |
|---|---|---|
defaults | Partial<UserPreferences> |
proofReadApiFailedByEditor
proofReadLoadingByEditor
registerArmedMode
Parameters:| Name | Type | Default |
|---|---|---|
editorId | string | |
key | "formatPainter" | "highlight" | |
disarm | () => void |
registerRootEditorView
Parameters:| Name | Type | Default |
|---|---|---|
id | string | |
view | EditorView |
registryVersion
removeEditorStoresFromMap
Parameters:| Name | Type | Default |
|---|---|---|
id | string |
removeMountConfigFromMap
Parameters:| Name | Type | Default |
|---|---|---|
id | string |
resolveEditorId
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState |
setFirstLayoutReady
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState | |
ready | boolean |
setNodePageNumbersStore
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState | |
pageNumbers | Map<string, string> |
setPageCountsStore
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState | |
pageCounts | Map<string, number> |
setPageNumberingStore
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState | |
pageNumbering | Map<string, PageNumberingAttrs> |
setProofReadApiFailedFor
Parameters:| Name | Type | Default |
|---|---|---|
editorId | string | |
value | boolean |
setProofReadLoadingFor
Parameters:| Name | Type | Default |
|---|---|---|
editorId | string | |
value | boolean |
setTocBreaksStore
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState | |
breaks | Map<string, TOCbreakEntry[]> |
setTOCstore
Parameters:| Name | Type | Default |
|---|---|---|
idOrState | string | EditorState | |
toc | TOCstate |
unregisterRootEditorView
Parameters:| Name | Type | Default |
|---|---|---|
id | string |
userPreferences
Types
HeaderFooterEditorKey
| Name | Type | Default |
|---|---|---|
sectionId | string | |
target | "header" | "footer" | |
variant | HeaderFooterVariant |
Other exports
| Export | Type | Description |
|---|---|---|
ARMED_MODE_KEYS | readonly ["formatPainter", "highlight"] | The modes that can be armed. ArmedModeKey is its element type. |
ArmedModeKey | "formatPainter" | "highlight" | |
UserPreferenceKey | "showOutline" | "showRuler" | "showComments" | "displayUnits" | "proofReadEnabled" | "zoomLevel" | "trackChanges" | "proofReadLoading" | "proofReadApiFailed" |