You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// plate/packages/autoformat/src/lib/withAutoformat.tseditor.insertText=(text)=>{if(!isCollapsed(editor.selection))returninsertText(text);if(getCodeLineEntry(editor))returninsertText(text);// I'm not sure if adding this processing here is too muchfor(construleofgetOptions().rules!){const{ insertTrigger, mode ='text', query }=rule;if(query&&!query(editorasany,{ ...rule, text }))continue;constautoformatter: Record<typeofmode,any>={block: autoformatBlock,mark: autoformatMark,text: autoformatText,};if(autoformatter[mode]?.(editor,{
...(ruleasany),
text,})){returninsertTrigger&&insertText(text);}}insertText(text);};
Almost every rule needs such a query (which means disabling autoformat when selection is within a code block). Although it is a little bit awkward to add the query to each rule, there is no better way to do so for now.
To further reuse codes, it may relate to a larger topic:
Some of the "container" elements (blocks) creates a brand new "context", for example, code block disallows autoformat and may other marks; columns, tables should support drag and drop...
Is it necessary to provide such a mechanism that decouples certain "context" and plugin configurations? I am not quite sure.
Description
Autoformat should not take effect within code blocks
Reproduction URL
No response
Reproduction steps
Plate version
39.2.15
Slate React version
0.110.3
Screenshots
No response
Logs
No response
Browsers
No response
The text was updated successfully, but these errors were encountered: