opentiny 6.9.4 → 6.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opentiny",
3
- "version": "6.9.4",
3
+ "version": "6.9.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mild-blue/opentiny"
package/tinymce.js CHANGED
@@ -26176,6 +26176,7 @@
26176
26176
  }
26177
26177
  };
26178
26178
 
26179
+ const defaultMaxImageWidthPx = 300;
26179
26180
  const uniqueId = createIdGenerator('mceclip');
26180
26181
  const createPasteDataTransfer = html => {
26181
26182
  const dataTransfer = createDataTransfer();
@@ -26245,7 +26246,17 @@
26245
26246
  const blobCache = editor.editorUpload.blobCache;
26246
26247
  const existingBlobInfo = blobCache.getByData(base64, type);
26247
26248
  const blobInfo = existingBlobInfo !== null && existingBlobInfo !== void 0 ? existingBlobInfo : createBlobInfo(editor, blobCache, file, base64);
26248
- pasteHtml(editor, `<img src="${ blobInfo.blobUri() }">`, false, true);
26249
+ const img = new Image();
26250
+ img.src = blobInfo.blobUri();
26251
+ img.onload = () => {
26252
+ const contentBodyElement = editor.dom.select('.mce-content-body')[0];
26253
+ const maxImageWidth = contentBodyElement ? parseInt(window.getComputedStyle(contentBodyElement).width) : defaultMaxImageWidthPx;
26254
+ const imageWidth = Math.min(img.naturalWidth, maxImageWidth);
26255
+ pasteHtml(editor, `<img src="${ blobInfo.blobUri() }" width="${ imageWidth }px">`, false, true);
26256
+ };
26257
+ img.onerror = err => {
26258
+ console.error('Failed to load the image blob:', err);
26259
+ };
26249
26260
  });
26250
26261
  };
26251
26262
  const isClipboardEvent = event => event.type === 'paste';