Function: provideOutput()
provideOutput<
Output
>(output
,cleanup
?):RegisterCleanup
<Output
>
Provide output from the register function of an Extension
Type Parameters
• Output
Parameters
• output: Output
• cleanup?
Returns
RegisterCleanup
<Output
>
A cleanup function
Examples
// This is entirely optional and would be inferred correctly, but
// it can be useful for documentation!
export interface RegisteredAtOutput {
registered_at: number;
}
export const RegisteredAtExtension = defineExtension({
name: "RegisteredAt",
register(editor) {
return provideOutput<RegisteredAtOutput>({ registered_at: Date.now() });
},
});
export interface UniqueCommandOutput {
command: LexicalCommand<unknown>;
}
export const UniqueCommandExtension = defineExtension({
name: 'UniqueCommand',
register(editor) {
const output: UniqueCommnadOutput = {command: createCommand('UNIQUE_COMMAND')};
const cleanup = registerCommand(
command,
(_payload) => {
console.log('Unique command received!');
return true;
}
COMMAND_PRIORITY_EDITOR
);
return provideOutput(output, cleanup);
},
});
Defined in
lexical-builder-core/dist/defineExtension.d.ts:103