[{"data":1,"prerenderedAt":524},["ShallowReactive",2],{"msfe-doc:\u002Fen\u002Fextensions\u002Finput-rules":3,"msfe-source:recipes\u002Frules.ts":132,"mdc-5319rn-key":133},{"id":4,"title":5,"body":6,"description":116,"extension":117,"keywords":118,"locale":123,"meta":124,"navigation":125,"order":126,"path":127,"section":128,"seo":129,"stem":130,"__hash__":131},"docs\u002Fextensions\u002Finput-rules.en.md","Input and paste rules",{"type":7,"value":8,"toc":108},"minimark",[9,14,31,40,44,48,62,65,69,85,88,92,95],[10,11,13],"h2",{"id":12},"when-rules-are-appropriate","When rules are appropriate",[15,16,17,18,22,23,26,27,30],"p",{},"Parser plugins interpret source. Input rules mutate newly typed text, such as replacing ",[19,20,21],"code",{},"::ok "," with ",[19,24,25],{},"[[done]] ",". Paste rules can translate a legacy ",[19,28,29],{},"[STATUS:DONE]"," token. Applications should enable such normalization explicitly and retain undo.",[15,32,33,34,39],{},"Install this complete module alongside the ",[35,36,38],"a",{"href":37},"\u002Fen\u002Fextensions\u002Fcustom-node","status node",". Without that node, the replacement remains ordinary source.",[41,42],"msfe-recipe",{"name":43},"recipes\u002Frules",[10,45,47],{"id":46},"handler-coordinates-and-output","Handler coordinates and output",[15,49,50,53,54,57,58,61],{},[19,51,52],{},"find"," is a regular expression. ",[19,55,56],{},"handler({ match, range, document })"," receives a match and UTF-16 range after native input entered the text. Return exact replacement text or ",[19,59,60],{},"null"," to preserve input. Do not dispatch commands, perform I\u002FO or mutate DOM inside the handler.",[15,63,64],{},"Use bounded document context when required. The example intentionally performs a global literal transformation, including matching text in code. A prose-only rule needs accurate syntax context and a policy for unconfirmed parsing; a regex alone is not Markdown semantic recognition.",[10,66,68],{"id":67},"current-work-limits","Current work limits",[70,71,72,76,79,82],"ul",{},[73,74,75],"li",{},"Input rules inspect at most 512 logical units at the current line suffix. Matches must end at the input position; the first applicable rule wins.",[73,77,78],{},"Paste rules scan only newly inserted text. Individual inserted spans over 65,536 units remain unchanged.",[73,80,81],{},"Overlapping paste matches are not applied twice, and edits are sorted by source position.",[73,83,84],{},"Multiple selections, readonly and native composition bypass normal rule transformation. Programmatic commands are not keyboard-input triggers.",[15,86,87],{},"These are current bounded-work policies. Large imports need a separate reviewable import command, not assumptions about automatic normalization.",[10,89,91],{"id":90},"verify-scope-and-undo","Verify scope and undo",[15,93,94],{},"Assert exact transformed source and one-step undo. Cover no match, empty matches, competing rules, multiple clipboard matches, identical text already in the document, oversized clipboard data, composition and readonly. Returning the original matched string does not add a redundant edit.",[15,96,97,98,102,103,107],{},"See ",[35,99,101],{"href":100},"\u002Fen\u002Fapi\u002Fextensions","Extension API",". For display-only behavior use ",[35,104,106],{"href":105},"\u002Fen\u002Fextensions\u002Fmarkdown-plugins","Markdown plugins"," rather than rewriting existing files.",{"title":109,"searchDepth":110,"depth":110,"links":111},"",2,[112,113,114,115],{"id":12,"depth":110,"text":13},{"id":46,"depth":110,"text":47},{"id":67,"depth":110,"text":68},{"id":90,"depth":110,"text":91},"Transform new input explicitly while preserving composition, bounded work and undo.","md",[119,120,121,122],"InputRule","PasteRule","IME","clipboard","en",{},true,5,"\u002Fen\u002Fextensions\u002Finput-rules","Extensions",{"title":5,"description":116},"extensions\u002Finput-rules.en","r-0Syx7NO959X870j48IYyivBBg18OKRiT8c6fynbnM","import { Extension, InputRule, PasteRule } from \"@quirekit\u002Fmsfe-core\";\n\u002F** Explicit opt-in text normalization, separate from syntax-only rendering plugins. *\u002F\nexport const SourceRules = Extension.create({ name: \"exampleRules\",\n  \u002F** @returns A suffix rule triggered by the final space after ::ok. *\u002F\n  addInputRules() { return [new InputRule({ find: \u002F::ok $\u002Fu,\n    \u002F** @returns Exact canonical replacement. *\u002F handler() { return \"[[done]] \"; },\n  })]; },\n  \u002F** @returns A clipboard-only legacy status migration. *\u002F\n  addPasteRules() { return [new PasteRule({ find: \u002F\\[STATUS:DONE\\]\u002Fu,\n    \u002F** @returns Exact canonical status syntax. *\u002F handler() { return \"[[done]]\"; },\n  })]; },\n});\n",{"data":134,"body":135},{},{"type":136,"children":137},"root",[138,518],{"type":139,"tag":140,"props":141,"children":145},"element","pre",{"className":142,"code":143,"language":144,"meta":109,"style":109},"language-ts shiki shiki-themes github-light github-light github-dark","import { Extension, InputRule, PasteRule } from \"@quirekit\u002Fmsfe-core\";\n\u002F** Explicit opt-in text normalization, separate from syntax-only rendering plugins. *\u002F\nexport const SourceRules = Extension.create({ name: \"exampleRules\",\n  \u002F** @returns A suffix rule triggered by the final space after ::ok. *\u002F\n  addInputRules() { return [new InputRule({ find: \u002F::ok $\u002Fu,\n    \u002F** @returns Exact canonical replacement. *\u002F handler() { return \"[[done]] \"; },\n  })]; },\n  \u002F** @returns A clipboard-only legacy status migration. *\u002F\n  addPasteRules() { return [new PasteRule({ find: \u002F\\[STATUS:DONE\\]\u002Fu,\n    \u002F** @returns Exact canonical status syntax. *\u002F handler() { return \"[[done]]\"; },\n  })]; },\n});\n\n","ts",[146],{"type":139,"tag":19,"props":147,"children":148},{"__ignoreMap":109},[149,184,193,244,263,330,371,380,397,463,501,509],{"type":139,"tag":150,"props":151,"children":154},"span",{"class":152,"line":153},"line",1,[155,162,168,173,179],{"type":139,"tag":150,"props":156,"children":158},{"style":157},"--shiki-default:#D73A49;--shiki-light:#D73A49;--shiki-dark:#F97583",[159],{"type":160,"value":161},"text","import",{"type":139,"tag":150,"props":163,"children":165},{"style":164},"--shiki-default:#24292E;--shiki-light:#24292E;--shiki-dark:#E1E4E8",[166],{"type":160,"value":167}," { Extension, InputRule, PasteRule } ",{"type":139,"tag":150,"props":169,"children":170},{"style":157},[171],{"type":160,"value":172},"from",{"type":139,"tag":150,"props":174,"children":176},{"style":175},"--shiki-default:#032F62;--shiki-light:#032F62;--shiki-dark:#9ECBFF",[177],{"type":160,"value":178}," \"@quirekit\u002Fmsfe-core\"",{"type":139,"tag":150,"props":180,"children":181},{"style":164},[182],{"type":160,"value":183},";\n",{"type":139,"tag":150,"props":185,"children":186},{"class":152,"line":110},[187],{"type":139,"tag":150,"props":188,"children":190},{"style":189},"--shiki-default:#6A737D;--shiki-light:#6A737D;--shiki-dark:#6A737D",[191],{"type":160,"value":192},"\u002F** Explicit opt-in text normalization, separate from syntax-only rendering plugins. *\u002F\n",{"type":139,"tag":150,"props":194,"children":196},{"class":152,"line":195},3,[197,202,207,213,218,223,229,234,239],{"type":139,"tag":150,"props":198,"children":199},{"style":157},[200],{"type":160,"value":201},"export",{"type":139,"tag":150,"props":203,"children":204},{"style":157},[205],{"type":160,"value":206}," const",{"type":139,"tag":150,"props":208,"children":210},{"style":209},"--shiki-default:#005CC5;--shiki-light:#005CC5;--shiki-dark:#79B8FF",[211],{"type":160,"value":212}," SourceRules",{"type":139,"tag":150,"props":214,"children":215},{"style":157},[216],{"type":160,"value":217}," =",{"type":139,"tag":150,"props":219,"children":220},{"style":164},[221],{"type":160,"value":222}," Extension.",{"type":139,"tag":150,"props":224,"children":226},{"style":225},"--shiki-default:#6F42C1;--shiki-light:#6F42C1;--shiki-dark:#B392F0",[227],{"type":160,"value":228},"create",{"type":139,"tag":150,"props":230,"children":231},{"style":164},[232],{"type":160,"value":233},"({ name: ",{"type":139,"tag":150,"props":235,"children":236},{"style":175},[237],{"type":160,"value":238},"\"exampleRules\"",{"type":139,"tag":150,"props":240,"children":241},{"style":164},[242],{"type":160,"value":243},",\n",{"type":139,"tag":150,"props":245,"children":247},{"class":152,"line":246},4,[248,253,258],{"type":139,"tag":150,"props":249,"children":250},{"style":189},[251],{"type":160,"value":252},"  \u002F** ",{"type":139,"tag":150,"props":254,"children":255},{"style":157},[256],{"type":160,"value":257},"@returns",{"type":139,"tag":150,"props":259,"children":260},{"style":189},[261],{"type":160,"value":262}," A suffix rule triggered by the final space after ::ok. *\u002F\n",{"type":139,"tag":150,"props":264,"children":265},{"class":152,"line":126},[266,271,276,281,286,291,296,301,306,311,316,321,326],{"type":139,"tag":150,"props":267,"children":268},{"style":225},[269],{"type":160,"value":270},"  addInputRules",{"type":139,"tag":150,"props":272,"children":273},{"style":164},[274],{"type":160,"value":275},"() { ",{"type":139,"tag":150,"props":277,"children":278},{"style":157},[279],{"type":160,"value":280},"return",{"type":139,"tag":150,"props":282,"children":283},{"style":164},[284],{"type":160,"value":285}," [",{"type":139,"tag":150,"props":287,"children":288},{"style":157},[289],{"type":160,"value":290},"new",{"type":139,"tag":150,"props":292,"children":293},{"style":225},[294],{"type":160,"value":295}," InputRule",{"type":139,"tag":150,"props":297,"children":298},{"style":164},[299],{"type":160,"value":300},"({ find:",{"type":139,"tag":150,"props":302,"children":303},{"style":175},[304],{"type":160,"value":305}," \u002F",{"type":139,"tag":150,"props":307,"children":309},{"style":308},"--shiki-default:#032F62;--shiki-light:#032F62;--shiki-dark:#DBEDFF",[310],{"type":160,"value":21},{"type":139,"tag":150,"props":312,"children":313},{"style":157},[314],{"type":160,"value":315},"$",{"type":139,"tag":150,"props":317,"children":318},{"style":175},[319],{"type":160,"value":320},"\u002F",{"type":139,"tag":150,"props":322,"children":323},{"style":157},[324],{"type":160,"value":325},"u",{"type":139,"tag":150,"props":327,"children":328},{"style":164},[329],{"type":160,"value":243},{"type":139,"tag":150,"props":331,"children":333},{"class":152,"line":332},6,[334,339,343,348,353,357,361,366],{"type":139,"tag":150,"props":335,"children":336},{"style":189},[337],{"type":160,"value":338},"    \u002F** ",{"type":139,"tag":150,"props":340,"children":341},{"style":157},[342],{"type":160,"value":257},{"type":139,"tag":150,"props":344,"children":345},{"style":189},[346],{"type":160,"value":347}," Exact canonical replacement. *\u002F",{"type":139,"tag":150,"props":349,"children":350},{"style":225},[351],{"type":160,"value":352}," handler",{"type":139,"tag":150,"props":354,"children":355},{"style":164},[356],{"type":160,"value":275},{"type":139,"tag":150,"props":358,"children":359},{"style":157},[360],{"type":160,"value":280},{"type":139,"tag":150,"props":362,"children":363},{"style":175},[364],{"type":160,"value":365}," \"[[done]] \"",{"type":139,"tag":150,"props":367,"children":368},{"style":164},[369],{"type":160,"value":370},"; },\n",{"type":139,"tag":150,"props":372,"children":374},{"class":152,"line":373},7,[375],{"type":139,"tag":150,"props":376,"children":377},{"style":164},[378],{"type":160,"value":379},"  })]; },\n",{"type":139,"tag":150,"props":381,"children":383},{"class":152,"line":382},8,[384,388,392],{"type":139,"tag":150,"props":385,"children":386},{"style":189},[387],{"type":160,"value":252},{"type":139,"tag":150,"props":389,"children":390},{"style":157},[391],{"type":160,"value":257},{"type":139,"tag":150,"props":393,"children":394},{"style":189},[395],{"type":160,"value":396}," A clipboard-only legacy status migration. *\u002F\n",{"type":139,"tag":150,"props":398,"children":400},{"class":152,"line":399},9,[401,406,410,414,418,422,427,431,435,441,446,451,455,459],{"type":139,"tag":150,"props":402,"children":403},{"style":225},[404],{"type":160,"value":405},"  addPasteRules",{"type":139,"tag":150,"props":407,"children":408},{"style":164},[409],{"type":160,"value":275},{"type":139,"tag":150,"props":411,"children":412},{"style":157},[413],{"type":160,"value":280},{"type":139,"tag":150,"props":415,"children":416},{"style":164},[417],{"type":160,"value":285},{"type":139,"tag":150,"props":419,"children":420},{"style":157},[421],{"type":160,"value":290},{"type":139,"tag":150,"props":423,"children":424},{"style":225},[425],{"type":160,"value":426}," PasteRule",{"type":139,"tag":150,"props":428,"children":429},{"style":164},[430],{"type":160,"value":300},{"type":139,"tag":150,"props":432,"children":433},{"style":175},[434],{"type":160,"value":305},{"type":139,"tag":150,"props":436,"children":438},{"style":437},"--shiki-default:#22863A;--shiki-default-font-weight:bold;--shiki-light:#22863A;--shiki-light-font-weight:bold;--shiki-dark:#85E89D;--shiki-dark-font-weight:bold",[439],{"type":160,"value":440},"\\[",{"type":139,"tag":150,"props":442,"children":443},{"style":308},[444],{"type":160,"value":445},"STATUS:DONE",{"type":139,"tag":150,"props":447,"children":448},{"style":437},[449],{"type":160,"value":450},"\\]",{"type":139,"tag":150,"props":452,"children":453},{"style":175},[454],{"type":160,"value":320},{"type":139,"tag":150,"props":456,"children":457},{"style":157},[458],{"type":160,"value":325},{"type":139,"tag":150,"props":460,"children":461},{"style":164},[462],{"type":160,"value":243},{"type":139,"tag":150,"props":464,"children":466},{"class":152,"line":465},10,[467,471,475,480,484,488,492,497],{"type":139,"tag":150,"props":468,"children":469},{"style":189},[470],{"type":160,"value":338},{"type":139,"tag":150,"props":472,"children":473},{"style":157},[474],{"type":160,"value":257},{"type":139,"tag":150,"props":476,"children":477},{"style":189},[478],{"type":160,"value":479}," Exact canonical status syntax. *\u002F",{"type":139,"tag":150,"props":481,"children":482},{"style":225},[483],{"type":160,"value":352},{"type":139,"tag":150,"props":485,"children":486},{"style":164},[487],{"type":160,"value":275},{"type":139,"tag":150,"props":489,"children":490},{"style":157},[491],{"type":160,"value":280},{"type":139,"tag":150,"props":493,"children":494},{"style":175},[495],{"type":160,"value":496}," \"[[done]]\"",{"type":139,"tag":150,"props":498,"children":499},{"style":164},[500],{"type":160,"value":370},{"type":139,"tag":150,"props":502,"children":504},{"class":152,"line":503},11,[505],{"type":139,"tag":150,"props":506,"children":507},{"style":164},[508],{"type":160,"value":379},{"type":139,"tag":150,"props":510,"children":512},{"class":152,"line":511},12,[513],{"type":139,"tag":150,"props":514,"children":515},{"style":164},[516],{"type":160,"value":517},"});\n",{"type":139,"tag":519,"props":520,"children":521},"style",{},[522],{"type":160,"value":523},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",1793046312603]