import { EditorView } from 'wordgard/view'; import { Extension } from 'wordgard/state'; import { Pos, Plot } from 'wordgard/doc'; declare const inputRule: any; declare const beforeUpdate: any; declare class InputRule { readonly expr: RegExp; readonly apply: (view: EditorView, match: DocMatchArray) => boolean; extension: Extension; lookahead: RegExp | undefined; inCode: boolean; private constructor(); static define(spec: InputRule.Spec): InputRule; /** Build an input rule for automatically wrapping a textblock when a given string is typed. The `expr` argument is directly passed through to the `InputRule` constructor. You'll probably want the regexp to start with `^`, so that the pattern can only occur at the start of a textblock. `tag` gives the type of plot to wrap in. */ static wrapping(expr: RegExp, tag: Plot.Tag.Any | ((match: DocMatchArray) => Plot.Tag.Any)): InputRule; /** Build an input rule that changes the type of a textblock when the matched text is typed into it. You'll usually want to start your regexp with `^` so that it is only matched at the start of a textblock. The optional `getAttrs` parameter can be used to compute the new node's attributes, and works the same as in the `wrappingInputRule` function. */ static textblockType(expr: RegExp, tag: Plot.Tag.Any | ((match: DocMatchArray) => Plot.Tag.Any)): InputRule; } declare namespace InputRule { interface Spec { /** The regular expression to match against the text before the input. This expression should end in a `$` marker. */ expr: RegExp; /** Handler to call when this rule matches. `match` will contain the document positions of the full match and all matched groups in `expr`. Should return `true` when it has taken an action, `false` when it didn't. You probably want to include `isolateHistory.of("full")` in any transactions you dispatch from a rule handler, so that users can undo the adjustment if it wasn't what they wanted. When given as a string, the full match will be replaced by that string. */ apply: ((view: EditorView, match: DocMatchArray) => boolean) | string; /** Because the regular expression given in `expr` must end at the cursor, it is matched against a string that stops at the cursor, and cannot look beyond it. You can provide an additional expression here (which should start with `^`) to enforce a lookahead condition. */ lookahead?: RegExp; /** By default, input rules don't apply inside nodes with the [`Code` role](#doc.Node.Role^Code). Set this to `true` to allow matches in code. */ inCode?: boolean; } } type DocMatch = { from: Pos; to: Pos; text: string; }; type DocMatchArray = readonly (DocMatch | null)[] & { 0: DocMatch; }; /** Converts double dashes to an emdash. */ declare const emDash: InputRule; /** Converts three dots to an ellipsis character. */ declare const ellipsis: InputRule; /** “Smart” opening double quotes. */ declare const openDoubleQuote: InputRule; /** “Smart” closing double quotes. */ declare const closeDoubleQuote: InputRule; /** ‘Smart’ opening single quotes. */ declare const openSingleQuote: InputRule; /** ‘Smart’ closing single quotes. */ declare const closeSingleQuote: InputRule; /** Smart-quote related input rules. */ declare const smartQuotes: readonly InputRule[]; export { InputRule, beforeUpdate, closeDoubleQuote, closeSingleQuote, ellipsis, emDash, inputRule, openDoubleQuote, openSingleQuote, smartQuotes }; export type { DocMatch, DocMatchArray };