@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/styles/index.css
CHANGED
package/package.json
CHANGED
|
@@ -54,7 +54,8 @@ export const Figure = BaseFigure.extend({
|
|
|
54
54
|
|
|
55
55
|
const updateImageDimensions = (width: number, height: number) => {
|
|
56
56
|
imageContainer.style.width = `${width}px`;
|
|
57
|
-
imageContainer.style.
|
|
57
|
+
imageContainer.style.aspectRatio = `${width} / ${height}`;
|
|
58
|
+
imageContainer.style.height = '';
|
|
58
59
|
};
|
|
59
60
|
|
|
60
61
|
const figure = document.createElement("figure");
|
|
@@ -70,7 +71,7 @@ export const Figure = BaseFigure.extend({
|
|
|
70
71
|
|
|
71
72
|
if (attrs.width && attrs.height) {
|
|
72
73
|
imageContainer.style.width = `${attrs.width}px`;
|
|
73
|
-
imageContainer.style.
|
|
74
|
+
imageContainer.style.aspectRatio = `${attrs.width} / ${attrs.height}`;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
img.onload = () => {
|
|
@@ -81,19 +82,13 @@ export const Figure = BaseFigure.extend({
|
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
if (attrs.width && attrs.height && maxWidth && attrs.width > maxWidth) {
|
|
84
|
-
const width = maxWidth;
|
|
85
|
-
const height = Math.round((attrs.height / attrs.width) * maxWidth);
|
|
86
|
-
|
|
87
|
-
imageContainer.style.width = `${width}px`;
|
|
88
|
-
imageContainer.style.height = `${height}px`;
|
|
89
|
-
|
|
90
85
|
const pos = getPos();
|
|
91
86
|
if (typeof pos === "number") {
|
|
92
87
|
editor
|
|
93
88
|
.chain()
|
|
94
89
|
.updateAttributes("image", {
|
|
95
|
-
width:
|
|
96
|
-
height: Math.round(height),
|
|
90
|
+
width: maxWidth,
|
|
91
|
+
height: Math.round((attrs.height / attrs.width) * maxWidth),
|
|
97
92
|
})
|
|
98
93
|
.run();
|
|
99
94
|
}
|
|
@@ -149,11 +144,13 @@ export const Figure = BaseFigure.extend({
|
|
|
149
144
|
}
|
|
150
145
|
},
|
|
151
146
|
onUpdate: (updatedNode) => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (
|
|
156
|
-
|
|
147
|
+
const newWidth = updatedNode.attrs.width;
|
|
148
|
+
const newHeight = updatedNode.attrs.height;
|
|
149
|
+
|
|
150
|
+
if (newWidth) imageContainer.style.width = `${newWidth}px`;
|
|
151
|
+
if (newWidth && newHeight) {
|
|
152
|
+
imageContainer.style.aspectRatio = `${newWidth} / ${newHeight}`;
|
|
153
|
+
imageContainer.style.height = '';
|
|
157
154
|
}
|
|
158
155
|
|
|
159
156
|
const existingCaption = figure.querySelector("figcaption");
|
|
@@ -194,6 +191,8 @@ export const Figure = BaseFigure.extend({
|
|
|
194
191
|
},
|
|
195
192
|
});
|
|
196
193
|
|
|
194
|
+
imageContainer.style.height = '';
|
|
195
|
+
|
|
197
196
|
figure.appendChild(resizableView.dom);
|
|
198
197
|
|
|
199
198
|
if (attrs.caption) {
|