REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 2.05 KB
Close
/home/byroehnu/.trash/node_modules11/@tiptap/core/src/inputRules/markInputRule.ts
Text
Base64
import { MarkType } from '@tiptap/pm/model' import { getMarksBetween } from '../helpers/getMarksBetween.js' import { InputRule, InputRuleFinder } from '../InputRule.js' import { ExtendedRegExpMatchArray } from '../types.js' import { callOrReturn } from '../utilities/callOrReturn.js' /** * Build an input rule that adds a mark when the * matched text is typed into it. * @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules */ export function markInputRule(config: { find: InputRuleFinder type: MarkType 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) if (attributes === false || attributes === null) { return null } const { tr } = state const captureGroup = match[match.length - 1] const fullMatch = match[0] if (captureGroup) { const startSpaces = fullMatch.search(/\S/) const textStart = range.from + fullMatch.indexOf(captureGroup) const textEnd = textStart + captureGroup.length const excludedMarks = getMarksBetween(range.from, range.to, state.doc) .filter(item => { // @ts-ignore const excluded = item.mark.type.excluded as MarkType[] return excluded.find(type => type === config.type && type !== item.mark.type) }) .filter(item => item.to > textStart) if (excludedMarks.length) { return null } if (textEnd < range.to) { tr.delete(textEnd, range.to) } if (textStart > range.from) { tr.delete(range.from + startSpaces, textStart) } const markEnd = range.from + startSpaces + captureGroup.length tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {})) tr.removeStoredMark(config.type) } }, }) }
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).