import { ApplySchemaAttributes , chainCommands , command , CommandFunction , convertCommand , extension , ExtensionPriority , ExtensionTag , KeyBindings , NodeExtension , NodeExtensionSpec , NodeSpecOverride , } from '@remirror/core' ; import { exitCode } from '@remirror/pm/commands' ; export interface HardBreakOptions { /**
     * The a collection of nodes where the hard break is not available.
     */ excludedNodes ? : string [ ] ; } remarks @ extension ( { defaultPriority : ExtensionPriority . Low , } ) export class HardBreakExtension extends NodeExtension { get name ( ) { return 'hardBreak' as const ; } createTags ( ) { return [ ExtensionTag . InlineNode ] ; } createNodeSpec ( extra , override ) { return { inline : true , selectable : false , atom : true , ... override , attrs : extra . defaults ( ) , parseDOM : [ { tag : 'br' , getAttrs : extra . parse } , ... ( override . parseDOM ?? [ ] ) ] , toDOM : ( node ) => [ 'br' , extra . dom ( node ) ] , } ; } createKeymap ( ) { const command = chainCommands ( convertCommand ( exitCode ) , ( ) => { this . store . commands . insertHardBreak ( ) ; return true ; } ) ; return { 'Mod-Enter' : command , 'Shift-Enter' : command , } ; } /**
     * Inserts a hardBreak `<br />` tag into the editor.
     */ @ command ( ) insertHardBreak ( ) { return ( props ) => { const { tr , dispatch } = props ; dispatch ?. ( tr . replaceSelectionWith ( this . type . create ( ) ) . scrollIntoView ( ) ) ; return true ; } ; } } declare global { namespace Remirror { interface AllExtensions { hardBreak : HardBreakExtension ; } } }