@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.
@@ -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,11 @@ 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" };
881
+ }
882
+ if (tagName === "hr") {
883
+ return { type: "hr" };
882
884
  }
883
885
  if (tagName === "img") {
884
886
  const attributes = {};
@@ -948,6 +950,7 @@ function domToContent(element) {
948
950
  "h5",
949
951
  "h6",
950
952
  "blockquote",
953
+ "pre",
951
954
  "ul",
952
955
  "ol",
953
956
  "li",
@@ -1690,8 +1693,25 @@ function handleMarkdownShortcut(editor, e) {
1690
1693
  /** Remove the trigger characters from the text node before applying formatting. */
1691
1694
  function clearBlockText(textNode, charCount) {
1692
1695
  const text = textNode.textContent || "";
1693
- textNode.textContent = text.substring(charCount);
1694
- // Reset cursor to start
1696
+ const remaining = text.substring(charCount);
1697
+ textNode.textContent = remaining;
1698
+ if (remaining === "") {
1699
+ const parent = textNode.parentElement;
1700
+ if (parent) {
1701
+ parent.removeChild(textNode);
1702
+ const br = document.createElement("br");
1703
+ parent.appendChild(br);
1704
+ const selection = window.getSelection();
1705
+ if (selection) {
1706
+ const range = document.createRange();
1707
+ range.setStart(parent, 0);
1708
+ range.collapse(true);
1709
+ selection.removeAllRanges();
1710
+ selection.addRange(range);
1711
+ }
1712
+ return;
1713
+ }
1714
+ }
1695
1715
  const selection = window.getSelection();
1696
1716
  if (selection) {
1697
1717
  const range = document.createRange();
@@ -5148,10 +5168,18 @@ const Editor = ({ initialContent, onChange, plugins: providedPlugins, placeholde
5148
5168
  {
5149
5169
  "--rte-button-hover-bg": theme.buttonHoverBg,
5150
5170
  }),
5171
+ ...(theme.buttonActiveBg &&
5172
+ {
5173
+ "--rte-button-active-bg": theme.buttonActiveBg,
5174
+ }),
5151
5175
  ...(theme.contentBg &&
5152
5176
  {
5153
5177
  "--rte-content-bg": theme.contentBg,
5154
5178
  }),
5179
+ ...(theme.textColor &&
5180
+ {
5181
+ "--rte-text-color": theme.textColor,
5182
+ }),
5155
5183
  ...(theme.primaryColor &&
5156
5184
  {
5157
5185
  "--rte-primary-color": theme.primaryColor,