@bigbinary/neeto-editor 1.28.22 → 1.28.23
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/index.cjs.js +19 -1
- package/index.cjs.js.map +1 -1
- package/index.js +19 -2
- package/index.js.map +1 -1
- package/package.json +2 -1
- package/types.d.ts +2 -0
package/index.js
CHANGED
|
@@ -6525,6 +6525,10 @@ var DEFAULT_EDITOR_OPTIONS = [EDITOR_OPTIONS.BOLD, EDITOR_OPTIONS.ITALIC, EDITOR
|
|
|
6525
6525
|
var EDITOR_PADDING_SIZE = 12;
|
|
6526
6526
|
var EDITOR_BORDER_SIZE = 1;
|
|
6527
6527
|
var EDITOR_LINE_HEIGHT = 21;
|
|
6528
|
+
var IMAGE_REGEX = new RegExp(/(<img[^>]*?>)(?![\s\S]*<\/figure>)/g);
|
|
6529
|
+
var IMAGE_REPLACEMENT_PATTERN = "<figure>$1</figure>";
|
|
6530
|
+
var EMPTY_DIV_REGEX = new RegExp(/<div[^>]*?>\s*(?:<br[^>]*?>)\s*<\/div>/g);
|
|
6531
|
+
var TRAILING_BR_REGEX = new RegExp(/\s*(?:<br[^>]*?>)+\s*$/);
|
|
6528
6532
|
|
|
6529
6533
|
var getEditorStyles = function getEditorStyles(_ref) {
|
|
6530
6534
|
var rows = _ref.rows;
|
|
@@ -6571,6 +6575,10 @@ var validateAndFormatUrl = function validateAndFormatUrl(url) {
|
|
|
6571
6575
|
}
|
|
6572
6576
|
return url;
|
|
6573
6577
|
};
|
|
6578
|
+
var transformEditorContent = function transformEditorContent(content) {
|
|
6579
|
+
var _content$replaceAll, _content$replaceAll$r;
|
|
6580
|
+
return content === null || content === void 0 ? void 0 : (_content$replaceAll = content.replaceAll(IMAGE_REGEX, IMAGE_REPLACEMENT_PATTERN)) === null || _content$replaceAll === void 0 ? void 0 : (_content$replaceAll$r = _content$replaceAll.replaceAll(EMPTY_DIV_REGEX, "")) === null || _content$replaceAll$r === void 0 ? void 0 : _content$replaceAll$r.replace(TRAILING_BR_REGEX, "");
|
|
6581
|
+
};
|
|
6574
6582
|
|
|
6575
6583
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
6576
6584
|
|
|
@@ -86985,7 +86993,7 @@ var EmojiSuggestion$1 = EmojiSuggestion.configure({
|
|
|
86985
86993
|
});
|
|
86986
86994
|
|
|
86987
86995
|
var ImageComponent = function ImageComponent(_ref) {
|
|
86988
|
-
var _figureRef$current$qu;
|
|
86996
|
+
var _figureRef$current$qu, _figureRef$current;
|
|
86989
86997
|
var node = _ref.node,
|
|
86990
86998
|
editor = _ref.editor,
|
|
86991
86999
|
getPos = _ref.getPos,
|
|
@@ -87006,9 +87014,17 @@ var ImageComponent = function ImageComponent(_ref) {
|
|
|
87006
87014
|
var height = figheight;
|
|
87007
87015
|
var width = figwidth;
|
|
87008
87016
|
var caption = figureRef.current ? (_figureRef$current$qu = figureRef.current.querySelector("figcaption>div")) === null || _figureRef$current$qu === void 0 ? void 0 : _figureRef$current$qu.textContent : alt;
|
|
87017
|
+
var editorElement = (_figureRef$current = figureRef.current) === null || _figureRef$current === void 0 ? void 0 : _figureRef$current.closest(".neeto-editor");
|
|
87018
|
+
var maxImageWidth = (editorElement === null || editorElement === void 0 ? void 0 : editorElement.offsetWidth) - 50;
|
|
87009
87019
|
var handleResizeStop = function handleResizeStop(_event, _direction, ref) {
|
|
87010
87020
|
height = ref.offsetHeight;
|
|
87011
87021
|
width = ref.offsetWidth;
|
|
87022
|
+
if (width > maxImageWidth) {
|
|
87023
|
+
width = maxImageWidth;
|
|
87024
|
+
var aspectRatio = ref.offsetHeight / ref.offsetWidth;
|
|
87025
|
+
height = width * aspectRatio;
|
|
87026
|
+
}
|
|
87027
|
+
setCaptionWidth(width);
|
|
87012
87028
|
view.dispatch(view.state.tr.setNodeMarkup(getPos(), undefined, mergeRight(node.attrs, {
|
|
87013
87029
|
figheight: height,
|
|
87014
87030
|
figwidth: width,
|
|
@@ -87030,6 +87046,7 @@ var ImageComponent = function ImageComponent(_ref) {
|
|
|
87030
87046
|
}), src ? /*#__PURE__*/React__default.createElement(Resizable, {
|
|
87031
87047
|
lockAspectRatio: true,
|
|
87032
87048
|
className: "neeto-editor__image",
|
|
87049
|
+
minWidth: "100px",
|
|
87033
87050
|
size: {
|
|
87034
87051
|
height: height,
|
|
87035
87052
|
width: width
|
|
@@ -98989,5 +99006,5 @@ initializeI18n({
|
|
|
98989
99006
|
}
|
|
98990
99007
|
});
|
|
98991
99008
|
|
|
98992
|
-
export { Attachments$1 as Attachments, Editor$1 as Editor, index as EditorContent, FormikEditor$1 as FormikEditor, Menu, isEditorEmpty, isEditorOverlaysActive, substituteVariables };
|
|
99009
|
+
export { Attachments$1 as Attachments, Editor$1 as Editor, index as EditorContent, FormikEditor$1 as FormikEditor, Menu, isEditorEmpty, isEditorOverlaysActive, substituteVariables, transformEditorContent };
|
|
98993
99010
|
//# sourceMappingURL=index.js.map
|