@cyberyozh/text-editor 0.1.16 → 0.1.17
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/editor.css +1 -0
- package/dist/editor.css.map +1 -1
- package/dist/editor.js +12 -13
- package/dist/editor.js.map +1 -1
- package/dist/editor.mjs +12 -13
- package/dist/editor.mjs.map +1 -1
- package/dist/styles/index.css +1 -0
- package/package.json +1 -1
- package/src/extensions/editor/figure.ts +14 -15
- package/src/styles/extensions/figure.css +1 -0
package/dist/editor.mjs
CHANGED
|
@@ -6433,7 +6433,8 @@ var Figure2 = BaseFigure.extend({
|
|
|
6433
6433
|
};
|
|
6434
6434
|
const updateImageDimensions = (width, height) => {
|
|
6435
6435
|
imageContainer.style.width = `${width}px`;
|
|
6436
|
-
imageContainer.style.
|
|
6436
|
+
imageContainer.style.aspectRatio = `${width} / ${height}`;
|
|
6437
|
+
imageContainer.style.height = "";
|
|
6437
6438
|
};
|
|
6438
6439
|
const figure = document.createElement("figure");
|
|
6439
6440
|
figure.setAttribute("data-drag-handle", "");
|
|
@@ -6445,7 +6446,7 @@ var Figure2 = BaseFigure.extend({
|
|
|
6445
6446
|
if (attrs.title) img.title = attrs.title;
|
|
6446
6447
|
if (attrs.width && attrs.height) {
|
|
6447
6448
|
imageContainer.style.width = `${attrs.width}px`;
|
|
6448
|
-
imageContainer.style.
|
|
6449
|
+
imageContainer.style.aspectRatio = `${attrs.width} / ${attrs.height}`;
|
|
6449
6450
|
}
|
|
6450
6451
|
img.onload = () => {
|
|
6451
6452
|
naturalAspectRatio = img.naturalHeight / img.naturalWidth;
|
|
@@ -6453,15 +6454,11 @@ var Figure2 = BaseFigure.extend({
|
|
|
6453
6454
|
maxHeight = Math.round(maxWidth * naturalAspectRatio);
|
|
6454
6455
|
}
|
|
6455
6456
|
if (attrs.width && attrs.height && maxWidth && attrs.width > maxWidth) {
|
|
6456
|
-
const width = maxWidth;
|
|
6457
|
-
const height = Math.round(attrs.height / attrs.width * maxWidth);
|
|
6458
|
-
imageContainer.style.width = `${width}px`;
|
|
6459
|
-
imageContainer.style.height = `${height}px`;
|
|
6460
6457
|
const pos = getPos();
|
|
6461
6458
|
if (typeof pos === "number") {
|
|
6462
6459
|
editor.chain().updateAttributes("image", {
|
|
6463
|
-
width:
|
|
6464
|
-
height: Math.round(height)
|
|
6460
|
+
width: maxWidth,
|
|
6461
|
+
height: Math.round(attrs.height / attrs.width * maxWidth)
|
|
6465
6462
|
}).run();
|
|
6466
6463
|
}
|
|
6467
6464
|
}
|
|
@@ -6503,11 +6500,12 @@ var Figure2 = BaseFigure.extend({
|
|
|
6503
6500
|
}
|
|
6504
6501
|
},
|
|
6505
6502
|
onUpdate: (updatedNode) => {
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
}
|
|
6509
|
-
if (
|
|
6510
|
-
imageContainer.style.
|
|
6503
|
+
const newWidth = updatedNode.attrs.width;
|
|
6504
|
+
const newHeight = updatedNode.attrs.height;
|
|
6505
|
+
if (newWidth) imageContainer.style.width = `${newWidth}px`;
|
|
6506
|
+
if (newWidth && newHeight) {
|
|
6507
|
+
imageContainer.style.aspectRatio = `${newWidth} / ${newHeight}`;
|
|
6508
|
+
imageContainer.style.height = "";
|
|
6511
6509
|
}
|
|
6512
6510
|
const existingCaption = figure.querySelector("figcaption");
|
|
6513
6511
|
if (updatedNode.attrs.caption && !existingCaption) {
|
|
@@ -6545,6 +6543,7 @@ var Figure2 = BaseFigure.extend({
|
|
|
6545
6543
|
}
|
|
6546
6544
|
}
|
|
6547
6545
|
});
|
|
6546
|
+
imageContainer.style.height = "";
|
|
6548
6547
|
figure.appendChild(resizableView.dom);
|
|
6549
6548
|
if (attrs.caption) {
|
|
6550
6549
|
const figcaption = document.createElement("figcaption");
|