Skip to content

Commit

Permalink
fix: restore makrs
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhhashemi committed Jan 31, 2024
1 parent 57d45d8 commit 1e0e025
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/yellow-seals-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tiptap-text-direction": patch
---

Restore marks in new line
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ function TextDirectionPlugin({ types }: { types: string[] }) {
if (node.attrs.dir !== null && node.textContent.length > 0) {
return;
}
const marks = tr.storedMarks || [];
tr.setNodeAttribute(pos, "dir", getTextDirection(node.textContent));
// `tr.setNodeAttribute` resets the stored marks so we'll restore them
for (const mark of marks) {
tr.addStoredMark(mark);
}
modified = true;
}
});
Expand Down

0 comments on commit 1e0e025

Please sign in to comment.