@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 CHANGED
@@ -6555,6 +6555,10 @@ var DEFAULT_EDITOR_OPTIONS = [EDITOR_OPTIONS.BOLD, EDITOR_OPTIONS.ITALIC, EDITOR
6555
6555
  var EDITOR_PADDING_SIZE = 12;
6556
6556
  var EDITOR_BORDER_SIZE = 1;
6557
6557
  var EDITOR_LINE_HEIGHT = 21;
6558
+ var IMAGE_REGEX = new RegExp(/(<img[^>]*?>)(?![\s\S]*<\/figure>)/g);
6559
+ var IMAGE_REPLACEMENT_PATTERN = "<figure>$1</figure>";
6560
+ var EMPTY_DIV_REGEX = new RegExp(/<div[^>]*?>\s*(?:<br[^>]*?>)\s*<\/div>/g);
6561
+ var TRAILING_BR_REGEX = new RegExp(/\s*(?:<br[^>]*?>)+\s*$/);
6558
6562
 
6559
6563
  var getEditorStyles = function getEditorStyles(_ref) {
6560
6564
  var rows = _ref.rows;
@@ -6601,6 +6605,10 @@ var validateAndFormatUrl = function validateAndFormatUrl(url) {
6601
6605
  }
6602
6606
  return url;
6603
6607
  };
6608
+ var transformEditorContent = function transformEditorContent(content) {
6609
+ var _content$replaceAll, _content$replaceAll$r;
6610
+ 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, "");
6611
+ };
6604
6612
 
6605
6613
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
6606
6614
 
@@ -87015,7 +87023,7 @@ var EmojiSuggestion$1 = EmojiSuggestion.configure({
87015
87023
  });
87016
87024
 
87017
87025
  var ImageComponent = function ImageComponent(_ref) {
87018
- var _figureRef$current$qu;
87026
+ var _figureRef$current$qu, _figureRef$current;
87019
87027
  var node = _ref.node,
87020
87028
  editor = _ref.editor,
87021
87029
  getPos = _ref.getPos,
@@ -87036,9 +87044,17 @@ var ImageComponent = function ImageComponent(_ref) {
87036
87044
  var height = figheight;
87037
87045
  var width = figwidth;
87038
87046
  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;
87047
+ var editorElement = (_figureRef$current = figureRef.current) === null || _figureRef$current === void 0 ? void 0 : _figureRef$current.closest(".neeto-editor");
87048
+ var maxImageWidth = (editorElement === null || editorElement === void 0 ? void 0 : editorElement.offsetWidth) - 50;
87039
87049
  var handleResizeStop = function handleResizeStop(_event, _direction, ref) {
87040
87050
  height = ref.offsetHeight;
87041
87051
  width = ref.offsetWidth;
87052
+ if (width > maxImageWidth) {
87053
+ width = maxImageWidth;
87054
+ var aspectRatio = ref.offsetHeight / ref.offsetWidth;
87055
+ height = width * aspectRatio;
87056
+ }
87057
+ setCaptionWidth(width);
87042
87058
  view.dispatch(view.state.tr.setNodeMarkup(getPos(), undefined, ramda.mergeRight(node.attrs, {
87043
87059
  figheight: height,
87044
87060
  figwidth: width,
@@ -87060,6 +87076,7 @@ var ImageComponent = function ImageComponent(_ref) {
87060
87076
  }), src ? /*#__PURE__*/React__default["default"].createElement(Resizable, {
87061
87077
  lockAspectRatio: true,
87062
87078
  className: "neeto-editor__image",
87079
+ minWidth: "100px",
87063
87080
  size: {
87064
87081
  height: height,
87065
87082
  width: width
@@ -99027,4 +99044,5 @@ exports.Menu = Menu;
99027
99044
  exports.isEditorEmpty = isEditorEmpty;
99028
99045
  exports.isEditorOverlaysActive = isEditorOverlaysActive;
99029
99046
  exports.substituteVariables = substituteVariables;
99047
+ exports.transformEditorContent = transformEditorContent;
99030
99048
  //# sourceMappingURL=index.cjs.js.map