@overlap/rte 1.0.2 → 1.0.4

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.esm.js CHANGED
@@ -268,6 +268,12 @@ function ensureAllCheckboxes(editor) {
268
268
  if (!ul.classList.contains("rte-checkbox-list")) {
269
269
  ul.classList.add("rte-checkbox-list");
270
270
  }
271
+ // Propagate checkbox class to nested ULs inside LI children
272
+ ul.querySelectorAll(":scope > li > ul").forEach((nestedUl) => {
273
+ if (!nestedUl.classList.contains("rte-checkbox-list")) {
274
+ nestedUl.classList.add("rte-checkbox-list");
275
+ }
276
+ });
271
277
  // Handle GitHub format: convert <input type="checkbox"> to aria-checked
272
278
  ul.querySelectorAll(":scope > li").forEach((li) => {
273
279
  const input = li.querySelector('input[type="checkbox"]');
@@ -1422,8 +1428,10 @@ function indentListItem(selection) {
1422
1428
  // Create nested list in the previous item
1423
1429
  let nestedList = previousItem.querySelector('ul, ol');
1424
1430
  if (!nestedList) {
1425
- // Create new nested list
1426
1431
  nestedList = document.createElement(list.tagName.toLowerCase());
1432
+ if (list.classList.contains('rte-checkbox-list')) {
1433
+ nestedList.classList.add('rte-checkbox-list');
1434
+ }
1427
1435
  previousItem.appendChild(nestedList);
1428
1436
  }
1429
1437
  // Move current item into nested list
@@ -1451,6 +1459,9 @@ function indentListItem(selection) {
1451
1459
  else {
1452
1460
  // No previous item — create new nested list in current item
1453
1461
  const nestedList = document.createElement(list.tagName.toLowerCase());
1462
+ if (list.classList.contains('rte-checkbox-list')) {
1463
+ nestedList.classList.add('rte-checkbox-list');
1464
+ }
1454
1465
  // Move all following items into the nested list
1455
1466
  let nextSibling = listItem.nextElementSibling;
1456
1467
  while (nextSibling && nextSibling.tagName === 'LI') {
@@ -3179,9 +3190,9 @@ function createImagePlugin(onImageUpload) {
3179
3190
  alert('Please enter an image URL');
3180
3191
  return;
3181
3192
  }
3182
- // Validate URL safety
3193
+ // Validate URL safety (allow data:image/* for base64-encoded uploads)
3183
3194
  const srcWithoutMeta = src.split('|__aid__:')[0];
3184
- if (!isUrlSafe(srcWithoutMeta)) {
3195
+ if (!isUrlSafe(srcWithoutMeta) && !srcWithoutMeta.startsWith('data:image/')) {
3185
3196
  alert('Invalid image URL');
3186
3197
  return;
3187
3198
  }
@@ -3223,13 +3234,12 @@ function createImagePlugin(onImageUpload) {
3223
3234
  }
3224
3235
  }
3225
3236
  };
3226
- return (jsxs(Fragment, { children: [jsx("button", { type: "button", onClick: () => setShowModal(true), disabled: props.disabled, className: "rte-toolbar-button", title: "Insert Image", "aria-label": "Insert Image", children: jsx(IconWrapper, { icon: "mdi:image", width: 18, height: 18 }) }), showModal && (jsx("div", { className: "rte-image-modal-overlay", onClick: (e) => {
3237
+ return (jsxs(Fragment, { children: [jsx("button", { type: "button", onClick: () => setShowModal(true), disabled: props.disabled, className: "rte-toolbar-button", title: "Insert Image", "aria-label": "Insert Image", children: jsx(IconWrapper, { icon: "mdi:image", width: 18, height: 18 }) }), showModal && (jsx("div", { className: "rte-image-modal-overlay", onMouseDown: (e) => e.stopPropagation(), onClick: (e) => {
3227
3238
  if (e.target === e.currentTarget) {
3228
3239
  setShowModal(false);
3229
3240
  }
3230
- }, children: jsxs("div", { className: "rte-image-modal", children: [jsxs("div", { className: "rte-image-modal-header", children: [jsx("h3", { children: "Insert Image" }), jsx("button", { type: "button", onClick: () => setShowModal(false), className: "rte-image-modal-close", "aria-label": "Close", children: jsx(IconWrapper, { icon: "mdi:close", width: 20, height: 20 }) })] }), jsxs("div", { className: "rte-image-modal-content", children: [onImageUpload && (jsx("div", { className: "rte-image-upload-section", children: jsxs("label", { className: "rte-image-upload-label", children: [jsx("input", { ref: fileInputRef, type: "file", accept: "image/*", onChange: handleFileSelect, style: { display: 'none' } }), jsx("div", { className: "rte-image-upload-button", children: isUploading ? (jsxs(Fragment, { children: [jsx(IconWrapper, { icon: "mdi:loading", width: 24, height: 24, className: "rte-spin" }), jsx("span", { children: "Uploading..." })] })) : (jsxs(Fragment, { children: [jsx(IconWrapper, { icon: "mdi:upload", width: 24, height: 24 }), jsx("span", { children: "Choose File" })] })) })] }) })), jsx("div", { className: "rte-image-url-section", children: jsxs("label", { children: ["Image URL", jsx("input", { type: "url", value: imageUrl, onChange: (e) => {
3241
+ }, children: jsxs("div", { className: "rte-image-modal", children: [jsxs("div", { className: "rte-image-modal-header", children: [jsx("h3", { children: "Insert Image" }), jsx("button", { type: "button", onClick: () => setShowModal(false), className: "rte-image-modal-close", "aria-label": "Close", children: jsx(IconWrapper, { icon: "mdi:close", width: 20, height: 20 }) })] }), jsxs("div", { className: "rte-image-modal-content", children: [onImageUpload && (jsx("div", { className: "rte-image-upload-section", children: jsxs("label", { className: "rte-image-upload-label", children: [jsx("input", { ref: fileInputRef, type: "file", accept: "image/*", onChange: handleFileSelect, style: { display: 'none' } }), jsx("div", { className: "rte-image-upload-button", children: isUploading ? (jsxs(Fragment, { children: [jsx(IconWrapper, { icon: "mdi:loading", width: 24, height: 24, className: "rte-spin" }), jsx("span", { children: "Uploading..." })] })) : (jsxs(Fragment, { children: [jsx(IconWrapper, { icon: "mdi:upload", width: 24, height: 24 }), jsx("span", { children: "Choose File" })] })) })] }) })), jsx("div", { className: "rte-image-url-section", children: jsxs("label", { children: ["Image URL", jsx("input", { type: "text", value: imageUrl, onChange: (e) => {
3231
3242
  setImageUrl(e.target.value);
3232
- // Clear raw URL when user manually edits
3233
3243
  setRawUrl('');
3234
3244
  }, placeholder: "https://example.com/image.jpg", className: "rte-image-url-input" })] }) }), jsx("div", { className: "rte-image-alt-section", children: jsxs("label", { children: ["Alt Text (optional)", jsx("input", { type: "text", value: altText, onChange: (e) => setAltText(e.target.value), placeholder: "Image description", className: "rte-image-alt-input" })] }) }), imageUrl && (jsx("div", { className: "rte-image-preview", children: jsx("img", { src: imageUrl, alt: altText || 'Preview' }) }))] }), jsxs("div", { className: "rte-image-modal-footer", children: [jsx("button", { type: "button", onClick: () => setShowModal(false), className: "rte-image-modal-cancel", children: "Cancel" }), jsx("button", { type: "button", onClick: handleInsertImage, disabled: !imageUrl.trim() || isUploading, className: "rte-image-modal-insert", children: "Insert" })] })] }) }))] }));
3235
3245
  },