@@ -137,8 +137,7 @@ function getHashtagRegexStringChars() {
137137 "\u1040-\u1049\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9" +
138138 "\uFF10-\uFF19" ;
139139
140- const alpha =
141- unicodeLetters + latinAccents + nonLatinChars + cjkChars ;
140+ const alpha = unicodeLetters + latinAccents + nonLatinChars + cjkChars ;
142141 const numeric = unicodeDigits + "_" ;
143142 const alphanumeric = alpha + unicodeAccents + numeric ;
144143 const hashChars = "#\\uFF03" ;
@@ -211,19 +210,18 @@ function registerHashtag(editor: LexicalEditor) {
211210 ) ;
212211
213212 // Revert any HashtagNode that ends up inside a code context
214- const removeCodeGuard = editor . registerNodeTransform (
215- HashtagNode ,
216- ( node ) => {
217- if ( $isInsideCode ( node ) ) {
218- const text = node . getTextContent ( ) ;
219- const reason = $isCodeNode ( node . getParent ( ) ! ) ? "code-block" : "inline-code" ;
220- console . log ( `[editor:hashtag] reverted "${ text } " (inside ${ reason } )` ) ;
221- const textNode = $createTextNode ( text ) ;
222- textNode . setFormat ( node . getFormat ( ) ) ;
223- node . replace ( textNode ) ;
224- }
225- } ,
226- ) ;
213+ const removeCodeGuard = editor . registerNodeTransform ( HashtagNode , ( node ) => {
214+ if ( $isInsideCode ( node ) ) {
215+ const text = node . getTextContent ( ) ;
216+ const reason = $isCodeNode ( node . getParent ( ) ! )
217+ ? "code-block"
218+ : "inline-code" ;
219+ console . log ( `[editor:hashtag] reverted "${ text } " (inside ${ reason } )` ) ;
220+ const textNode = $createTextNode ( text ) ;
221+ textNode . setFormat ( node . getFormat ( ) ) ;
222+ node . replace ( textNode ) ;
223+ }
224+ } ) ;
227225
228226 // Prevent the forward transform from creating hashtags in code contexts
229227 const removeTextGuard = editor . registerNodeTransform ( TextNode , ( node ) => {
@@ -233,13 +231,17 @@ function registerHashtag(editor: LexicalEditor) {
233231 const prev = node . getPreviousSibling ( ) ;
234232 const next = node . getNextSibling ( ) ;
235233 if ( prev instanceof HashtagNode ) {
236- console . log ( `[editor:hashtag] cleaned sibling "${ prev . getTextContent ( ) } " (prev, in code)` ) ;
234+ console . log (
235+ `[editor:hashtag] cleaned sibling "${ prev . getTextContent ( ) } " (prev, in code)` ,
236+ ) ;
237237 const textNode = $createTextNode ( prev . getTextContent ( ) ) ;
238238 textNode . setFormat ( prev . getFormat ( ) ) ;
239239 prev . replace ( textNode ) ;
240240 }
241241 if ( next instanceof HashtagNode ) {
242- console . log ( `[editor:hashtag] cleaned sibling "${ next . getTextContent ( ) } " (next, in code)` ) ;
242+ console . log (
243+ `[editor:hashtag] cleaned sibling "${ next . getTextContent ( ) } " (next, in code)` ,
244+ ) ;
243245 const textNode = $createTextNode ( next . getTextContent ( ) ) ;
244246 textNode . setFormat ( next . getFormat ( ) ) ;
245247 next . replace ( textNode ) ;
0 commit comments