import type { Value } from '../../../facade';
import type { Editor } from '../../editor';
import type { AnyBasePlugin, PluginReference } from '../../plugin';
import type {
InputRule,
InsertBreakInputRule,
InsertBreakInputRuleContext,
InsertBreakInputRuleReadContext,
InsertDataInputRule,
InsertDataInputRuleContext,
InsertDataInputRuleReadContext,
InsertTextInputRule,
InsertTextInputRuleContext,
InsertTextInputRuleReadContext,
} from './types';
type InputRuleOwner = AnyBasePlugin & PluginReference;
type OwnerEditor
= Editor;
type BoundResolvedInsertBreakRule = Omit<
InsertBreakInputRule>,
'apply' | 'resolve'
> & {
apply: (
context: InsertBreakInputRuleContext>,
match: NoInfer
) => ReturnType>['apply']>;
resolve: (
context: InsertBreakInputRuleReadContext>
) => TMatch | undefined;
};
type BoundResolvedInsertDataRule = Omit<
InsertDataInputRule>,
'apply' | 'resolve'
> & {
apply: (
context: InsertDataInputRuleContext>,
match: NoInfer
) => ReturnType>['apply']>;
resolve: (
context: InsertDataInputRuleReadContext>
) => TMatch | undefined;
};
type BoundResolvedInsertTextRule = Omit<
InsertTextInputRule>,
'apply' | 'resolve'
> & {
apply: (
context: InsertTextInputRuleContext>,
match: NoInfer
) => ReturnType>['apply']>;
resolve: (
context: InsertTextInputRuleReadContext>
) => TMatch | undefined;
};
export function defineInputRule(
rule: InsertBreakInputRule
): InsertBreakInputRule;
export function defineInputRule(
rule: InsertDataInputRule
): InsertDataInputRule;
export function defineInputRule(
rule: InsertTextInputRule
): InsertTextInputRule;
export function defineInputRule(rule: TRule): TRule;
export function defineInputRule(
owner: P,
rule: BoundResolvedInsertBreakRule
): InsertBreakInputRule>;
export function defineInputRule(
owner: P,
rule: BoundResolvedInsertDataRule
): InsertDataInputRule>;
export function defineInputRule(
owner: P,
rule: BoundResolvedInsertTextRule
): InsertTextInputRule>;
export function defineInputRule(
owner: P,
rule: InsertBreakInputRule>
): InsertBreakInputRule>;
export function defineInputRule(
owner: P,
rule: InsertDataInputRule>
): InsertDataInputRule>;
export function defineInputRule(
owner: P,
rule: InsertTextInputRule>
): InsertTextInputRule>;
export function defineInputRule(
ownerOrRule: InputRuleOwner | TRule,
rule?: TRule
) {
return rule ?? ownerOrRule;
}