Skip to content

Commit

Permalink
markdown auto import fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ibastawisi committed Jun 16, 2024
1 parent cd0ea2a commit 11c5b55
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function runTextMatchTransformers(

const startIndex = match.index || 0;
const endIndex = startIndex + match[0].length;
if (!match.slice(1).map(Boolean).includes(true)) continue;
let replaceNode;

if (startIndex === 0) {
Expand Down Expand Up @@ -84,6 +85,7 @@ function $runTextFormatTransformers(
const matches = textContent.matchAll(regex);
for (const match of matches) {
const startIndex = match.index || 0;
if (textContent[startIndex - 1] === matcher.tag[0]) continue;
const endIndex = startIndex + match[0].length;
let targetNode;
if (startIndex === 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/editor/plugins/MarkdownPlugin/MarkdownTransformers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,9 @@ export const LINK: TextMatchTransformer = {
export const HR: ElementTransformer = {
dependencies: [HorizontalRuleNode],
export: (node: LexicalNode) => {
return $isHorizontalRuleNode(node) ? '***' : null;
return $isHorizontalRuleNode(node) ? '---' : null;
},
regExp: /^(---|\*\*\*|___)\s?/,
regExp: /^(---)\s?/,
replace: (parentNode, _1, _2, isImport) => {
const line = $createHorizontalRuleNode();

Expand Down
4 changes: 2 additions & 2 deletions src/editor/plugins/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
import { ListPlugin } from "./ListPlugin";
import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
import { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin';
import MarkdownPlugin from "./MarkdownPlugin/MarkdownShortcutPlugin";
import MarkdownShortcutPlugin from "./MarkdownPlugin/MarkdownShortcutPlugin";
import MarkdownAutoImportPlugin from "./MarkdownPlugin/MarkdownAutoImportPlugin";
import ListMaxIndentLevelPlugin from "./ListPlugin/ListMaxIndentLevelPlugin";
import CodeHighlightPlugin from "./CodePlugin/CodeHighlightPlugin";
Expand Down Expand Up @@ -64,7 +64,7 @@ export const EditorPlugins: React.FC<{
<TabFocusPlugin />
<TabIndentationPlugin />
<ListMaxIndentLevelPlugin maxDepth={7} />
<MarkdownPlugin />
<MarkdownShortcutPlugin />
<MarkdownAutoImportPlugin />
<FloatingToolbarPlugin />
<HorizontalRulePlugin />
Expand Down

0 comments on commit 11c5b55

Please sign in to comment.