strapi-plugin-comments 2.2.15 → 2.2.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/README.md +4 -4
- package/admin/src/components/CommentReviewModal/index.d.ts +0 -1
- package/admin/src/components/ConfirmationDialog/index.d.ts +0 -1
- package/admin/src/components/DiscussionStatus/index.d.ts +0 -1
- package/admin/src/components/DiscussionThread/index.d.ts +0 -1
- package/admin/src/components/DiscussionThreadItem/index.d.ts +0 -1
- package/admin/src/components/DiscussionThreadItemActions/index.d.ts +0 -1
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.d.ts +0 -1
- package/admin/src/components/DiscussionThreadItemFooter/index.d.ts +0 -1
- package/admin/src/components/DiscussionThreadItemReviewAction/index.d.ts +0 -1
- package/admin/src/components/FormSwitch/index.d.ts +0 -1
- package/admin/src/components/LoadingIndicatorOverlay/index.d.ts +0 -1
- package/admin/src/components/ModeratorResponse/index.js +5 -8
- package/admin/src/components/ModeratorResponseModal/ModeratorResponseModal.js +5 -8
- package/admin/src/components/Nav/index.d.ts +0 -1
- package/admin/src/components/PluginIcon/index.d.ts +0 -1
- package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.d.ts +18 -1
- package/admin/src/components/ReportsActions/components/BlockMenu/index.d.ts +0 -1
- package/admin/src/components/ReportsActions/index.d.ts +0 -1
- package/admin/src/components/ReportsReviewModal/index.d.ts +0 -1
- package/admin/src/components/ReportsReviewTable/index.d.ts +0 -1
- package/admin/src/components/StatusBadge/index.d.ts +0 -1
- package/admin/src/components/TableFilters/index.d.ts +0 -1
- package/admin/src/components/TablePagination/index.d.ts +0 -1
- package/admin/src/components/Wysiwyg/Editor.d.ts +24 -12
- package/admin/src/components/Wysiwyg/Editor.js +375 -21
- package/admin/src/components/Wysiwyg/EditorLayout.d.ts +9 -8
- package/admin/src/components/Wysiwyg/EditorLayout.js +37 -51
- package/admin/src/components/Wysiwyg/Field.d.ts +15 -0
- package/admin/src/components/Wysiwyg/{index.js → Field.js} +48 -49
- package/admin/src/components/Wysiwyg/PreviewWysiwyg.d.ts +6 -0
- package/admin/src/components/Wysiwyg/PreviewWysiwyg.js +191 -0
- package/admin/src/components/Wysiwyg/WysiwygFooter.d.ts +7 -6
- package/admin/src/components/Wysiwyg/WysiwygFooter.js +32 -13
- package/admin/src/components/Wysiwyg/WysiwygNav.d.ts +12 -10
- package/admin/src/components/Wysiwyg/WysiwygNav.js +76 -58
- package/admin/src/components/Wysiwyg/WysiwygStyles.d.ts +0 -1
- package/admin/src/components/Wysiwyg/WysiwygStyles.js +8 -13
- package/admin/src/components/Wysiwyg/utils/continueList.d.ts +5 -2
- package/admin/src/components/Wysiwyg/utils/continueList.js +2 -1
- package/admin/src/components/Wysiwyg/utils/mdRenderer.d.ts +5 -0
- package/admin/src/components/Wysiwyg/utils/mdRenderer.js +63 -0
- package/admin/src/components/Wysiwyg/utils/utils.d.ts +11 -9
- package/admin/src/components/Wysiwyg/utils/utils.js +13 -12
- package/admin/src/components/icons/comments.d.ts +0 -1
- package/admin/src/components/icons/lock.d.ts +0 -1
- package/admin/src/components/icons/review.d.ts +0 -1
- package/admin/src/components/icons/strapiIcons.d.ts +0 -1
- package/admin/src/components/icons/unlock.d.ts +0 -1
- package/admin/src/custom-fields/comments/components/icon.d.ts +0 -1
- package/admin/src/index.d.ts +3 -1
- package/admin/src/index.js +1 -1
- package/admin/src/pages/App/index.d.ts +14 -2
- package/admin/src/pages/App/reducer/selectors.d.ts +5 -1
- package/admin/src/pages/Details/components/DetailsEntity/index.d.ts +0 -1
- package/admin/src/pages/Details/components/DetailsFilters/index.d.ts +0 -1
- package/admin/src/pages/Details/index.d.ts +9 -2
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.d.ts +0 -1
- package/admin/src/pages/Discover/index.d.ts +9 -2
- package/admin/src/pages/NoAccessPage/index.d.ts +0 -1
- package/admin/src/pages/Reports/components/ReportsTableRow/index.d.ts +0 -1
- package/admin/src/pages/Reports/index.d.ts +9 -2
- package/admin/src/pages/Settings/index.d.ts +0 -1
- package/admin/src/pages/Settings/index.js +2 -5
- package/admin/src/permissions.js +0 -1
- package/package.json +9 -10
- package/server/services/common.js +3 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/admin/src/components/Wysiwyg/EditorStylesContainer.d.ts +0 -2
- package/admin/src/components/Wysiwyg/EditorStylesContainer.js +0 -348
- package/admin/src/components/Wysiwyg/index.d.ts +0 -28
- package/admin/src/components/Wysiwyg/tests/index.test.d.ts +0 -2
- package/admin/src/components/Wysiwyg/tests/index.test.js +0 -1633
|
@@ -26,17 +26,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
|
|
30
|
-
const
|
|
29
|
+
exports.Editor = void 0;
|
|
30
|
+
const React = __importStar(require("react"));
|
|
31
31
|
const codemirror5_1 = __importDefault(require("codemirror5"));
|
|
32
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
33
|
+
const PreviewWysiwyg_1 = require("./PreviewWysiwyg");
|
|
34
|
+
const continueList_1 = require("./utils/continueList");
|
|
32
35
|
require("codemirror5/addon/display/placeholder");
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const continueList_1 = __importDefault(require("./utils/continueList"));
|
|
37
|
-
const Editor = ({ disabled, editorRef, error, isPreviewMode, isExpandMode, name, onChange, placeholder, textareaRef, value, }) => {
|
|
38
|
-
const onChangeRef = (0, react_1.useRef)(onChange);
|
|
39
|
-
(0, react_1.useEffect)(() => {
|
|
36
|
+
const Editor = React.forwardRef(({ disabled, editorRef, error, isPreviewMode, isExpandMode, name, onChange, placeholder, textareaRef, value, }, forwardedRef) => {
|
|
37
|
+
const onChangeRef = React.useRef(onChange);
|
|
38
|
+
React.useEffect(() => {
|
|
40
39
|
editorRef.current = codemirror5_1.default.fromTextArea(textareaRef.current, {
|
|
41
40
|
lineWrapping: true,
|
|
42
41
|
extraKeys: {
|
|
@@ -50,17 +49,18 @@ const Editor = ({ disabled, editorRef, error, isPreviewMode, isExpandMode, name,
|
|
|
50
49
|
spellcheck: true,
|
|
51
50
|
inputStyle: 'contenteditable',
|
|
52
51
|
});
|
|
53
|
-
codemirror5_1.default.commands.newlineAndIndentContinueMarkdownList =
|
|
54
|
-
|
|
52
|
+
codemirror5_1.default.commands.newlineAndIndentContinueMarkdownList =
|
|
53
|
+
continueList_1.newlineAndIndentContinueMarkdownList;
|
|
54
|
+
editorRef.current.on('change', (doc) => {
|
|
55
55
|
onChangeRef.current({ target: { name, value: doc.getValue(), type: 'wysiwyg' } });
|
|
56
56
|
});
|
|
57
57
|
}, [editorRef, textareaRef, name, placeholder]);
|
|
58
|
-
|
|
59
|
-
if (
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
if (value && !editorRef.current.hasFocus()) {
|
|
60
60
|
editorRef.current.setValue(value);
|
|
61
61
|
}
|
|
62
62
|
}, [editorRef, value]);
|
|
63
|
-
|
|
63
|
+
React.useEffect(() => {
|
|
64
64
|
if (isPreviewMode || disabled) {
|
|
65
65
|
editorRef.current.setOption('readOnly', 'nocursor');
|
|
66
66
|
}
|
|
@@ -68,7 +68,7 @@ const Editor = ({ disabled, editorRef, error, isPreviewMode, isExpandMode, name,
|
|
|
68
68
|
editorRef.current.setOption('readOnly', false);
|
|
69
69
|
}
|
|
70
70
|
}, [disabled, isPreviewMode, editorRef]);
|
|
71
|
-
|
|
71
|
+
React.useEffect(() => {
|
|
72
72
|
if (error) {
|
|
73
73
|
editorRef.current.setOption('screenReaderLabel', error);
|
|
74
74
|
}
|
|
@@ -76,10 +76,364 @@ const Editor = ({ disabled, editorRef, error, isPreviewMode, isExpandMode, name,
|
|
|
76
76
|
editorRef.current.setOption('screenReaderLabel', 'Editor');
|
|
77
77
|
}
|
|
78
78
|
}, [editorRef, error]);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
80
|
+
focus() {
|
|
81
|
+
editorRef.current.getInputField().focus();
|
|
82
|
+
},
|
|
83
|
+
scrollIntoView(args) {
|
|
84
|
+
editorRef.current.getInputField().scrollIntoView(args);
|
|
85
|
+
},
|
|
86
|
+
}), [editorRef]);
|
|
87
|
+
return (React.createElement(EditorAndPreviewWrapper, null,
|
|
88
|
+
React.createElement(EditorStylesContainer, { isExpandMode: isExpandMode, disabled: disabled || isPreviewMode },
|
|
89
|
+
React.createElement("textarea", { ref: textareaRef })),
|
|
90
|
+
isPreviewMode && React.createElement(PreviewWysiwyg_1.PreviewWysiwyg, { data: value })));
|
|
91
|
+
});
|
|
92
|
+
exports.Editor = Editor;
|
|
93
|
+
const EditorAndPreviewWrapper = styled_components_1.default.div `
|
|
94
|
+
position: relative;
|
|
95
|
+
height: calc(100% - 48px);
|
|
96
|
+
`;
|
|
97
|
+
const EditorStylesContainer = styled_components_1.default.div `
|
|
98
|
+
cursor: ${({ disabled }) => (disabled ? 'not-allowed !important' : 'auto')};
|
|
99
|
+
height: 100%;
|
|
100
|
+
/* BASICS */
|
|
101
|
+
.CodeMirror-placeholder {
|
|
102
|
+
color: ${({ theme }) => theme.colors.neutral600} !important;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.CodeMirror {
|
|
106
|
+
/* Set height, width, borders, and global font properties here */
|
|
107
|
+
font-size: ${14 / 16}rem;
|
|
108
|
+
height: ${({ isExpandMode }) => isExpandMode
|
|
109
|
+
? '100%'
|
|
110
|
+
: '410px'}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border
|
|
111
|
+
color: ${({ theme }) => theme.colors.neutral800};
|
|
112
|
+
direction: ltr;
|
|
113
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
|
|
114
|
+
'Open Sans', 'Helvetica Neue', sans-serif;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* PADDING */
|
|
118
|
+
|
|
119
|
+
.CodeMirror-lines {
|
|
120
|
+
padding: ${({ theme }) => `${theme.spaces[3]} ${theme.spaces[4]}`};
|
|
121
|
+
/* Vertical padding around content */
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.CodeMirror-scrollbar-filler,
|
|
125
|
+
.CodeMirror-gutter-filler {
|
|
126
|
+
/* The little square between H and V scrollbars */
|
|
127
|
+
background-color: ${({ theme }) => `${theme.colors.neutral0}`};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* GUTTER */
|
|
131
|
+
|
|
132
|
+
.CodeMirror-gutters {
|
|
133
|
+
border-right: 1px solid #ddd;
|
|
134
|
+
background-color: #f7f7f7;
|
|
135
|
+
white-space: nowrap;
|
|
136
|
+
}
|
|
137
|
+
.CodeMirror-linenumbers {
|
|
138
|
+
}
|
|
139
|
+
.CodeMirror-linenumber {
|
|
140
|
+
padding: 0 3px 0 5px;
|
|
141
|
+
min-width: 20px;
|
|
142
|
+
text-align: right;
|
|
143
|
+
color: #999;
|
|
144
|
+
white-space: nowrap;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.CodeMirror-guttermarker {
|
|
148
|
+
color: black;
|
|
149
|
+
}
|
|
150
|
+
.CodeMirror-guttermarker-subtle {
|
|
151
|
+
color: #999;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* CURSOR */
|
|
155
|
+
|
|
156
|
+
.CodeMirror-cursor {
|
|
157
|
+
border-left: 1px solid black;
|
|
158
|
+
border-right: none;
|
|
159
|
+
width: 0;
|
|
160
|
+
}
|
|
161
|
+
/* Shown when moving in bi-directional text */
|
|
162
|
+
.CodeMirror div.CodeMirror-secondarycursor {
|
|
163
|
+
border-left: 1px solid silver;
|
|
164
|
+
}
|
|
165
|
+
.cm-fat-cursor .CodeMirror-cursor {
|
|
166
|
+
width: auto;
|
|
167
|
+
border: 0 !important;
|
|
168
|
+
background: #7e7;
|
|
169
|
+
}
|
|
170
|
+
.cm-fat-cursor div.CodeMirror-cursors {
|
|
171
|
+
/* z-index: 1; */
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.cm-fat-cursor-mark {
|
|
175
|
+
background-color: rgba(20, 255, 20, 0.5);
|
|
176
|
+
-webkit-animation: blink 1.06s steps(1) infinite;
|
|
177
|
+
-moz-animation: blink 1.06s steps(1) infinite;
|
|
178
|
+
animation: blink 1.06s steps(1) infinite;
|
|
179
|
+
}
|
|
180
|
+
.cm-animate-fat-cursor {
|
|
181
|
+
width: auto;
|
|
182
|
+
border: 0;
|
|
183
|
+
-webkit-animation: blink 1.06s steps(1) infinite;
|
|
184
|
+
-moz-animation: blink 1.06s steps(1) infinite;
|
|
185
|
+
animation: blink 1.06s steps(1) infinite;
|
|
186
|
+
background-color: #7e7;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* Can style cursor different in overwrite (non-insert) mode */
|
|
190
|
+
.CodeMirror-overwrite .CodeMirror-cursor {
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.cm-tab {
|
|
194
|
+
display: inline-block;
|
|
195
|
+
text-decoration: inherit;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.CodeMirror-rulers {
|
|
199
|
+
position: absolute;
|
|
200
|
+
left: 0;
|
|
201
|
+
right: 0;
|
|
202
|
+
top: -50px;
|
|
203
|
+
bottom: 0;
|
|
204
|
+
overflow: hidden;
|
|
205
|
+
}
|
|
206
|
+
.CodeMirror-ruler {
|
|
207
|
+
border-left: 1px solid #ccc;
|
|
208
|
+
top: 0;
|
|
209
|
+
bottom: 0;
|
|
210
|
+
position: absolute;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/* DEFAULT THEME */
|
|
214
|
+
|
|
215
|
+
.cm-header,
|
|
216
|
+
.cm-strong {
|
|
217
|
+
font-weight: bold;
|
|
218
|
+
}
|
|
219
|
+
.cm-em {
|
|
220
|
+
font-style: italic;
|
|
221
|
+
}
|
|
222
|
+
.cm-link {
|
|
223
|
+
text-decoration: underline;
|
|
224
|
+
}
|
|
225
|
+
.cm-strikethrough {
|
|
226
|
+
text-decoration: line-through;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.CodeMirror-composing {
|
|
230
|
+
border-bottom: 2px solid;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* Default styles for common addons */
|
|
234
|
+
|
|
235
|
+
div.CodeMirror span.CodeMirror-matchingbracket {
|
|
236
|
+
color: #0b0;
|
|
237
|
+
}
|
|
238
|
+
div.CodeMirror span.CodeMirror-nonmatchingbracket {
|
|
239
|
+
color: #a22;
|
|
240
|
+
}
|
|
241
|
+
.CodeMirror-matchingtag {
|
|
242
|
+
background: rgba(255, 150, 0, 0.3);
|
|
243
|
+
}
|
|
244
|
+
.CodeMirror-activeline-background {
|
|
245
|
+
background: #e8f2ff;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* STOP */
|
|
249
|
+
|
|
250
|
+
/* The rest of this file contains styles related to the mechanics of
|
|
251
|
+
the editor. You probably shouldn't touch them. */
|
|
252
|
+
|
|
253
|
+
.CodeMirror {
|
|
254
|
+
position: relative;
|
|
255
|
+
overflow: hidden;
|
|
256
|
+
background: ${({ theme }) => `${theme.colors.neutral0}`};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.CodeMirror-scroll {
|
|
260
|
+
overflow: scroll !important; /* Things will break if this is overridden */
|
|
261
|
+
/* 50px is the magic margin used to hide the element's real scrollbars */
|
|
262
|
+
/* See overflow: hidden in .CodeMirror */
|
|
263
|
+
margin-bottom: -50px;
|
|
264
|
+
margin-right: -50px;
|
|
265
|
+
padding-bottom: 50px;
|
|
266
|
+
height: 100%;
|
|
267
|
+
outline: none; /* Prevent dragging from highlighting the element */
|
|
268
|
+
position: relative;
|
|
269
|
+
}
|
|
270
|
+
.CodeMirror-sizer {
|
|
271
|
+
position: relative;
|
|
272
|
+
border-right: 50px solid transparent;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
|
276
|
+
before actual scrolling happens, thus preventing shaking and
|
|
277
|
+
flickering artifacts. */
|
|
278
|
+
.CodeMirror-vscrollbar,
|
|
279
|
+
.CodeMirror-hscrollbar,
|
|
280
|
+
.CodeMirror-scrollbar-filler,
|
|
281
|
+
.CodeMirror-gutter-filler {
|
|
282
|
+
position: absolute;
|
|
283
|
+
z-index: 1;
|
|
284
|
+
display: none;
|
|
285
|
+
outline: none;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.CodeMirror-vscrollbar {
|
|
289
|
+
right: 0;
|
|
290
|
+
top: 0;
|
|
291
|
+
overflow-x: hidden;
|
|
292
|
+
overflow-y: scroll;
|
|
293
|
+
}
|
|
294
|
+
.CodeMirror-hscrollbar {
|
|
295
|
+
bottom: 0;
|
|
296
|
+
left: 0;
|
|
297
|
+
overflow-y: hidden;
|
|
298
|
+
overflow-x: scroll;
|
|
299
|
+
}
|
|
300
|
+
.CodeMirror-scrollbar-filler {
|
|
301
|
+
right: 0;
|
|
302
|
+
bottom: 0;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.CodeMirror-lines {
|
|
306
|
+
cursor: text;
|
|
307
|
+
min-height: 1px; /* prevents collapsing before first draw */
|
|
308
|
+
}
|
|
309
|
+
/* Reset some styles that the rest of the page might have set */
|
|
310
|
+
.CodeMirror pre.CodeMirror-line,
|
|
311
|
+
.CodeMirror pre.CodeMirror-line-like {
|
|
312
|
+
-moz-border-radius: 0;
|
|
313
|
+
-webkit-border-radius: 0;
|
|
314
|
+
border-radius: 0;
|
|
315
|
+
border-width: 0;
|
|
316
|
+
background: transparent;
|
|
317
|
+
font-family: inherit;
|
|
318
|
+
font-size: inherit;
|
|
319
|
+
margin: 0;
|
|
320
|
+
white-space: pre;
|
|
321
|
+
word-wrap: normal;
|
|
322
|
+
line-height: 1.5;
|
|
323
|
+
color: inherit;
|
|
324
|
+
/* z-index: 2; */
|
|
325
|
+
position: relative;
|
|
326
|
+
overflow: visible;
|
|
327
|
+
-webkit-tap-highlight-color: transparent;
|
|
328
|
+
-webkit-font-variant-ligatures: contextual;
|
|
329
|
+
font-variant-ligatures: contextual;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.CodeMirror pre.CodeMirror-line-like {
|
|
333
|
+
z-index: 2;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.CodeMirror-wrap pre.CodeMirror-line,
|
|
337
|
+
.CodeMirror-wrap pre.CodeMirror-line-like {
|
|
338
|
+
word-wrap: break-word;
|
|
339
|
+
white-space: pre-wrap;
|
|
340
|
+
word-break: normal;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.CodeMirror-linebackground {
|
|
344
|
+
position: absolute;
|
|
345
|
+
left: 0;
|
|
346
|
+
right: 0;
|
|
347
|
+
top: 0;
|
|
348
|
+
bottom: 0;
|
|
349
|
+
z-index: 0;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.CodeMirror-linewidget {
|
|
353
|
+
position: relative;
|
|
354
|
+
/* z-index: 2; */
|
|
355
|
+
padding: 0.1px; /* Force widget margins to stay inside of the container */
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.CodeMirror-widget {
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.CodeMirror-rtl pre {
|
|
362
|
+
direction: rtl;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.CodeMirror-code {
|
|
366
|
+
outline: none;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/* Force content-box sizing for the elements where we expect it */
|
|
370
|
+
.CodeMirror-scroll,
|
|
371
|
+
.CodeMirror-sizer,
|
|
372
|
+
.CodeMirror-gutter,
|
|
373
|
+
.CodeMirror-gutters,
|
|
374
|
+
.CodeMirror-linenumber {
|
|
375
|
+
-moz-box-sizing: content-box;
|
|
376
|
+
box-sizing: content-box;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.CodeMirror-measure {
|
|
380
|
+
position: absolute;
|
|
381
|
+
width: 100%;
|
|
382
|
+
height: 0;
|
|
383
|
+
overflow: hidden;
|
|
384
|
+
visibility: hidden;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.CodeMirror-cursor {
|
|
388
|
+
position: absolute;
|
|
389
|
+
pointer-events: none;
|
|
390
|
+
border-color: ${({ theme }) => `${theme.colors.neutral800}`};
|
|
391
|
+
}
|
|
392
|
+
.CodeMirror-measure pre {
|
|
393
|
+
position: static;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
div.CodeMirror-cursors {
|
|
397
|
+
visibility: hidden;
|
|
398
|
+
position: relative;
|
|
399
|
+
+ div {
|
|
400
|
+
z-index: 0 !important;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
div.CodeMirror-dragcursors {
|
|
405
|
+
visibility: visible;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.CodeMirror-focused div.CodeMirror-cursors {
|
|
409
|
+
visibility: visible;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
.CodeMirror-selected {
|
|
413
|
+
background: ${({ theme }) => theme.colors.neutral200};
|
|
414
|
+
/* z-index: -10; */
|
|
415
|
+
}
|
|
416
|
+
.CodeMirror-crosshair {
|
|
417
|
+
cursor: crosshair;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/* Used to force a border model for a node */
|
|
421
|
+
.cm-force-border {
|
|
422
|
+
padding-right: 0.1px;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/* See issue #2901 */
|
|
426
|
+
.cm-tab-wrap-hack:after {
|
|
427
|
+
content: '';
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/* Help users use markselection to safely style text background */
|
|
431
|
+
span.CodeMirror-selectedtext {
|
|
432
|
+
background: none;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
span {
|
|
436
|
+
color: ${({ theme }) => theme.colors.neutral800} !important;
|
|
437
|
+
}
|
|
438
|
+
`;
|
|
85
439
|
//# sourceMappingURL=Editor.js.map
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
type EditorLayoutProps = {
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface EditorLayoutProps {
|
|
4
3
|
children: React.ReactNode;
|
|
5
|
-
error: string | undefined;
|
|
6
4
|
isExpandMode: boolean;
|
|
7
|
-
|
|
5
|
+
error?: string;
|
|
6
|
+
previewContent?: string;
|
|
8
7
|
onCollapse: () => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
}
|
|
9
|
+
declare const EditorLayout: ({ children, isExpandMode, error, previewContent, onCollapse, }: EditorLayoutProps) => JSX.Element;
|
|
10
|
+
declare const ExpandButton: import("styled-components").StyledComponent<any, any, any, any>;
|
|
11
|
+
export { EditorLayout, ExpandButton };
|
|
12
|
+
export type { EditorLayoutProps };
|
|
12
13
|
//# sourceMappingURL=EditorLayout.d.ts.map
|
|
@@ -26,35 +26,54 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const Flex_1 = require("@strapi/design-system/Flex");
|
|
33
|
-
const Box_1 = require("@strapi/design-system/Box");
|
|
34
|
-
const FocusTrap_1 = require("@strapi/design-system/FocusTrap");
|
|
35
|
-
const Portal_1 = require("@strapi/design-system/Portal");
|
|
36
|
-
const BaseButton_1 = require("@strapi/design-system/BaseButton");
|
|
37
|
-
const Typography_1 = require("@strapi/design-system/Typography");
|
|
29
|
+
exports.ExpandButton = exports.EditorLayout = void 0;
|
|
30
|
+
const React = __importStar(require("react"));
|
|
31
|
+
const design_system_1 = require("@strapi/design-system");
|
|
38
32
|
const helper_plugin_1 = require("@strapi/helper-plugin");
|
|
39
|
-
const
|
|
33
|
+
const icons_1 = require("@strapi/icons");
|
|
40
34
|
const react_intl_1 = require("react-intl");
|
|
41
|
-
const
|
|
42
|
-
const
|
|
35
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
36
|
+
const PreviewWysiwyg_1 = require("./PreviewWysiwyg");
|
|
37
|
+
const EditorLayout = ({ children, isExpandMode, error, previewContent = '', onCollapse, }) => {
|
|
38
|
+
const { formatMessage } = (0, react_intl_1.useIntl)();
|
|
39
|
+
(0, helper_plugin_1.useLockScroll)({ lockScroll: isExpandMode });
|
|
40
|
+
if (isExpandMode) {
|
|
41
|
+
return (React.createElement(design_system_1.Portal, { role: "dialog", "aria-modal": false },
|
|
42
|
+
React.createElement(design_system_1.FocusTrap, { onEscape: onCollapse },
|
|
43
|
+
React.createElement(ExpandWrapper, { position: "fixed", top: 0, left: 0, right: 0, bottom: 0, zIndex: 4, justifyContent: "center", onClick: onCollapse },
|
|
44
|
+
React.createElement(design_system_1.Box, { background: "neutral0", hasRadius: true, shadow: "popupShadow", overflow: "hidden", width: "90%", height: "90%", onClick: (e) => e.stopPropagation() },
|
|
45
|
+
React.createElement(design_system_1.Flex, { height: "100%", alignItems: "flex-start" },
|
|
46
|
+
React.createElement(BoxWithBorder, { flex: "1", height: "100%" }, children),
|
|
47
|
+
React.createElement(design_system_1.Flex, { alignItems: "start", direction: "column", flex: 1, height: "100%", width: "100%" },
|
|
48
|
+
React.createElement(design_system_1.Flex, { height: (0, helper_plugin_1.pxToRem)(48), background: "neutral100", justifyContent: "flex-end", shrink: 0, width: "100%" },
|
|
49
|
+
React.createElement(ExpandButton, { onClick: onCollapse },
|
|
50
|
+
React.createElement(design_system_1.Typography, null, formatMessage({
|
|
51
|
+
id: 'components.Wysiwyg.collapse',
|
|
52
|
+
defaultMessage: 'Collapse',
|
|
53
|
+
})),
|
|
54
|
+
React.createElement(icons_1.Collapse, null))),
|
|
55
|
+
React.createElement(design_system_1.Box, { position: "relative", height: "100%", width: "100%" },
|
|
56
|
+
React.createElement(PreviewWysiwyg_1.PreviewWysiwyg, { data: previewContent })))))))));
|
|
57
|
+
}
|
|
58
|
+
return (React.createElement(design_system_1.Box, { borderColor: error ? 'danger600' : 'neutral200', borderStyle: "solid", borderWidth: "1px", hasRadius: true }, children));
|
|
59
|
+
};
|
|
60
|
+
exports.EditorLayout = EditorLayout;
|
|
61
|
+
const ExpandWrapper = (0, styled_components_1.default)(design_system_1.Flex) `
|
|
62
|
+
background: ${({ theme }) => `${theme.colors.neutral800}${Math.floor(0.2 * 255)
|
|
43
63
|
.toString(16)
|
|
44
|
-
.padStart(2, 0)}
|
|
45
|
-
const ExpandWrapper = (0, styled_components_1.default)(Flex_1.Flex) `
|
|
46
|
-
background: ${({ theme }) => setOpacity(theme.colors.neutral800, 0.2)};
|
|
64
|
+
.padStart(2, '0')}`};
|
|
47
65
|
`;
|
|
48
|
-
const BoxWithBorder = (0, styled_components_1.default)(
|
|
66
|
+
const BoxWithBorder = (0, styled_components_1.default)(design_system_1.Box) `
|
|
49
67
|
border-right: 1px solid ${({ theme }) => theme.colors.neutral200};
|
|
50
68
|
`;
|
|
51
|
-
|
|
69
|
+
const ExpandButton = (0, styled_components_1.default)(design_system_1.BaseButton) `
|
|
52
70
|
background-color: transparent;
|
|
53
71
|
border: none;
|
|
54
72
|
align-items: center;
|
|
55
73
|
|
|
56
74
|
svg {
|
|
57
75
|
margin-left: ${({ theme }) => `${theme.spaces[2]}`};
|
|
76
|
+
|
|
58
77
|
path {
|
|
59
78
|
fill: ${({ theme }) => theme.colors.neutral700};
|
|
60
79
|
width: ${12 / 16}rem;
|
|
@@ -62,38 +81,5 @@ exports.ExpandButton = (0, styled_components_1.default)(BaseButton_1.BaseButton)
|
|
|
62
81
|
}
|
|
63
82
|
}
|
|
64
83
|
`;
|
|
65
|
-
|
|
66
|
-
const { formatMessage } = (0, react_intl_1.useIntl)();
|
|
67
|
-
(0, react_1.useEffect)(() => {
|
|
68
|
-
const body = document.body;
|
|
69
|
-
if (isExpandMode) {
|
|
70
|
-
body.classList.add('lock-body-scroll');
|
|
71
|
-
}
|
|
72
|
-
return () => {
|
|
73
|
-
if (isExpandMode) {
|
|
74
|
-
body.classList.remove('lock-body-scroll');
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}, [isExpandMode]);
|
|
78
|
-
if (isExpandMode) {
|
|
79
|
-
return (react_1.default.createElement(Portal_1.Portal, { role: "dialog", "aria-modal": false },
|
|
80
|
-
react_1.default.createElement(FocusTrap_1.FocusTrap, { onEscape: onCollapse },
|
|
81
|
-
react_1.default.createElement(ExpandWrapper, { position: "fixed", top: 0, left: 0, right: 0, bottom: 0, zIndex: 4, justifyContent: "center", onClick: onCollapse },
|
|
82
|
-
react_1.default.createElement(Box_1.Box, { id: "wysiwyg-expand", background: "neutral0", hasRadius: true, shadow: "popupShadow", overflow: "hidden", width: "70%", height: "70%", onClick: (e) => e.stopPropagation() },
|
|
83
|
-
react_1.default.createElement(Flex_1.Flex, { height: "100%", alignItems: "flex-start" },
|
|
84
|
-
react_1.default.createElement(BoxWithBorder, { flex: "1", height: "100%" }, children),
|
|
85
|
-
react_1.default.createElement(Box_1.Box, { flex: "1", height: "100%" },
|
|
86
|
-
react_1.default.createElement(Flex_1.Flex, { height: (0, helper_plugin_1.pxToRem)(48), background: "neutral100", justifyContent: "flex-end" },
|
|
87
|
-
react_1.default.createElement(exports.ExpandButton, { id: "collapse", onClick: onCollapse },
|
|
88
|
-
react_1.default.createElement(Typography_1.Typography, null, formatMessage({
|
|
89
|
-
id: 'components.Wysiwyg.collapse',
|
|
90
|
-
defaultMessage: 'Collapse',
|
|
91
|
-
})),
|
|
92
|
-
react_1.default.createElement(Collapse_1.default, null))),
|
|
93
|
-
react_1.default.createElement(Box_1.Box, { position: "relative", height: "100%" },
|
|
94
|
-
react_1.default.createElement(PreviewWysiwyg_1.default, { data: previewContent })))))))));
|
|
95
|
-
}
|
|
96
|
-
return (react_1.default.createElement(Box_1.Box, { borderColor: error ? 'danger600' : 'neutral200', borderStyle: "solid", borderWidth: "1px", hasRadius: true }, children));
|
|
97
|
-
};
|
|
98
|
-
exports.EditorLayout = EditorLayout;
|
|
84
|
+
exports.ExpandButton = ExpandButton;
|
|
99
85
|
//# sourceMappingURL=EditorLayout.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TranslationMessage } from '@strapi/helper-plugin';
|
|
3
|
+
import { HintProps } from '../Hint';
|
|
4
|
+
import { EditorApi, EditorProps } from './Editor';
|
|
5
|
+
import { EditorLayoutProps } from './EditorLayout';
|
|
6
|
+
interface WysiwygProps extends Pick<EditorProps, 'disabled' | 'name' | 'onChange' | 'value'>, Pick<EditorLayoutProps, 'error'>, Pick<HintProps, 'hint'> {
|
|
7
|
+
intlLabel: TranslationMessage;
|
|
8
|
+
labelAction?: React.ReactNode;
|
|
9
|
+
placeholder?: TranslationMessage;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const Wysiwyg: React.ForwardRefExoticComponent<WysiwygProps & React.RefAttributes<EditorApi>>;
|
|
13
|
+
export { Wysiwyg };
|
|
14
|
+
export type { WysiwygProps };
|
|
15
|
+
//# sourceMappingURL=Field.d.ts.map
|