opentiny 6.9.4 → 6.9.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/tinymce.js CHANGED
@@ -25915,12 +25915,9 @@
25915
25915
  return tag + '>';
25916
25916
  };
25917
25917
  const toBlockElements = (text, rootTag, rootAttrs) => {
25918
- const blocks = text.split(/\n\n/);
25918
+ const paragraphs = text.split(/\n/);
25919
25919
  const tagOpen = openContainer(rootTag, rootAttrs);
25920
25920
  const tagClose = '</' + rootTag + '>';
25921
- const paragraphs = map$3(blocks, p => {
25922
- return p.split(/\n/).join('<br />');
25923
- });
25924
25921
  const stitch = p => {
25925
25922
  return tagOpen + p + tagClose;
25926
25923
  };
@@ -26176,6 +26173,7 @@
26176
26173
  }
26177
26174
  };
26178
26175
 
26176
+ const defaultMaxImageWidthPx = 300;
26179
26177
  const uniqueId = createIdGenerator('mceclip');
26180
26178
  const createPasteDataTransfer = html => {
26181
26179
  const dataTransfer = createDataTransfer();
@@ -26245,7 +26243,17 @@
26245
26243
  const blobCache = editor.editorUpload.blobCache;
26246
26244
  const existingBlobInfo = blobCache.getByData(base64, type);
26247
26245
  const blobInfo = existingBlobInfo !== null && existingBlobInfo !== void 0 ? existingBlobInfo : createBlobInfo(editor, blobCache, file, base64);
26248
- pasteHtml(editor, `<img src="${ blobInfo.blobUri() }">`, false, true);
26246
+ const img = new Image();
26247
+ img.src = blobInfo.blobUri();
26248
+ img.onload = () => {
26249
+ const contentBodyElement = editor.dom.select('.mce-content-body')[0];
26250
+ const maxImageWidth = contentBodyElement ? parseInt(window.getComputedStyle(contentBodyElement).width) : defaultMaxImageWidthPx;
26251
+ const imageWidth = Math.min(img.naturalWidth, maxImageWidth);
26252
+ pasteHtml(editor, `<img src="${ blobInfo.blobUri() }" width="${ imageWidth }px">`, false, true);
26253
+ };
26254
+ img.onerror = err => {
26255
+ console.error('Failed to load the image blob:', err);
26256
+ };
26249
26257
  });
26250
26258
  };
26251
26259
  const isClipboardEvent = event => event.type === 'paste';