@overlap/rte 1.0.3 → 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.
package/dist/index.js CHANGED
@@ -272,6 +272,12 @@ function ensureAllCheckboxes(editor) {
272
272
  if (!ul.classList.contains("rte-checkbox-list")) {
273
273
  ul.classList.add("rte-checkbox-list");
274
274
  }
275
+ // Propagate checkbox class to nested ULs inside LI children
276
+ ul.querySelectorAll(":scope > li > ul").forEach((nestedUl) => {
277
+ if (!nestedUl.classList.contains("rte-checkbox-list")) {
278
+ nestedUl.classList.add("rte-checkbox-list");
279
+ }
280
+ });
275
281
  // Handle GitHub format: convert <input type="checkbox"> to aria-checked
276
282
  ul.querySelectorAll(":scope > li").forEach((li) => {
277
283
  const input = li.querySelector('input[type="checkbox"]');
@@ -874,9 +880,8 @@ function domToContent(element) {
874
880
  if (tagName === "input" && el.getAttribute("type") === "checkbox") {
875
881
  return null;
876
882
  }
877
- // Handle <br> as empty text
878
883
  if (tagName === "br") {
879
- return null;
884
+ return { type: "br" };
880
885
  }
881
886
  if (tagName === "img") {
882
887
  const attributes = {};
@@ -1426,8 +1431,10 @@ function indentListItem(selection) {
1426
1431
  // Create nested list in the previous item
1427
1432
  let nestedList = previousItem.querySelector('ul, ol');
1428
1433
  if (!nestedList) {
1429
- // Create new nested list
1430
1434
  nestedList = document.createElement(list.tagName.toLowerCase());
1435
+ if (list.classList.contains('rte-checkbox-list')) {
1436
+ nestedList.classList.add('rte-checkbox-list');
1437
+ }
1431
1438
  previousItem.appendChild(nestedList);
1432
1439
  }
1433
1440
  // Move current item into nested list
@@ -1455,6 +1462,9 @@ function indentListItem(selection) {
1455
1462
  else {
1456
1463
  // No previous item — create new nested list in current item
1457
1464
  const nestedList = document.createElement(list.tagName.toLowerCase());
1465
+ if (list.classList.contains('rte-checkbox-list')) {
1466
+ nestedList.classList.add('rte-checkbox-list');
1467
+ }
1458
1468
  // Move all following items into the nested list
1459
1469
  let nextSibling = listItem.nextElementSibling;
1460
1470
  while (nextSibling && nextSibling.tagName === 'LI') {
@@ -1683,8 +1693,25 @@ function handleMarkdownShortcut(editor, e) {
1683
1693
  /** Remove the trigger characters from the text node before applying formatting. */
1684
1694
  function clearBlockText(textNode, charCount) {
1685
1695
  const text = textNode.textContent || "";
1686
- textNode.textContent = text.substring(charCount);
1687
- // 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
+ }
1688
1715
  const selection = window.getSelection();
1689
1716
  if (selection) {
1690
1717
  const range = document.createRange();
@@ -3227,7 +3254,7 @@ function createImagePlugin(onImageUpload) {
3227
3254
  }
3228
3255
  }
3229
3256
  };
3230
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { type: "button", onClick: () => setShowModal(true), disabled: props.disabled, className: "rte-toolbar-button", title: "Insert Image", "aria-label": "Insert Image", children: jsxRuntime.jsx(IconWrapper, { icon: "mdi:image", width: 18, height: 18 }) }), showModal && (jsxRuntime.jsx("div", { className: "rte-image-modal-overlay", onClick: (e) => {
3257
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { type: "button", onClick: () => setShowModal(true), disabled: props.disabled, className: "rte-toolbar-button", title: "Insert Image", "aria-label": "Insert Image", children: jsxRuntime.jsx(IconWrapper, { icon: "mdi:image", width: 18, height: 18 }) }), showModal && (jsxRuntime.jsx("div", { className: "rte-image-modal-overlay", onMouseDown: (e) => e.stopPropagation(), onClick: (e) => {
3231
3258
  if (e.target === e.currentTarget) {
3232
3259
  setShowModal(false);
3233
3260
  }
@@ -5141,10 +5168,18 @@ const Editor = ({ initialContent, onChange, plugins: providedPlugins, placeholde
5141
5168
  {
5142
5169
  "--rte-button-hover-bg": theme.buttonHoverBg,
5143
5170
  }),
5171
+ ...(theme.buttonActiveBg &&
5172
+ {
5173
+ "--rte-button-active-bg": theme.buttonActiveBg,
5174
+ }),
5144
5175
  ...(theme.contentBg &&
5145
5176
  {
5146
5177
  "--rte-content-bg": theme.contentBg,
5147
5178
  }),
5179
+ ...(theme.textColor &&
5180
+ {
5181
+ "--rte-text-color": theme.textColor,
5182
+ }),
5148
5183
  ...(theme.primaryColor &&
5149
5184
  {
5150
5185
  "--rte-primary-color": theme.primaryColor,