ecomlab-components-next 0.1.32 → 0.1.34
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/common/fetchUrls.js +7 -2
- package/dist/common/headers.js +2 -1
- package/dist/common/hooks/useDebounce.js +37 -0
- package/dist/common/hooks/useTextSelectionInModal.js +41 -0
- package/dist/components/Article/ArcticleWiki/ArcticleWiki.stories.js +152 -0
- package/dist/components/Article/ArcticleWiki/ArticleWiki.js +775 -0
- package/dist/components/Article/ArcticleWiki/ArticleWiki.scss +278 -0
- package/dist/components/Article/ArticleViewV2/ArticleViewV2.js +791 -0
- package/dist/components/Article/ArticleViewV2/ArticleViewV2.scss +245 -0
- package/dist/components/Article/ArticleViewV2/ArticleViewV2.stories.js +166 -0
- package/dist/components/Article/ArticleViewV2/img/bell.svg +9 -0
- package/dist/components/Article/ArticleViewV2/img/btn-add-round.svg +4 -0
- package/dist/components/Article/ArticleViewV2/img/calendar_icon.svg +6 -0
- package/dist/components/Article/ArticleViewV2/img/close-round.svg +3 -0
- package/dist/components/Article/ArticleViewV2/img/close.svg +9 -0
- package/dist/components/Article/ArticleViewV2/img/copy_icon.svg +5 -0
- package/dist/components/Article/ArticleViewV2/img/dndMenu.svg +1 -0
- package/dist/components/Article/ArticleViewV2/img/info.svg +9 -0
- package/dist/components/Article/ArticleViewV2/img/ok_icon.svg +5 -0
- package/dist/components/Article/ArticleViewV2/img/plus_circle.svg +6 -0
- package/dist/components/Article/ArticleViewV2/img/share_icon.svg +5 -0
- package/dist/components/Article/ArticleViewV2/img/tg.svg +3 -0
- package/dist/components/Article/ArticleViewV2/img/tg_icon.svg +5 -0
- package/dist/components/Article/ArticleViewV2/img/time_icon.svg +6 -0
- package/dist/components/Article/ArticleViewV2/img/view_icon.svg +6 -0
- package/dist/components/Article/ArticleViewV2/img/vk_icon.svg +5 -0
- package/dist/components/Article/ArticleViewV2/img/whatsapp_icon.svg +5 -0
- package/dist/components/Article/Breadcrumb/Breadcrumb.js +69 -0
- package/dist/components/Article/Breadcrumb/Breadcrumb.scss +96 -0
- package/dist/components/Article/Breadcrumb/img/drop-right.svg +3 -0
- package/dist/components/Article/Breadcrumb/img/home_icon.svg +5 -0
- package/dist/components/Article/EditWrapper/EditWrapper.js +108 -0
- package/dist/components/Article/EditWrapper/EditWrapper.scss +93 -0
- package/dist/components/Article/EditWrapper/img/bx-grid-vertical.svg +5 -0
- package/dist/components/Article/Editor/Editor.js +92 -0
- package/dist/components/Article/Editor/Editor.scss +35 -0
- package/dist/components/Article/Editor/img/copy.svg +6 -0
- package/dist/components/Article/FormBtn/FormBtn.js +229 -0
- package/dist/components/Article/FormBtn/FormBtn.scss +458 -0
- package/dist/components/Article/FormBtn/ModalBitrixForm/ModalBitrixForm.js +282 -0
- package/dist/components/Article/FormBtn/ModalBitrixForm/ModalBitrixForm.scss +140 -0
- package/dist/components/Article/FormBtn/ModalBitrixForm/img/close_icon.svg +3 -0
- package/dist/components/Article/FormBtn/ModalBitrixForm/img/done_icon.svg +3 -0
- package/dist/components/Article/FormBtn/ModalBitrixForm/img/ozon.svg +9 -0
- package/dist/components/Article/FormBtn/ModalBitrixForm/img/ozon_bkg.svg +9 -0
- package/dist/components/Article/FormBtn/ModalBitrixForm/validationFunc.js +14 -0
- package/dist/components/Article/FormBtn/img/clos_icon.svg +6 -0
- package/dist/components/Article/FormBtn/img/close-icon.svg +3 -0
- package/dist/components/Article/ImgArticle/ImgArticle.js +297 -0
- package/dist/components/Article/ImgArticle/ImgArticle.scss +169 -0
- package/dist/components/Article/ImgArticle/img/noPhoto.png +0 -0
- package/dist/components/Article/InformationBlock/InformationBlock.js +200 -0
- package/dist/components/Article/InformationBlock/InformationBlock.scss +89 -0
- package/dist/components/Article/InformationBlock/img/bell.svg +9 -0
- package/dist/components/Article/ListOfContent/ListOfContent.js +110 -0
- package/dist/components/Article/ListOfContent/ListOfContent.scss +115 -0
- package/dist/components/Article/ListOfContent/img/time_icon.svg +3 -0
- package/dist/components/Article/ListOfContent/img/view_icon.svg +3 -0
- package/dist/components/Article/ModalMiltilevelSidebarSettings/ModalMiltilevelSidebarSettings.js +973 -0
- package/dist/components/Article/ModalMiltilevelSidebarSettings/ModalMiltilevelSidebarSettings.scss +254 -0
- package/dist/components/Article/ModalMiltilevelSidebarSettings/ModalMiltilevelSidebarSettings.stories.js +76 -0
- package/dist/components/Article/ModalMiltilevelSidebarSettings/img/bx-cog.png +0 -0
- package/dist/components/Article/ModalMiltilevelSidebarSettings/img/bx-cog.svg +4 -0
- package/dist/components/Article/ModalMiltilevelSidebarSettings/img/bx-trash.png +0 -0
- package/dist/components/Article/ModalMiltilevelSidebarSettings/img/bx-trash.svg +4 -0
- package/dist/components/Article/ModalMiltilevelSidebarSettings/img/drop_icon.svg +5 -0
- package/dist/components/Article/ModalMiltilevelSidebarSettings/img/edit_icon.svg +6 -0
- package/dist/components/Article/ModalMiltilevelSidebarSettings/img/trash_icon.svg +8 -0
- package/dist/components/Article/ModalReplaceBlock/ModalReplaceBlock.js +85 -0
- package/dist/components/Article/ModalReplaceBlock/ModalReplaceBlock.scss +72 -0
- package/dist/components/Article/SelectedBlocks/SelectedBlocks.js +281 -0
- package/dist/components/Article/SelectedBlocks/SelectedBlocks.scss +0 -0
- package/dist/components/Article/SocialMedia/ModalSelectionSocialMedia/ModalSelectionSocialMedia.js +130 -0
- package/dist/components/Article/SocialMedia/ModalSelectionSocialMedia/ModalSelectionSocialMedia.scss +65 -0
- package/dist/components/Article/SocialMedia/ModalSelectionSocialMedia/img/Facebook.svg +4 -0
- package/dist/components/Article/SocialMedia/ModalSelectionSocialMedia/img/OK.svg +4 -0
- package/dist/components/Article/SocialMedia/ModalSelectionSocialMedia/img/Xcom.svg +9 -0
- package/dist/components/Article/SocialMedia/ModalSelectionSocialMedia/img/linkedin.svg +5 -0
- package/dist/components/Article/SocialMedia/ModalSelectionSocialMedia/img/tg.svg +4 -0
- package/dist/components/Article/SocialMedia/ModalSelectionSocialMedia/img/vk.svg +4 -0
- package/dist/components/Article/SocialMedia/ModalSelectionSocialMedia/img/wtsp.svg +4 -0
- package/dist/components/Article/SocialMedia/SocialMedia.js +242 -0
- package/dist/components/Article/SocialMedia/SocialMedia.scss +57 -0
- package/dist/components/Article/SocialMedia/img/dzen.svg +4 -0
- package/dist/components/Article/SocialMedia/img/facebook.svg +4 -0
- package/dist/components/Article/SocialMedia/img/insta.svg +9 -0
- package/dist/components/Article/SocialMedia/img/linkendIn.svg +5 -0
- package/dist/components/Article/SocialMedia/img/ok.svg +4 -0
- package/dist/components/Article/SocialMedia/img/pikabu.svg +9 -0
- package/dist/components/Article/SocialMedia/img/telegram.svg +4 -0
- package/dist/components/Article/SocialMedia/img/vcru.svg +0 -0
- package/dist/components/Article/SocialMedia/img/vk.svg +4 -0
- package/dist/components/Article/SocialMedia/img/wp.svg +4 -0
- package/dist/components/Article/SocialMedia/img/x.svg +9 -0
- package/dist/components/Article/TextArticle/TextArticle.js +257 -0
- package/dist/components/Article/TextArticle/TextArticle.scss +156 -0
- package/dist/components/Article/TextArticle/img/dndMenu.svg +1 -0
- package/dist/components/Article/TitleText/TitleText.js +157 -0
- package/dist/components/Article/TitleText/TitleText.scss +74 -0
- package/dist/components/Article/VideoArticle/VideoArticle.js +248 -0
- package/dist/components/Article/VideoArticle/VideoArticle.scss +147 -0
- package/dist/components/Buttons/ButtonActionDrop/ButtonActionDrop.js +109 -0
- package/dist/components/Buttons/ButtonActionDrop/ButtonActionDrop.scss +97 -0
- package/dist/components/Buttons/ButtonActionDrop/img/bx-dots-horizontal-rounded.svg +3 -0
- package/package.json +3 -2
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ImgArticle = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _universalCookie = _interopRequireDefault(require("universal-cookie"));
|
|
11
|
+
var _noPhoto = _interopRequireDefault(require("./img/noPhoto.png"));
|
|
12
|
+
var _EditWrapper = require("../EditWrapper/EditWrapper");
|
|
13
|
+
var _InputDinamycPlaceholder = _interopRequireDefault(require("../../Inputs/InputDinamycPlaceholder/InputDinamycPlaceholder"));
|
|
14
|
+
var _useDebounce = require("../../../common/hooks/useDebounce");
|
|
15
|
+
require("./ImgArticle.scss");
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
19
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
22
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
23
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
24
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
25
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
26
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
27
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
28
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
29
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } // import { ARTICLE_TYPES } from '../ArticleElement'
|
|
30
|
+
var ImgArticle = exports.ImgArticle = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
31
|
+
var _data$;
|
|
32
|
+
var data = _ref.data,
|
|
33
|
+
editMode = _ref.editMode,
|
|
34
|
+
onChange = _ref.onChange,
|
|
35
|
+
changeContent = _ref.changeContent,
|
|
36
|
+
position = _ref.position,
|
|
37
|
+
setContentArr = _ref.setContentArr,
|
|
38
|
+
id = _ref.id,
|
|
39
|
+
setCurrentIndex = _ref.setCurrentIndex,
|
|
40
|
+
ind = _ref.ind,
|
|
41
|
+
setIsModal = _ref.setIsModal,
|
|
42
|
+
before = _ref.before,
|
|
43
|
+
setBeforeBlock = _ref.setBeforeBlock,
|
|
44
|
+
deleteBlock = _ref.deleteBlock,
|
|
45
|
+
_ref$readonly = _ref.readonly,
|
|
46
|
+
readonly = _ref$readonly === void 0 ? false : _ref$readonly,
|
|
47
|
+
draggableElement = _ref.draggableElement,
|
|
48
|
+
setDraggableElement = _ref.setDraggableElement,
|
|
49
|
+
articleId = _ref.articleId,
|
|
50
|
+
fetchDataById = _ref.fetchDataById,
|
|
51
|
+
changeBlock = _ref.changeBlock;
|
|
52
|
+
var _useState = (0, _react.useState)(""),
|
|
53
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
54
|
+
extension = _useState2[0],
|
|
55
|
+
setExtension = _useState2[1];
|
|
56
|
+
var _useState3 = (0, _react.useState)(false),
|
|
57
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
58
|
+
error = _useState4[0],
|
|
59
|
+
setError = _useState4[1];
|
|
60
|
+
var _useState5 = (0, _react.useState)(false),
|
|
61
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
62
|
+
isOpen = _useState6[0],
|
|
63
|
+
setOpen = _useState6[1];
|
|
64
|
+
var fileInputRef = (0, _react.useRef)();
|
|
65
|
+
// const showPlaceholder = (data === undefined || data === '') && uploadedImage === undefined
|
|
66
|
+
var cookies = new _universalCookie["default"]();
|
|
67
|
+
var activeLang = localStorage.getItem('lang');
|
|
68
|
+
var _useState7 = (0, _react.useState)(null),
|
|
69
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
70
|
+
objImg = _useState8[0],
|
|
71
|
+
setObjImg = _useState8[1];
|
|
72
|
+
var _useState9 = (0, _react.useState)(((_data$ = data[0]) === null || _data$ === void 0 || (_data$ = _data$.properties) === null || _data$ === void 0 ? void 0 : _data$.alt) || ''),
|
|
73
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
74
|
+
altValue = _useState10[0],
|
|
75
|
+
setAltValue = _useState10[1];
|
|
76
|
+
var translatePlaceholderOpen = function translatePlaceholderOpen() {
|
|
77
|
+
if (activeLang == 'ru') return 'Открыть изображение';
|
|
78
|
+
if (activeLang == 'en') return 'Open image';
|
|
79
|
+
if (activeLang == 'tr') return "Resmi büyüt";
|
|
80
|
+
return 'Открыть изображение';
|
|
81
|
+
};
|
|
82
|
+
var translatePlaceholderSelected = function translatePlaceholderSelected() {
|
|
83
|
+
if (activeLang == 'ru') return 'Выберите изображение';
|
|
84
|
+
if (activeLang == 'en') return 'Select an image';
|
|
85
|
+
if (activeLang == 'tr') return "Bir resim seçin";
|
|
86
|
+
return 'Выберите изображение';
|
|
87
|
+
};
|
|
88
|
+
(0, _react.useImperativeHandle)(ref, function () {
|
|
89
|
+
return {
|
|
90
|
+
error: error,
|
|
91
|
+
// прикрутить открытие системного диалога с выбором изображения
|
|
92
|
+
focus: function focus() {},
|
|
93
|
+
data: objImg
|
|
94
|
+
};
|
|
95
|
+
}, [objImg]);
|
|
96
|
+
var debounceChange = (0, _useDebounce.useDebounce)(changeContent, 1000);
|
|
97
|
+
(0, _react.useEffect)(function () {
|
|
98
|
+
debounceChange(id, [objImg]);
|
|
99
|
+
setContentArr(function (prev) {
|
|
100
|
+
return prev.map(function (el) {
|
|
101
|
+
if ((el === null || el === void 0 ? void 0 : el.block_id) == id) {
|
|
102
|
+
return _objectSpread(_objectSpread({}, el), {}, {
|
|
103
|
+
content: [objImg]
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
return el;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}, [objImg]);
|
|
111
|
+
var fetchPostImg = function fetchPostImg(file) {
|
|
112
|
+
var fd = new FormData();
|
|
113
|
+
fd.append('images', file);
|
|
114
|
+
var url = "https://dl.ecomru.ru:6001/clients/images";
|
|
115
|
+
var token = cookies.get('auth');
|
|
116
|
+
var requestHeaders = {
|
|
117
|
+
'Accept': 'application/json',
|
|
118
|
+
'Cache-control': 'no-cache',
|
|
119
|
+
'Authorization': "Bearer ".concat(token)
|
|
120
|
+
};
|
|
121
|
+
fetch(url, {
|
|
122
|
+
body: fd,
|
|
123
|
+
method: 'POST',
|
|
124
|
+
headers: requestHeaders
|
|
125
|
+
}).then(function (res) {
|
|
126
|
+
if (res.ok) {
|
|
127
|
+
return res.json();
|
|
128
|
+
} else {
|
|
129
|
+
throw new Error('bad table response');
|
|
130
|
+
}
|
|
131
|
+
}).then(function (json) {
|
|
132
|
+
if (json.images) {
|
|
133
|
+
var _json$images;
|
|
134
|
+
setObjImg({
|
|
135
|
+
value: (_json$images = json.images) === null || _json$images === void 0 || (_json$images = _json$images[0]) === null || _json$images === void 0 ? void 0 : _json$images.url,
|
|
136
|
+
properties: {
|
|
137
|
+
alt: altValue
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
// debounceChange({value: json.images?.[0]?.url, type: ARTICLE_TYPES.image, place: position, alt: altValue}, ARTICLE_TYPES.image)
|
|
141
|
+
}
|
|
142
|
+
})["catch"](function (err) {
|
|
143
|
+
console.log(err);
|
|
144
|
+
})["finally"](function () {
|
|
145
|
+
// mapContentToApiRequest(contentData)
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
var handleImageClick = function handleImageClick(e) {
|
|
149
|
+
if (readonly) {
|
|
150
|
+
var html = document.querySelector('html');
|
|
151
|
+
html.style = 'overflow: hidden';
|
|
152
|
+
setOpen(!isOpen);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (fileInputRef.current) {
|
|
156
|
+
fileInputRef.current.click();
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var handleFileInput = function handleFileInput(e) {
|
|
160
|
+
if (e.target.files.length === 0) {
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
var fileBase64Reader = new FileReader();
|
|
165
|
+
fileBase64Reader.onload = function () {
|
|
166
|
+
var _fileBase64Reader$res, _extensionAndBase64$;
|
|
167
|
+
var re = /;base64,/;
|
|
168
|
+
var extensionAndBase64 = (_fileBase64Reader$res = fileBase64Reader.result) === null || _fileBase64Reader$res === void 0 ? void 0 : _fileBase64Reader$res.split(re);
|
|
169
|
+
var onlyExtension = (_extensionAndBase64$ = extensionAndBase64[0]) === null || _extensionAndBase64$ === void 0 ? void 0 : _extensionAndBase64$.split('image/')[1];
|
|
170
|
+
setExtension(onlyExtension);
|
|
171
|
+
fetchPostImg(e.target.files[0]);
|
|
172
|
+
};
|
|
173
|
+
fileBase64Reader.readAsDataURL(e.target.files[0]);
|
|
174
|
+
setError(false);
|
|
175
|
+
onChange();
|
|
176
|
+
};
|
|
177
|
+
(0, _react.useEffect)(function () {
|
|
178
|
+
var _data$2, _data$3;
|
|
179
|
+
setObjImg({
|
|
180
|
+
value: (_data$2 = data[0]) === null || _data$2 === void 0 ? void 0 : _data$2.value,
|
|
181
|
+
properties: {
|
|
182
|
+
alt: (_data$3 = data[0]) === null || _data$3 === void 0 || (_data$3 = _data$3.properties) === null || _data$3 === void 0 ? void 0 : _data$3.alt
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}, []);
|
|
186
|
+
(0, _react.useEffect)(function () {
|
|
187
|
+
if (!isOpen) {
|
|
188
|
+
if (typeof document !== 'undefined') {
|
|
189
|
+
var html = document.querySelector('html');
|
|
190
|
+
html.style = 'overflow: unset';
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}, [isOpen]);
|
|
194
|
+
(0, _react.useEffect)(function () {
|
|
195
|
+
setObjImg(function (prev) {
|
|
196
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
197
|
+
properties: {
|
|
198
|
+
alt: altValue
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
}, [altValue]);
|
|
203
|
+
var handleDeleteBlock = function handleDeleteBlock(e) {
|
|
204
|
+
// setContent(e.currentTarget.textContent)
|
|
205
|
+
setContentArr(function (prev) {
|
|
206
|
+
return prev.filter(function (el) {
|
|
207
|
+
if ((el === null || el === void 0 ? void 0 : el.block_id) != id) {
|
|
208
|
+
return el;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
deleteBlock(id);
|
|
213
|
+
};
|
|
214
|
+
(0, _react.useEffect)(function () {
|
|
215
|
+
setCurrentIndex(ind);
|
|
216
|
+
setBeforeBlock(before);
|
|
217
|
+
}, []);
|
|
218
|
+
return /*#__PURE__*/_react["default"].createElement(_EditWrapper.EditWrapper, {
|
|
219
|
+
id: id,
|
|
220
|
+
before: before,
|
|
221
|
+
readonly: readonly,
|
|
222
|
+
deleteFunc: function deleteFunc(e) {
|
|
223
|
+
return handleDeleteBlock(id);
|
|
224
|
+
},
|
|
225
|
+
type: "image",
|
|
226
|
+
articleId: articleId,
|
|
227
|
+
changeBlock: changeBlock,
|
|
228
|
+
draggableElement: draggableElement,
|
|
229
|
+
setDraggableElement: setDraggableElement,
|
|
230
|
+
fetchDataById: fetchDataById,
|
|
231
|
+
child: /*#__PURE__*/_react["default"].createElement("div", {
|
|
232
|
+
className: "img-container__box",
|
|
233
|
+
onClick: function onClick(e) {
|
|
234
|
+
setCurrentIndex(ind);
|
|
235
|
+
setBeforeBlock(before);
|
|
236
|
+
},
|
|
237
|
+
onContextMenu: function onContextMenu(e) {
|
|
238
|
+
if (!readonly) {
|
|
239
|
+
e.preventDefault();
|
|
240
|
+
setCurrentIndex(ind);
|
|
241
|
+
setIsModal(true);
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
tabIndex: 0
|
|
245
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
246
|
+
className: "img-container",
|
|
247
|
+
onClick: handleImageClick
|
|
248
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
249
|
+
className: "blackout",
|
|
250
|
+
style: {
|
|
251
|
+
display: isOpen ? 'flex' : 'none'
|
|
252
|
+
}
|
|
253
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
254
|
+
className: "img-box"
|
|
255
|
+
}, /*#__PURE__*/_react["default"].createElement("img", {
|
|
256
|
+
className: "img",
|
|
257
|
+
src: objImg === null || objImg === void 0 ? void 0 : objImg.value
|
|
258
|
+
}))), /*#__PURE__*/_react["default"].createElement("button", {
|
|
259
|
+
className: !readonly ? 'img-container__button' : 'img-container__button__readonly'
|
|
260
|
+
}, /*#__PURE__*/_react["default"].createElement("img", {
|
|
261
|
+
src: objImg !== null && objImg !== void 0 && objImg.value ? objImg === null || objImg === void 0 ? void 0 : objImg.value : _noPhoto["default"],
|
|
262
|
+
onError: function onError(e) {
|
|
263
|
+
e.target.src = _noPhoto["default"];
|
|
264
|
+
setError(true);
|
|
265
|
+
},
|
|
266
|
+
className: "img",
|
|
267
|
+
extension: extension,
|
|
268
|
+
alt: altValue ? altValue : ''
|
|
269
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
270
|
+
className: "hidden-placeholder"
|
|
271
|
+
}, /*#__PURE__*/_react["default"].createElement("p", {
|
|
272
|
+
className: "text"
|
|
273
|
+
}, objImg ? translatePlaceholderOpen() : translatePlaceholderSelected()))), /*#__PURE__*/_react["default"].createElement("input", {
|
|
274
|
+
name: "uploadedImage",
|
|
275
|
+
ref: fileInputRef,
|
|
276
|
+
className: "img-container__file-input",
|
|
277
|
+
type: "file",
|
|
278
|
+
onChange: handleFileInput,
|
|
279
|
+
accept: "image/png, image/jpeg"
|
|
280
|
+
}), !readonly && /*#__PURE__*/_react["default"].createElement("div", {
|
|
281
|
+
className: "link_modal",
|
|
282
|
+
onClick: function onClick(e) {
|
|
283
|
+
return e.stopPropagation();
|
|
284
|
+
}
|
|
285
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
286
|
+
className: "link_modal_container"
|
|
287
|
+
}, /*#__PURE__*/_react["default"].createElement(_InputDinamycPlaceholder["default"], {
|
|
288
|
+
placeholder: "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 alt",
|
|
289
|
+
onChange: function onChange(e) {
|
|
290
|
+
setAltValue(e);
|
|
291
|
+
debounceChange(id, [objImg]);
|
|
292
|
+
},
|
|
293
|
+
changeValue: altValue,
|
|
294
|
+
autoComplete: false
|
|
295
|
+
})))))
|
|
296
|
+
});
|
|
297
|
+
});
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// @import url('../../../font.scss');
|
|
2
|
+
|
|
3
|
+
.img-container {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
height: auto;
|
|
8
|
+
max-height: 600px;
|
|
9
|
+
max-width: 100%;
|
|
10
|
+
border-radius: 10px;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
|
|
14
|
+
&__box {
|
|
15
|
+
width: 100%;
|
|
16
|
+
margin-bottom: 32px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.img-container__button__readonly,
|
|
20
|
+
.img-container__button {
|
|
21
|
+
display: flex;
|
|
22
|
+
border: none;
|
|
23
|
+
width: 100%;
|
|
24
|
+
background-color: inherit;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
height: 100%;
|
|
28
|
+
position: relative;
|
|
29
|
+
|
|
30
|
+
.img {
|
|
31
|
+
width: auto;
|
|
32
|
+
height: auto;
|
|
33
|
+
max-width: 100%;
|
|
34
|
+
max-height: 600px;
|
|
35
|
+
object-fit: contain;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.hidden-placeholder {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
width: 100%;
|
|
43
|
+
height: 100%;
|
|
44
|
+
position: absolute;
|
|
45
|
+
top: 0;
|
|
46
|
+
left: 0;
|
|
47
|
+
right: 0;
|
|
48
|
+
bottom: 0;
|
|
49
|
+
z-index: 1;
|
|
50
|
+
background-color: white;
|
|
51
|
+
opacity: 0.5;
|
|
52
|
+
transition: 0.3s;
|
|
53
|
+
opacity: 0;
|
|
54
|
+
visibility: hidden;
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
|
|
57
|
+
.text {
|
|
58
|
+
color: #2B2B46;
|
|
59
|
+
font-family: "Golos Text";
|
|
60
|
+
font-size: 32px;
|
|
61
|
+
line-height: 1.1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&:hover {
|
|
66
|
+
.hidden-placeholder {
|
|
67
|
+
visibility: visible;
|
|
68
|
+
opacity: 0.5;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
.blackout {
|
|
78
|
+
display: flex;
|
|
79
|
+
width: 100%;
|
|
80
|
+
height: 100%;
|
|
81
|
+
min-height: 100vh;
|
|
82
|
+
z-index: 10;
|
|
83
|
+
position: fixed;
|
|
84
|
+
overflow: auto;
|
|
85
|
+
align-items: center;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
background-color: rgb(0, 0, 0, 0.3);
|
|
88
|
+
padding: 20px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.img-box {
|
|
92
|
+
display: flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
width: 100%;
|
|
96
|
+
height: 100%;
|
|
97
|
+
|
|
98
|
+
.img {
|
|
99
|
+
width: auto;
|
|
100
|
+
height: auto;
|
|
101
|
+
max-width: 100%;
|
|
102
|
+
max-height: 100%;
|
|
103
|
+
object-fit: contain;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&__placeholder {
|
|
108
|
+
width: 200px;
|
|
109
|
+
height: 200px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&__button {
|
|
113
|
+
min-width: 100%;
|
|
114
|
+
position: relative;
|
|
115
|
+
top: 0;
|
|
116
|
+
bottom: 0;
|
|
117
|
+
left: 0;
|
|
118
|
+
right: 0;
|
|
119
|
+
z-index: 0;
|
|
120
|
+
border: none;
|
|
121
|
+
border-radius: 16px;
|
|
122
|
+
background-color: unset;
|
|
123
|
+
min-height: 100px;
|
|
124
|
+
|
|
125
|
+
&__placeholder {
|
|
126
|
+
display: flex;
|
|
127
|
+
width: 400px;
|
|
128
|
+
height: 400px;
|
|
129
|
+
justify-content: center;
|
|
130
|
+
align-items: center;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&__file-input {
|
|
135
|
+
position: absolute;
|
|
136
|
+
opacity: 0;
|
|
137
|
+
visibility: hidden;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
&__img {
|
|
141
|
+
display: inline-block;
|
|
142
|
+
max-width: 100%;
|
|
143
|
+
width: 100%;
|
|
144
|
+
height: auto;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&__img-placeholder {
|
|
148
|
+
display: inline-block;
|
|
149
|
+
max-width: 100%;
|
|
150
|
+
width: 100%;
|
|
151
|
+
height: auto;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@media (max-width: 1100px) {
|
|
156
|
+
.img-container {
|
|
157
|
+
&__box {
|
|
158
|
+
margin-bottom: 24px;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@media (max-width: 430px) {
|
|
164
|
+
.img-container {
|
|
165
|
+
&__box {
|
|
166
|
+
margin-bottom: 18px;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.InformationBlock = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _EditWrapper = require("../EditWrapper/EditWrapper");
|
|
11
|
+
var _Editor = require("../Editor/Editor");
|
|
12
|
+
var _htmlReactParser = _interopRequireDefault(require("html-react-parser"));
|
|
13
|
+
var _useDebounce = require("../../../common/hooks/useDebounce");
|
|
14
|
+
require("./InformationBlock.scss");
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
16
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
17
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
18
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
21
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
22
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
24
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
25
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
26
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
27
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
28
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } // import { ModalReplaceLink } from '../../Modal/ModalReplaceLink/ModalReplaceLink'
|
|
29
|
+
var InformationBlock = exports.InformationBlock = function InformationBlock(_ref) {
|
|
30
|
+
var _data$;
|
|
31
|
+
var data = _ref.data,
|
|
32
|
+
editMode = _ref.editMode,
|
|
33
|
+
changeContent = _ref.changeContent,
|
|
34
|
+
setContentArr = _ref.setContentArr,
|
|
35
|
+
id = _ref.id,
|
|
36
|
+
deleteBlock = _ref.deleteBlock,
|
|
37
|
+
setCurrentIndex = _ref.setCurrentIndex,
|
|
38
|
+
ind = _ref.ind,
|
|
39
|
+
setIsModal = _ref.setIsModal,
|
|
40
|
+
setBeforeBlock = _ref.setBeforeBlock,
|
|
41
|
+
before = _ref.before,
|
|
42
|
+
_ref$readonly = _ref.readonly,
|
|
43
|
+
readonly = _ref$readonly === void 0 ? false : _ref$readonly,
|
|
44
|
+
draggableElement = _ref.draggableElement,
|
|
45
|
+
setDraggableElement = _ref.setDraggableElement,
|
|
46
|
+
articleId = _ref.articleId,
|
|
47
|
+
fetchDataById = _ref.fetchDataById,
|
|
48
|
+
changeBlock = _ref.changeBlock;
|
|
49
|
+
var ref = (0, _react.useRef)();
|
|
50
|
+
var _useState = (0, _react.useState)((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.value),
|
|
51
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
+
content = _useState2[0],
|
|
53
|
+
setContent = _useState2[1];
|
|
54
|
+
var _useState3 = (0, _react.useState)(false),
|
|
55
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
56
|
+
showLinkModal = _useState4[0],
|
|
57
|
+
setShowLinkModal = _useState4[1];
|
|
58
|
+
var _useState5 = (0, _react.useState)(null),
|
|
59
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
60
|
+
target = _useState6[0],
|
|
61
|
+
setTarget = _useState6[1];
|
|
62
|
+
var _useState7 = (0, _react.useState)({}),
|
|
63
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
64
|
+
selectionData = _useState8[0],
|
|
65
|
+
setSelectionData = _useState8[1];
|
|
66
|
+
var handleInput = function handleInput(e) {
|
|
67
|
+
var _ref$current;
|
|
68
|
+
debounceChange(id, [{
|
|
69
|
+
value: ref === null || ref === void 0 || (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.innerHTML,
|
|
70
|
+
properties: {}
|
|
71
|
+
}]);
|
|
72
|
+
setContentArr(function (prev) {
|
|
73
|
+
return prev.map(function (el) {
|
|
74
|
+
if ((el === null || el === void 0 ? void 0 : el.block_id) == id) {
|
|
75
|
+
var _ref$current2;
|
|
76
|
+
return _objectSpread(_objectSpread({}, el), {}, {
|
|
77
|
+
content: [{
|
|
78
|
+
value: ref === null || ref === void 0 || (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.innerHTML
|
|
79
|
+
}]
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
return el;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
var getSelectionText = function getSelectionText() {
|
|
88
|
+
var text = "";
|
|
89
|
+
var startIndex;
|
|
90
|
+
var endIndex;
|
|
91
|
+
var WGS = window.getSelection();
|
|
92
|
+
if (WGS) {
|
|
93
|
+
text = WGS.toString();
|
|
94
|
+
startIndex = WGS.extentOffset;
|
|
95
|
+
endIndex = WGS.anchorOffset;
|
|
96
|
+
} else if (document.selection && document.selection.type != "Control") {
|
|
97
|
+
text = document.selection.createRange().text;
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
text: text,
|
|
101
|
+
startIndex: startIndex,
|
|
102
|
+
endIndex: endIndex
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// const replaceWithLink = (linkValue) => {
|
|
107
|
+
// const fullContent = target.innerText
|
|
108
|
+
// const { text, startIndex, endIndex } = selectionData
|
|
109
|
+
// target.innerHTML = `${fullContent?.slice(0, startIndex)}<a class='link' title=${titleValue} href=${linkValue} target='_blank'>${text}</a>${fullContent?.slice(endIndex, fullContent?.length)}`
|
|
110
|
+
// resetData()
|
|
111
|
+
// }
|
|
112
|
+
|
|
113
|
+
var contextMenuHandler = function contextMenuHandler(e) {
|
|
114
|
+
var _selectionObj$text;
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
var selectionObj = getSelectionText();
|
|
117
|
+
if ((selectionObj === null || selectionObj === void 0 || (_selectionObj$text = selectionObj.text) === null || _selectionObj$text === void 0 ? void 0 : _selectionObj$text.length) < 1) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
setSelectionData(selectionObj);
|
|
121
|
+
setTarget(e.target);
|
|
122
|
+
setShowLinkModal(true);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// useEffect(() => {
|
|
126
|
+
// if (typeof data === 'string') {
|
|
127
|
+
// setContent(parse(data))
|
|
128
|
+
// }
|
|
129
|
+
// }, [editMode, data])
|
|
130
|
+
|
|
131
|
+
var debounceChange = (0, _useDebounce.useDebounce)(changeContent, 1000);
|
|
132
|
+
var handleDeleteBlock = function handleDeleteBlock(e) {
|
|
133
|
+
// setContent(e.currentTarget.textContent)
|
|
134
|
+
setContentArr(function (prev) {
|
|
135
|
+
return prev.filter(function (el) {
|
|
136
|
+
if ((el === null || el === void 0 ? void 0 : el.block_id) != id) {
|
|
137
|
+
return el;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
deleteBlock(id);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// Вставка кода без форматирования
|
|
145
|
+
var handlePaste = function handlePaste(event) {
|
|
146
|
+
event.preventDefault(); // Отменяем стандартное поведение вставки
|
|
147
|
+
var text = event.clipboardData.getData('text/plain'); // Получаем только текст
|
|
148
|
+
document.execCommand('insertText', false, text); // Вставляем текст без форматирования
|
|
149
|
+
};
|
|
150
|
+
return /*#__PURE__*/_react["default"].createElement(_EditWrapper.EditWrapper, {
|
|
151
|
+
id: id,
|
|
152
|
+
before: before,
|
|
153
|
+
deleteFunc: function deleteFunc(e) {
|
|
154
|
+
return handleDeleteBlock(e);
|
|
155
|
+
},
|
|
156
|
+
type: "info",
|
|
157
|
+
articleId: articleId,
|
|
158
|
+
changeBlock: changeBlock,
|
|
159
|
+
readonly: readonly,
|
|
160
|
+
draggableElement: draggableElement,
|
|
161
|
+
setDraggableElement: setDraggableElement,
|
|
162
|
+
fetchDataById: fetchDataById,
|
|
163
|
+
child: /*#__PURE__*/_react["default"].createElement("div", {
|
|
164
|
+
style: {
|
|
165
|
+
display: 'flex',
|
|
166
|
+
flexDirection: 'column',
|
|
167
|
+
gap: '4px',
|
|
168
|
+
width: '100%'
|
|
169
|
+
}
|
|
170
|
+
}, !readonly && /*#__PURE__*/_react["default"].createElement(_Editor.Editor, {
|
|
171
|
+
handleInput: handleInput
|
|
172
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
173
|
+
className: "information-article",
|
|
174
|
+
onClick: function onClick(e) {
|
|
175
|
+
setCurrentIndex(ind);
|
|
176
|
+
setBeforeBlock(before);
|
|
177
|
+
},
|
|
178
|
+
onContextMenu: function onContextMenu(e) {
|
|
179
|
+
if (!readonly) {
|
|
180
|
+
e.preventDefault();
|
|
181
|
+
setCurrentIndex(ind);
|
|
182
|
+
setIsModal(true);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}, /*#__PURE__*/_react["default"].createElement("p", {
|
|
186
|
+
onPaste: handlePaste,
|
|
187
|
+
ref: ref,
|
|
188
|
+
className: "information-article__text",
|
|
189
|
+
suppressContentEditableWarning: true,
|
|
190
|
+
contentEditable: !readonly,
|
|
191
|
+
onInput: function onInput(e) {
|
|
192
|
+
return handleInput(e);
|
|
193
|
+
},
|
|
194
|
+
onContextMenu: contextMenuHandler,
|
|
195
|
+
dangerouslySetInnerHTML: {
|
|
196
|
+
__html: content
|
|
197
|
+
}
|
|
198
|
+
})))
|
|
199
|
+
});
|
|
200
|
+
};
|