@overlap/rte 1.0.4 → 1.0.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../src/components/Editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAYjF,OAAO,EAA4B,WAAW,EAAE,MAAM,UAAU,CAAC;AA4BjE,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAktBxC,CAAC"}
1
+ {"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../src/components/Editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAYjF,OAAO,EAA4B,WAAW,EAAE,MAAM,UAAU,CAAC;AA4BjE,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA0tBxC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -201,7 +201,9 @@ interface EditorProps {
201
201
  borderRadius?: number;
202
202
  toolbarBg?: string;
203
203
  buttonHoverBg?: string;
204
+ buttonActiveBg?: string;
204
205
  contentBg?: string;
206
+ textColor?: string;
205
207
  primaryColor?: string;
206
208
  };
207
209
  onImageUpload?: (file: File) => Promise<string>;
package/dist/index.esm.js CHANGED
@@ -876,9 +876,8 @@ function domToContent(element) {
876
876
  if (tagName === "input" && el.getAttribute("type") === "checkbox") {
877
877
  return null;
878
878
  }
879
- // Handle <br> as empty text
880
879
  if (tagName === "br") {
881
- return null;
880
+ return { type: "br" };
882
881
  }
883
882
  if (tagName === "img") {
884
883
  const attributes = {};
@@ -1690,8 +1689,25 @@ function handleMarkdownShortcut(editor, e) {
1690
1689
  /** Remove the trigger characters from the text node before applying formatting. */
1691
1690
  function clearBlockText(textNode, charCount) {
1692
1691
  const text = textNode.textContent || "";
1693
- textNode.textContent = text.substring(charCount);
1694
- // Reset cursor to start
1692
+ const remaining = text.substring(charCount);
1693
+ textNode.textContent = remaining;
1694
+ if (remaining === "") {
1695
+ const parent = textNode.parentElement;
1696
+ if (parent) {
1697
+ parent.removeChild(textNode);
1698
+ const br = document.createElement("br");
1699
+ parent.appendChild(br);
1700
+ const selection = window.getSelection();
1701
+ if (selection) {
1702
+ const range = document.createRange();
1703
+ range.setStart(parent, 0);
1704
+ range.collapse(true);
1705
+ selection.removeAllRanges();
1706
+ selection.addRange(range);
1707
+ }
1708
+ return;
1709
+ }
1710
+ }
1695
1711
  const selection = window.getSelection();
1696
1712
  if (selection) {
1697
1713
  const range = document.createRange();
@@ -5148,10 +5164,18 @@ const Editor = ({ initialContent, onChange, plugins: providedPlugins, placeholde
5148
5164
  {
5149
5165
  "--rte-button-hover-bg": theme.buttonHoverBg,
5150
5166
  }),
5167
+ ...(theme.buttonActiveBg &&
5168
+ {
5169
+ "--rte-button-active-bg": theme.buttonActiveBg,
5170
+ }),
5151
5171
  ...(theme.contentBg &&
5152
5172
  {
5153
5173
  "--rte-content-bg": theme.contentBg,
5154
5174
  }),
5175
+ ...(theme.textColor &&
5176
+ {
5177
+ "--rte-text-color": theme.textColor,
5178
+ }),
5155
5179
  ...(theme.primaryColor &&
5156
5180
  {
5157
5181
  "--rte-primary-color": theme.primaryColor,