Skip to content

Commit e600920

Browse files
formatting
1 parent 8dda41a commit e600920

3 files changed

Lines changed: 29 additions & 28 deletions

File tree

src/components/editor/extensions/hashtag-extension.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

src/components/editor/plugins/initial-content-plugin.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ export default function InitialContentPlugin({
3131
hasInitialized.current = true;
3232

3333
const mode = isNew ? "new" : !markdown.trim() ? "empty" : "existing";
34-
console.log(
35-
`[editor:init] mode=${mode} markdown=${markdown.length} chars`,
36-
);
34+
console.log(`[editor:init] mode=${mode} markdown=${markdown.length} chars`);
3735

3836
editor.update(() => {
3937
if (isNew) {
@@ -55,9 +53,7 @@ export default function InitialContentPlugin({
5553
}
5654

5755
const root = $getRoot();
58-
console.log(
59-
`[editor:init] imported ${root.getChildrenSize()} nodes`,
60-
);
56+
console.log(`[editor:init] imported ${root.getChildrenSize()} nodes`);
6157
});
6258

6359
onInitComplete();

src/components/editor/plugins/on-change-markdown-plugin.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,19 @@ export default function OnChangeMarkdownPlugin({
5858
);
5959

6060
if (!initCompleteRef.current) {
61-
console.log(
62-
"[editor:update] pre-init update, skipping onChange",
63-
);
61+
console.log("[editor:update] pre-init update, skipping onChange");
6462
return;
6563
}
6664

6765
const markdown = $exportMarkdown(TRANSFORMERS);
6866

69-
if (prevMarkdownRef.current !== null && prevMarkdownRef.current === markdown) {
70-
console.log("[editor:update] markdown unchanged, skipping onChange");
67+
if (
68+
prevMarkdownRef.current !== null &&
69+
prevMarkdownRef.current === markdown
70+
) {
71+
console.log(
72+
"[editor:update] markdown unchanged, skipping onChange",
73+
);
7174
return;
7275
}
7376

0 commit comments

Comments
 (0)