REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 1.88 KB
Close
/home/byroehnu/.trash/node_modules11/@tiptap/core/src/inputRules/nodeInputRule.ts
Text
Base64
import { NodeType } from '@tiptap/pm/model' import { InputRule, InputRuleFinder } from '../InputRule.js' import { ExtendedRegExpMatchArray } from '../types.js' import { callOrReturn } from '../utilities/callOrReturn.js' /** * Build an input rule that adds a node when the * matched text is typed into it. * @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules */ export function nodeInputRule(config: { /** * The regex to match. */ find: InputRuleFinder /** * The node type to add. */ type: NodeType /** * A function that returns the attributes for the node * can also be an object of attributes */ getAttributes?: | Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null }) { return new InputRule({ find: config.find, handler: ({ state, range, match }) => { const attributes = callOrReturn(config.getAttributes, undefined, match) || {} const { tr } = state const start = range.from let end = range.to const newNode = config.type.create(attributes) if (match[1]) { const offset = match[0].lastIndexOf(match[1]) let matchStart = start + offset if (matchStart > end) { matchStart = end } else { end = matchStart + match[1].length } // insert last typed character const lastChar = match[0][match[0].length - 1] tr.insertText(lastChar, start + match[0].length - 1) // insert node from input rule tr.replaceWith(matchStart, end, newNode) } else if (match[0]) { const insertionStart = config.type.isInline ? start : start - 1 tr.insert(insertionStart, config.type.create(attributes)).delete( tr.mapping.map(start), tr.mapping.map(end), ) } tr.scrollIntoView() }, }) }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 6
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
index.ts
188 B
lrw-r--r--
2026-02-28 11:47:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
markInputRule.ts
2.05 KB
lrw-r--r--
2026-02-28 11:47:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
nodeInputRule.ts
1.88 KB
lrw-r--r--
2026-02-28 11:48:00
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
textblockTypeInputRule.ts
1.27 KB
lrw-r--r--
2026-02-28 11:48:02
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
textInputRule.ts
915 B
lrw-r--r--
2026-02-28 11:48:02
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
wrappingInputRule.ts
2.95 KB
lrw-r--r--
2026-02-28 11:48:06
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).