|
|
import { |
|
|
Ancestor, |
|
|
Editor, |
|
|
Node, |
|
|
Operation, |
|
|
Point, |
|
|
Range, |
|
|
RangeRef, |
|
|
Text, |
|
|
} from 'slate' |
|
|
import { TextDiff } from './diff-text' |
|
|
import { Key } from './key' |
|
|
|
|
|
export type Action = { at?: Point | Range; run: () => void } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const IS_NODE_MAP_DIRTY: WeakMap<Editor, boolean> = new WeakMap() |
|
|
export const NODE_TO_INDEX: WeakMap<Node, number> = new WeakMap() |
|
|
export const NODE_TO_PARENT: WeakMap<Node, Ancestor> = new WeakMap() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const EDITOR_TO_WINDOW: WeakMap<Editor, Window> = new WeakMap() |
|
|
export const EDITOR_TO_ELEMENT: WeakMap<Editor, HTMLElement> = new WeakMap() |
|
|
export const EDITOR_TO_PLACEHOLDER: WeakMap<Editor, string> = new WeakMap() |
|
|
export const EDITOR_TO_PLACEHOLDER_ELEMENT: WeakMap<Editor, HTMLElement> = |
|
|
new WeakMap() |
|
|
export const ELEMENT_TO_NODE: WeakMap<HTMLElement, Node> = new WeakMap() |
|
|
export const NODE_TO_ELEMENT: WeakMap<Node, HTMLElement> = new WeakMap() |
|
|
export const NODE_TO_KEY: WeakMap<Node, Key> = new WeakMap() |
|
|
export const EDITOR_TO_KEY_TO_ELEMENT: WeakMap< |
|
|
Editor, |
|
|
WeakMap<Key, HTMLElement> |
|
|
> = new WeakMap() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const IS_READ_ONLY: WeakMap<Editor, boolean> = new WeakMap() |
|
|
export const IS_FOCUSED: WeakMap<Editor, boolean> = new WeakMap() |
|
|
export const IS_COMPOSING: WeakMap<Editor, boolean> = new WeakMap() |
|
|
|
|
|
export const EDITOR_TO_USER_SELECTION: WeakMap<Editor, RangeRef | null> = |
|
|
new WeakMap() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const EDITOR_TO_ON_CHANGE = new WeakMap< |
|
|
Editor, |
|
|
(options?: { operation?: Operation }) => void |
|
|
>() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const EDITOR_TO_SCHEDULE_FLUSH: WeakMap<Editor, () => void> = |
|
|
new WeakMap() |
|
|
|
|
|
export const EDITOR_TO_PENDING_INSERTION_MARKS: WeakMap< |
|
|
Editor, |
|
|
Partial<Text> | null |
|
|
> = new WeakMap() |
|
|
|
|
|
export const EDITOR_TO_USER_MARKS: WeakMap<Editor, Partial<Text> | null> = |
|
|
new WeakMap() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const EDITOR_TO_PENDING_DIFFS: WeakMap<Editor, TextDiff[]> = |
|
|
new WeakMap() |
|
|
|
|
|
export const EDITOR_TO_PENDING_ACTION: WeakMap<Editor, Action | null> = |
|
|
new WeakMap() |
|
|
|
|
|
export const EDITOR_TO_PENDING_SELECTION: WeakMap<Editor, Range | null> = |
|
|
new WeakMap() |
|
|
|
|
|
export const EDITOR_TO_FORCE_RENDER: WeakMap<Editor, () => void> = new WeakMap() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const PLACEHOLDER_SYMBOL = Symbol('placeholder') as unknown as string |
|
|
export const MARK_PLACEHOLDER_SYMBOL = Symbol( |
|
|
'mark-placeholder' |
|
|
) as unknown as string |
|
|
|