@overlap/rte 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -880,9 +880,11 @@ function domToContent(element) {
880
880
  if (tagName === "input" && el.getAttribute("type") === "checkbox") {
881
881
  return null;
882
882
  }
883
- // Handle <br> as empty text
884
883
  if (tagName === "br") {
885
- return null;
884
+ return { type: "br" };
885
+ }
886
+ if (tagName === "hr") {
887
+ return { type: "hr" };
886
888
  }
887
889
  if (tagName === "img") {
888
890
  const attributes = {};
@@ -952,6 +954,7 @@ function domToContent(element) {
952
954
  "h5",
953
955
  "h6",
954
956
  "blockquote",
957
+ "pre",
955
958
  "ul",
956
959
  "ol",
957
960
  "li",
@@ -1694,8 +1697,25 @@ function handleMarkdownShortcut(editor, e) {
1694
1697
  /** Remove the trigger characters from the text node before applying formatting. */
1695
1698
  function clearBlockText(textNode, charCount) {
1696
1699
  const text = textNode.textContent || "";
1697
- textNode.textContent = text.substring(charCount);
1698
- // Reset cursor to start
1700
+ const remaining = text.substring(charCount);
1701
+ textNode.textContent = remaining;
1702
+ if (remaining === "") {
1703
+ const parent = textNode.parentElement;
1704
+ if (parent) {
1705
+ parent.removeChild(textNode);
1706
+ const br = document.createElement("br");
1707
+ parent.appendChild(br);
1708
+ const selection = window.getSelection();
1709
+ if (selection) {
1710
+ const range = document.createRange();
1711
+ range.setStart(parent, 0);
1712
+ range.collapse(true);
1713
+ selection.removeAllRanges();
1714
+ selection.addRange(range);
1715
+ }
1716
+ return;
1717
+ }
1718
+ }
1699
1719
  const selection = window.getSelection();
1700
1720
  if (selection) {
1701
1721
  const range = document.createRange();
@@ -5152,10 +5172,18 @@ const Editor = ({ initialContent, onChange, plugins: providedPlugins, placeholde
5152
5172
  {
5153
5173
  "--rte-button-hover-bg": theme.buttonHoverBg,
5154
5174
  }),
5175
+ ...(theme.buttonActiveBg &&
5176
+ {
5177
+ "--rte-button-active-bg": theme.buttonActiveBg,
5178
+ }),
5155
5179
  ...(theme.contentBg &&
5156
5180
  {
5157
5181
  "--rte-content-bg": theme.contentBg,
5158
5182
  }),
5183
+ ...(theme.textColor &&
5184
+ {
5185
+ "--rte-text-color": theme.textColor,
5186
+ }),
5159
5187
  ...(theme.primaryColor &&
5160
5188
  {
5161
5189
  "--rte-primary-color": theme.primaryColor,