@elastic/eui 106.1.0 → 106.2.0
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/es/components/call_out/call_out.js +2 -1
- package/es/components/card/checkable_card/checkable_card.js +30 -5
- package/es/components/code/code_block.js +5 -2
- package/es/components/code/code_block_virtualized.js +5 -3
- package/es/components/markdown_editor/index.js +1 -0
- package/es/components/markdown_editor/markdown_editor.js +15 -4
- package/es/components/markdown_editor/markdown_editor_drop_zone.js +5 -3
- package/es/components/markdown_editor/markdown_editor_footer.js +12 -120
- package/es/components/markdown_editor/markdown_editor_footer.styles.js +0 -2
- package/es/components/markdown_editor/markdown_editor_help_button.js +144 -0
- package/es/components/markdown_editor/markdown_editor_help_button.styles.js +16 -0
- package/es/components/markdown_editor/markdown_editor_toolbar.js +28 -23
- package/es/components/popover/popover.js +2 -1
- package/eui.d.ts +84 -52
- package/i18ntokens.json +624 -624
- package/lib/components/call_out/call_out.js +3 -2
- package/lib/components/card/checkable_card/checkable_card.js +29 -4
- package/lib/components/code/code_block.js +5 -2
- package/lib/components/code/code_block_virtualized.js +5 -3
- package/lib/components/markdown_editor/index.js +7 -0
- package/lib/components/markdown_editor/markdown_editor.js +15 -4
- package/lib/components/markdown_editor/markdown_editor_drop_zone.js +5 -3
- package/lib/components/markdown_editor/markdown_editor_footer.js +10 -117
- package/lib/components/markdown_editor/markdown_editor_footer.styles.js +0 -2
- package/lib/components/markdown_editor/markdown_editor_help_button.js +151 -0
- package/lib/components/markdown_editor/markdown_editor_help_button.styles.js +22 -0
- package/lib/components/markdown_editor/markdown_editor_toolbar.js +28 -23
- package/lib/components/popover/popover.js +2 -1
- package/optimize/es/components/call_out/call_out.js +1 -0
- package/optimize/es/components/card/checkable_card/checkable_card.js +25 -5
- package/optimize/es/components/code/code_block.js +5 -2
- package/optimize/es/components/code/code_block_virtualized.js +5 -3
- package/optimize/es/components/markdown_editor/index.js +1 -0
- package/optimize/es/components/markdown_editor/markdown_editor.js +7 -3
- package/optimize/es/components/markdown_editor/markdown_editor_drop_zone.js +3 -2
- package/optimize/es/components/markdown_editor/markdown_editor_footer.js +12 -120
- package/optimize/es/components/markdown_editor/markdown_editor_footer.styles.js +0 -2
- package/optimize/es/components/markdown_editor/markdown_editor_help_button.js +139 -0
- package/optimize/es/components/markdown_editor/markdown_editor_help_button.styles.js +16 -0
- package/optimize/es/components/markdown_editor/markdown_editor_toolbar.js +20 -16
- package/optimize/es/components/popover/popover.js +2 -1
- package/optimize/lib/components/call_out/call_out.js +2 -1
- package/optimize/lib/components/card/checkable_card/checkable_card.js +24 -4
- package/optimize/lib/components/code/code_block.js +5 -2
- package/optimize/lib/components/code/code_block_virtualized.js +5 -3
- package/optimize/lib/components/markdown_editor/index.js +7 -0
- package/optimize/lib/components/markdown_editor/markdown_editor.js +7 -3
- package/optimize/lib/components/markdown_editor/markdown_editor_drop_zone.js +3 -2
- package/optimize/lib/components/markdown_editor/markdown_editor_footer.js +9 -118
- package/optimize/lib/components/markdown_editor/markdown_editor_footer.styles.js +0 -2
- package/optimize/lib/components/markdown_editor/markdown_editor_help_button.js +150 -0
- package/optimize/lib/components/markdown_editor/markdown_editor_help_button.styles.js +22 -0
- package/optimize/lib/components/markdown_editor/markdown_editor_toolbar.js +20 -16
- package/optimize/lib/components/popover/popover.js +2 -1
- package/package.json +1 -1
- package/test-env/components/call_out/call_out.js +3 -2
- package/test-env/components/card/checkable_card/checkable_card.js +24 -4
- package/test-env/components/code/code_block_virtualized.js +5 -3
- package/test-env/components/markdown_editor/index.js +7 -0
- package/test-env/components/markdown_editor/markdown_editor.js +15 -4
- package/test-env/components/markdown_editor/markdown_editor_drop_zone.js +5 -3
- package/test-env/components/markdown_editor/markdown_editor_footer.js +9 -118
- package/test-env/components/markdown_editor/markdown_editor_footer.styles.js +0 -2
- package/test-env/components/markdown_editor/markdown_editor_help_button.js +150 -0
- package/test-env/components/markdown_editor/markdown_editor_help_button.styles.js +22 -0
- package/test-env/components/markdown_editor/markdown_editor_toolbar.js +28 -23
- package/test-env/components/popover/popover.js +2 -1
|
@@ -27,7 +27,7 @@ var _markdown_context = require("./markdown_context");
|
|
|
27
27
|
var _markdown_default_plugins = require("./plugins/markdown_default_plugins");
|
|
28
28
|
var _markdown_editor = require("./markdown_editor.styles");
|
|
29
29
|
var _react2 = require("@emotion/react");
|
|
30
|
-
var _excluded = ["className", "editorId", "value", "onChange", "height", "maxHeight", "autoExpandPreview", "parsingPluginList", "processingPluginList", "uiPlugins", "onParse", "errors", "aria-label", "aria-labelledby", "aria-describedby", "initialViewMode", "dropHandlers", "markdownFormatProps", "placeholder", "readOnly"];
|
|
30
|
+
var _excluded = ["className", "editorId", "value", "onChange", "height", "maxHeight", "autoExpandPreview", "parsingPluginList", "processingPluginList", "uiPlugins", "onParse", "errors", "aria-label", "aria-labelledby", "aria-describedby", "initialViewMode", "dropHandlers", "markdownFormatProps", "placeholder", "readOnly", "toolbarProps", "showFooter"];
|
|
31
31
|
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); }
|
|
32
32
|
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; }
|
|
33
33
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
@@ -115,6 +115,9 @@ var EuiMarkdownEditor = exports.EuiMarkdownEditor = /*#__PURE__*/(0, _react.forw
|
|
|
115
115
|
markdownFormatProps = _ref.markdownFormatProps,
|
|
116
116
|
placeholder = _ref.placeholder,
|
|
117
117
|
readOnly = _ref.readOnly,
|
|
118
|
+
toolbarProps = _ref.toolbarProps,
|
|
119
|
+
_ref$showFooter = _ref.showFooter,
|
|
120
|
+
showFooter = _ref$showFooter === void 0 ? true : _ref$showFooter,
|
|
118
121
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
119
122
|
var _useState = (0, _react.useState)(initialViewMode),
|
|
120
123
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -294,7 +297,7 @@ var EuiMarkdownEditor = exports.EuiMarkdownEditor = /*#__PURE__*/(0, _react.forw
|
|
|
294
297
|
}, (0, _react2.jsx)("div", (0, _extends2.default)({
|
|
295
298
|
className: classes,
|
|
296
299
|
css: cssStyles
|
|
297
|
-
}, rest), (0, _react2.jsx)(_markdown_editor_toolbar.EuiMarkdownEditorToolbar, {
|
|
300
|
+
}, rest), (0, _react2.jsx)(_markdown_editor_toolbar.EuiMarkdownEditorToolbar, (0, _extends2.default)({
|
|
298
301
|
ref: editorToolbarRef,
|
|
299
302
|
selectedNode: selectedNode,
|
|
300
303
|
markdownActions: markdownActions,
|
|
@@ -303,7 +306,7 @@ var EuiMarkdownEditor = exports.EuiMarkdownEditor = /*#__PURE__*/(0, _react.forw
|
|
|
303
306
|
},
|
|
304
307
|
viewMode: viewMode,
|
|
305
308
|
uiPlugins: toolbarPlugins
|
|
306
|
-
}), isPreviewing && (0, _react2.jsx)("div", {
|
|
309
|
+
}, toolbarProps)), isPreviewing && (0, _react2.jsx)("div", {
|
|
307
310
|
ref: previewRef,
|
|
308
311
|
className: classesPreview,
|
|
309
312
|
css: styles.euiMarkdownEditorPreview,
|
|
@@ -335,6 +338,7 @@ var EuiMarkdownEditor = exports.EuiMarkdownEditor = /*#__PURE__*/(0, _react.forw
|
|
|
335
338
|
selectionEnd: newSelectionPoint
|
|
336
339
|
});
|
|
337
340
|
},
|
|
341
|
+
showFooter: showFooter,
|
|
338
342
|
uiPlugins: toolbarPlugins,
|
|
339
343
|
errors: errors,
|
|
340
344
|
hasUnacceptedItems: hasUnacceptedItems,
|
|
@@ -469,6 +473,13 @@ EuiMarkdownEditor.propTypes = {
|
|
|
469
473
|
* Determines the text size. Choose `relative` to control the `font-size` based on the value of a parent container.
|
|
470
474
|
*/
|
|
471
475
|
textSize: _propTypes.default.any
|
|
472
|
-
})
|
|
476
|
+
}),
|
|
477
|
+
/**
|
|
478
|
+
* Props to customize the toolbar. `right` replaces the default preview/editor toggle with custom content.
|
|
479
|
+
*/
|
|
480
|
+
toolbarProps: _propTypes.default.shape({
|
|
481
|
+
right: _propTypes.default.node
|
|
482
|
+
}),
|
|
483
|
+
/** Controls whether the footer is shown */showFooter: _propTypes.default.bool
|
|
473
484
|
};
|
|
474
485
|
EuiMarkdownEditor.displayName = 'EuiMarkdownEditor';
|
|
@@ -69,7 +69,8 @@ var EuiMarkdownEditorDropZone = exports.EuiMarkdownEditorDropZone = function Eui
|
|
|
69
69
|
hasUnacceptedItems = props.hasUnacceptedItems,
|
|
70
70
|
setHasUnacceptedItems = props.setHasUnacceptedItems,
|
|
71
71
|
setEditorFooterHeight = props.setEditorFooterHeight,
|
|
72
|
-
isEditing = props.isEditing
|
|
72
|
+
isEditing = props.isEditing,
|
|
73
|
+
showFooter = props.showFooter;
|
|
73
74
|
var classes = (0, _classnames.default)('euiMarkdownEditorDropZone');
|
|
74
75
|
var styles = (0, _services.useEuiMemoizedStyles)(_markdown_editor_drop_zone.euiMarkdownEditorDropZoneStyles);
|
|
75
76
|
var cssStyles = [styles.euiMarkdownEditorDropZone, isDragging && !isDraggingError && styles.isDragging, isDraggingError && styles.isDraggingError, (hasUnacceptedItems || errors.length > 0) && styles.hasError];
|
|
@@ -176,7 +177,7 @@ var EuiMarkdownEditorDropZone = exports.EuiMarkdownEditorDropZone = function Eui
|
|
|
176
177
|
return (0, _react2.jsx)("div", (0, _extends2.default)({}, rootProps, {
|
|
177
178
|
css: cssStyles,
|
|
178
179
|
className: classes
|
|
179
|
-
}), children, (0, _react2.jsx)(_markdown_editor_footer.EuiMarkdownEditorFooter, {
|
|
180
|
+
}), children, showFooter && (0, _react2.jsx)(_markdown_editor_footer.EuiMarkdownEditorFooter, {
|
|
180
181
|
ref: setEditorFooterRef,
|
|
181
182
|
uiPlugins: uiPlugins,
|
|
182
183
|
openFiles: function openFiles() {
|
|
@@ -223,5 +224,6 @@ EuiMarkdownEditorDropZone.propTypes = {
|
|
|
223
224
|
hasUnacceptedItems: _propTypes.default.bool.isRequired,
|
|
224
225
|
setHasUnacceptedItems: _propTypes.default.func.isRequired,
|
|
225
226
|
setEditorFooterHeight: _propTypes.default.func.isRequired,
|
|
226
|
-
isEditing: _propTypes.default.bool.isRequired
|
|
227
|
+
isEditing: _propTypes.default.bool.isRequired,
|
|
228
|
+
showFooter: _propTypes.default.bool
|
|
227
229
|
};
|
|
@@ -12,18 +12,13 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
12
12
|
var _services = require("../../services");
|
|
13
13
|
var _loading = require("../loading");
|
|
14
14
|
var _button = require("../button");
|
|
15
|
-
var _title = require("../title");
|
|
16
|
-
var _modal = require("../modal");
|
|
17
15
|
var _i18n = require("../i18n");
|
|
18
16
|
var _popover = require("../popover");
|
|
19
17
|
var _text = require("../text");
|
|
20
|
-
var _spacer = require("../spacer");
|
|
21
18
|
var _tool_tip = require("../tool_tip");
|
|
22
|
-
var _horizontal_rule = require("../horizontal_rule");
|
|
23
|
-
var _link = require("../link");
|
|
24
19
|
var _markdown_context = require("./markdown_context");
|
|
25
|
-
var _markdown_logo = _interopRequireDefault(require("./icons/markdown_logo"));
|
|
26
20
|
var _markdown_editor_footer = require("./markdown_editor_footer.styles");
|
|
21
|
+
var _markdown_editor_help_button = require("./markdown_editor_help_button");
|
|
27
22
|
var _react2 = require("@emotion/react");
|
|
28
23
|
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); }
|
|
29
24
|
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; }
|
|
@@ -35,8 +30,6 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
35
30
|
* Side Public License, v 1.
|
|
36
31
|
*/
|
|
37
32
|
|
|
38
|
-
// @ts-ignore a react svg
|
|
39
|
-
|
|
40
33
|
var EuiMarkdownEditorFooter = exports.EuiMarkdownEditorFooter = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
41
34
|
var uiPlugins = props.uiPlugins,
|
|
42
35
|
isUploadingFiles = props.isUploadingFiles,
|
|
@@ -47,16 +40,8 @@ var EuiMarkdownEditorFooter = exports.EuiMarkdownEditorFooter = /*#__PURE__*/(0,
|
|
|
47
40
|
var styles = (0, _services.useEuiMemoizedStyles)(_markdown_editor_footer.euiMarkdownEditorFooterStyles);
|
|
48
41
|
var _useState = (0, _react.useState)(false),
|
|
49
42
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var _useState3 = (0, _react.useState)(false),
|
|
53
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
54
|
-
isShowingHelpPopover = _useState4[0],
|
|
55
|
-
setIsShowingHelpPopover = _useState4[1];
|
|
56
|
-
var _useState5 = (0, _react.useState)(false),
|
|
57
|
-
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
58
|
-
isPopoverOpen = _useState6[0],
|
|
59
|
-
setIsPopoverOpen = _useState6[1];
|
|
43
|
+
isPopoverOpen = _useState2[0],
|
|
44
|
+
setIsPopoverOpen = _useState2[1];
|
|
60
45
|
var onButtonClick = function onButtonClick() {
|
|
61
46
|
return setIsPopoverOpen(function (isPopoverOpen) {
|
|
62
47
|
return !isPopoverOpen;
|
|
@@ -79,13 +64,10 @@ var EuiMarkdownEditorFooter = exports.EuiMarkdownEditorFooter = /*#__PURE__*/(0,
|
|
|
79
64
|
supportedFileTypes: (0, _i18n.useEuiI18n)('euiMarkdownEditorFooter.supportedFileTypes', 'Supported files: {supportedFileTypes}', {
|
|
80
65
|
supportedFileTypes: supportedFileTypes
|
|
81
66
|
}),
|
|
82
|
-
showSyntaxErrors: (0, _i18n.useEuiI18n)('euiMarkdownEditorFooter.showSyntaxErrors', 'Show errors')
|
|
83
|
-
showMarkdownHelp: (0, _i18n.useEuiI18n)('euiMarkdownEditorFooter.showMarkdownHelp', 'Show markdown help')
|
|
67
|
+
showSyntaxErrors: (0, _i18n.useEuiI18n)('euiMarkdownEditorFooter.showSyntaxErrors', 'Show errors')
|
|
84
68
|
};
|
|
85
|
-
var syntaxTitle = (0, _i18n.useEuiI18n)('euiMarkdownEditorFooter.syntaxTitle', 'Syntax help');
|
|
86
69
|
var _useContext = (0, _react.useContext)(_markdown_context.EuiMarkdownContext),
|
|
87
70
|
readOnly = _useContext.readOnly;
|
|
88
|
-
var helpModalTitleId = (0, _services.useGeneratedHtmlId)();
|
|
89
71
|
if (isUploadingFiles) {
|
|
90
72
|
uploadButton = (0, _react2.jsx)(_button.EuiButtonIcon, {
|
|
91
73
|
size: "s",
|
|
@@ -145,108 +127,17 @@ var EuiMarkdownEditorFooter = exports.EuiMarkdownEditorFooter = /*#__PURE__*/(0,
|
|
|
145
127
|
}, message.toString());
|
|
146
128
|
})));
|
|
147
129
|
}
|
|
148
|
-
var uiPluginsWithHelpText = uiPlugins.filter(function (_ref2) {
|
|
149
|
-
var helpText = _ref2.helpText;
|
|
150
|
-
return !!helpText;
|
|
151
|
-
});
|
|
152
|
-
var hasUiPluginsWithHelpText = uiPluginsWithHelpText.length > 0;
|
|
153
|
-
var mdSyntaxHref = 'https://guides.github.com/features/mastering-markdown/';
|
|
154
|
-
var mdSyntaxLink = (0, _react2.jsx)(_link.EuiLink, {
|
|
155
|
-
href: mdSyntaxHref,
|
|
156
|
-
target: "_blank"
|
|
157
|
-
}, (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
158
|
-
token: "euiMarkdownEditorFooter.mdSyntaxLink",
|
|
159
|
-
default: "GitHub flavored markdown"
|
|
160
|
-
}));
|
|
161
|
-
var helpSyntaxButton;
|
|
162
|
-
if (hasUiPluginsWithHelpText) {
|
|
163
|
-
helpSyntaxButton = (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_tool_tip.EuiToolTip, {
|
|
164
|
-
content: syntaxTitle
|
|
165
|
-
}, (0, _react2.jsx)(_button.EuiButtonIcon, {
|
|
166
|
-
size: "s",
|
|
167
|
-
css: styles.euiMarkdownEditorFooter__helpButton,
|
|
168
|
-
className: "euiMarkdownEditorFooter__helpButton",
|
|
169
|
-
iconType: _markdown_logo.default,
|
|
170
|
-
color: "text",
|
|
171
|
-
"aria-label": ariaLabels.showMarkdownHelp,
|
|
172
|
-
onClick: function onClick() {
|
|
173
|
-
return setIsShowingHelpModal(!isShowingHelpModal);
|
|
174
|
-
},
|
|
175
|
-
isDisabled: readOnly
|
|
176
|
-
})), isShowingHelpModal && (0, _react2.jsx)(_modal.EuiModal, {
|
|
177
|
-
onClose: function onClose() {
|
|
178
|
-
return setIsShowingHelpModal(false);
|
|
179
|
-
},
|
|
180
|
-
"aria-labelledby": helpModalTitleId
|
|
181
|
-
}, (0, _react2.jsx)(_modal.EuiModalHeader, null, (0, _react2.jsx)(_title.EuiTitle, null, (0, _react2.jsx)("h1", {
|
|
182
|
-
id: helpModalTitleId
|
|
183
|
-
}, syntaxTitle))), (0, _react2.jsx)(_modal.EuiModalBody, null, (0, _react2.jsx)(_text.EuiText, null, (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
184
|
-
tokens: ['euiMarkdownEditorFooter.syntaxModalDescriptionPrefix', 'euiMarkdownEditorFooter.syntaxModalDescriptionSuffix'],
|
|
185
|
-
defaults: ['This editor uses', 'You can also utilize these additional syntax plugins to add rich content to your text.']
|
|
186
|
-
}, function (_ref3) {
|
|
187
|
-
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
188
|
-
syntaxModalDescriptionPrefix = _ref4[0],
|
|
189
|
-
syntaxModalDescriptionSuffix = _ref4[1];
|
|
190
|
-
return (0, _react2.jsx)("p", null, syntaxModalDescriptionPrefix, " ", mdSyntaxLink, ".", ' ', syntaxModalDescriptionSuffix);
|
|
191
|
-
})), (0, _react2.jsx)(_horizontal_rule.EuiHorizontalRule, null), uiPluginsWithHelpText.map(function (_ref5) {
|
|
192
|
-
var name = _ref5.name,
|
|
193
|
-
helpText = _ref5.helpText;
|
|
194
|
-
return (0, _react2.jsx)(_react.Fragment, {
|
|
195
|
-
key: name
|
|
196
|
-
}, (0, _react2.jsx)(_title.EuiTitle, {
|
|
197
|
-
size: "xxs"
|
|
198
|
-
}, (0, _react2.jsx)("p", null, (0, _react2.jsx)("strong", null, name))), (0, _react2.jsx)(_spacer.EuiSpacer, {
|
|
199
|
-
size: "s"
|
|
200
|
-
}), helpText, (0, _react2.jsx)(_spacer.EuiSpacer, {
|
|
201
|
-
size: "l"
|
|
202
|
-
}));
|
|
203
|
-
}), (0, _react2.jsx)(_horizontal_rule.EuiHorizontalRule, null)), (0, _react2.jsx)(_modal.EuiModalFooter, null, (0, _react2.jsx)(_button.EuiButton, {
|
|
204
|
-
onClick: function onClick() {
|
|
205
|
-
return setIsShowingHelpModal(false);
|
|
206
|
-
},
|
|
207
|
-
fill: true
|
|
208
|
-
}, (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
209
|
-
token: "euiMarkdownEditorFooter.closeButton",
|
|
210
|
-
default: "Close"
|
|
211
|
-
})))));
|
|
212
|
-
} else {
|
|
213
|
-
helpSyntaxButton = (0, _react2.jsx)(_popover.EuiPopover, {
|
|
214
|
-
button: (0, _react2.jsx)(_button.EuiButtonIcon, {
|
|
215
|
-
title: syntaxTitle,
|
|
216
|
-
size: "s",
|
|
217
|
-
css: styles.euiMarkdownEditorFooter__helpButton,
|
|
218
|
-
className: "euiMarkdownEditorFooter__helpButton",
|
|
219
|
-
iconType: _markdown_logo.default,
|
|
220
|
-
color: "text",
|
|
221
|
-
"aria-label": ariaLabels.showMarkdownHelp,
|
|
222
|
-
onClick: function onClick() {
|
|
223
|
-
return setIsShowingHelpPopover(!isShowingHelpPopover);
|
|
224
|
-
}
|
|
225
|
-
}),
|
|
226
|
-
isOpen: isShowingHelpPopover,
|
|
227
|
-
closePopover: function closePopover() {
|
|
228
|
-
return setIsShowingHelpPopover(false);
|
|
229
|
-
},
|
|
230
|
-
panelPaddingSize: "s",
|
|
231
|
-
anchorPosition: "upCenter",
|
|
232
|
-
"aria-labelledby": helpModalTitleId
|
|
233
|
-
}, (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
234
|
-
tokens: ['euiMarkdownEditorFooter.syntaxPopoverDescription'],
|
|
235
|
-
defaults: ['This editor uses']
|
|
236
|
-
}, function (_ref6) {
|
|
237
|
-
var _ref7 = (0, _slicedToArray2.default)(_ref6, 1),
|
|
238
|
-
syntaxPopoverDescription = _ref7[0];
|
|
239
|
-
return (0, _react2.jsx)("p", null, syntaxPopoverDescription, " ", mdSyntaxLink, ".");
|
|
240
|
-
}));
|
|
241
|
-
}
|
|
242
130
|
return (0, _react2.jsx)("div", {
|
|
243
131
|
ref: ref,
|
|
244
132
|
css: styles.euiMarkdownEditorFooter,
|
|
245
|
-
className: "euiMarkdownEditorFooter"
|
|
133
|
+
className: "euiMarkdownEditorFooter",
|
|
134
|
+
"data-test-subj": "euiMarkdownEditorFooter"
|
|
246
135
|
}, (0, _react2.jsx)("div", {
|
|
247
136
|
css: styles.euiMarkdownEditorFooter__actions,
|
|
248
137
|
className: "euiMarkdownEditorFooter__actions"
|
|
249
|
-
}, uploadButton, errorsButton),
|
|
138
|
+
}, uploadButton, errorsButton), (0, _react2.jsx)(_markdown_editor_help_button.EuiMarkdownEditorHelpButton, {
|
|
139
|
+
uiPlugins: uiPlugins
|
|
140
|
+
}));
|
|
250
141
|
});
|
|
251
142
|
EuiMarkdownEditorFooter.propTypes = {
|
|
252
143
|
uiPlugins: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
@@ -25,8 +25,6 @@ var euiMarkdownEditorFooterStyles = exports.euiMarkdownEditorFooterStyles = func
|
|
|
25
25
|
euiMarkdownEditorFooter__actions: /*#__PURE__*/(0, _react.css)("flex:1;display:inline-flex;align-items:center;gap:", euiTheme.size.xs, ";;label:euiMarkdownEditorFooter__actions;"),
|
|
26
26
|
// Override default button border radius to match the overall markdown editor
|
|
27
27
|
euiMarkdownEditorFooter__uploadError: /*#__PURE__*/(0, _react.css)("border-radius:", borderRadius, ";;label:euiMarkdownEditorFooter__uploadError;"),
|
|
28
|
-
// Override the default button icon width size
|
|
29
|
-
euiMarkdownEditorFooter__helpButton: /*#__PURE__*/(0, _react.css)(".euiIcon{", (0, _global_styling.logicalCSS)('width', '26px'), ";};label:euiMarkdownEditorFooter__helpButton;"),
|
|
30
28
|
euiMarkdownEditorFooter__popover: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('width', '300px'), ";;label:euiMarkdownEditorFooter__popover;")
|
|
31
29
|
};
|
|
32
30
|
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.EuiMarkdownEditorHelpButton = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _services = require("../../services");
|
|
12
|
+
var _button = require("../button");
|
|
13
|
+
var _title = require("../title");
|
|
14
|
+
var _modal = require("../modal");
|
|
15
|
+
var _i18n = require("../i18n");
|
|
16
|
+
var _popover = require("../popover");
|
|
17
|
+
var _text = require("../text");
|
|
18
|
+
var _spacer = require("../spacer");
|
|
19
|
+
var _tool_tip = require("../tool_tip");
|
|
20
|
+
var _horizontal_rule = require("../horizontal_rule");
|
|
21
|
+
var _link = require("../link");
|
|
22
|
+
var _markdown_context = require("./markdown_context");
|
|
23
|
+
var _markdown_logo = _interopRequireDefault(require("./icons/markdown_logo"));
|
|
24
|
+
var _markdown_editor_help_button = require("./markdown_editor_help_button.styles");
|
|
25
|
+
var _react2 = require("@emotion/react");
|
|
26
|
+
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); }
|
|
27
|
+
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; }
|
|
28
|
+
/*
|
|
29
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
30
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
31
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
32
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
33
|
+
* Side Public License, v 1.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
// @ts-ignore a react svg
|
|
37
|
+
|
|
38
|
+
var mdSyntaxHref = 'https://guides.github.com/features/mastering-markdown/';
|
|
39
|
+
var mdSyntaxLink = (0, _react2.jsx)(_link.EuiLink, {
|
|
40
|
+
href: mdSyntaxHref,
|
|
41
|
+
target: "_blank"
|
|
42
|
+
}, (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
43
|
+
token: "euiMarkdownEditorHelpButton.mdSyntaxLink",
|
|
44
|
+
default: "GitHub flavored markdown"
|
|
45
|
+
}));
|
|
46
|
+
var EuiMarkdownEditorHelpButton = exports.EuiMarkdownEditorHelpButton = function EuiMarkdownEditorHelpButton(_ref) {
|
|
47
|
+
var uiPlugins = _ref.uiPlugins;
|
|
48
|
+
var _useState = (0, _react.useState)(false),
|
|
49
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
50
|
+
isShowingHelpModal = _useState2[0],
|
|
51
|
+
setIsShowingHelpModal = _useState2[1];
|
|
52
|
+
var _useState3 = (0, _react.useState)(false),
|
|
53
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
54
|
+
isShowingHelpPopover = _useState4[0],
|
|
55
|
+
setIsShowingHelpPopover = _useState4[1];
|
|
56
|
+
var _useContext = (0, _react.useContext)(_markdown_context.EuiMarkdownContext),
|
|
57
|
+
readOnly = _useContext.readOnly;
|
|
58
|
+
var styles = (0, _services.useEuiMemoizedStyles)(_markdown_editor_help_button.euiMarkdownEditorHelpButtonStyles);
|
|
59
|
+
var syntaxTitle = (0, _i18n.useEuiI18n)('euiMarkdownEditorHelpButton.syntaxTitle', 'Syntax help');
|
|
60
|
+
var ariaLabels = {
|
|
61
|
+
showMarkdownHelp: (0, _i18n.useEuiI18n)('euiMarkdownEditorHelpButton.showMarkdownHelp', 'Show markdown help')
|
|
62
|
+
};
|
|
63
|
+
var helpModalTitleId = (0, _services.useGeneratedHtmlId)();
|
|
64
|
+
var uiPluginsWithHelpText = uiPlugins.filter(function (_ref2) {
|
|
65
|
+
var helpText = _ref2.helpText;
|
|
66
|
+
return !!helpText;
|
|
67
|
+
});
|
|
68
|
+
var hasUiPluginsWithHelpText = uiPluginsWithHelpText.length > 0;
|
|
69
|
+
if (hasUiPluginsWithHelpText) {
|
|
70
|
+
return (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_tool_tip.EuiToolTip, {
|
|
71
|
+
content: syntaxTitle
|
|
72
|
+
}, (0, _react2.jsx)(_button.EuiButtonIcon, {
|
|
73
|
+
size: "s",
|
|
74
|
+
css: styles.euiMarkdownEditorFooter__helpButton,
|
|
75
|
+
className: "euiMarkdownEditorFooter__helpButton",
|
|
76
|
+
iconType: _markdown_logo.default,
|
|
77
|
+
color: "text",
|
|
78
|
+
"aria-label": ariaLabels.showMarkdownHelp,
|
|
79
|
+
onClick: function onClick() {
|
|
80
|
+
return setIsShowingHelpModal(!isShowingHelpModal);
|
|
81
|
+
},
|
|
82
|
+
isDisabled: readOnly
|
|
83
|
+
})), isShowingHelpModal && (0, _react2.jsx)(_modal.EuiModal, {
|
|
84
|
+
onClose: function onClose() {
|
|
85
|
+
return setIsShowingHelpModal(false);
|
|
86
|
+
},
|
|
87
|
+
"aria-labelledby": helpModalTitleId
|
|
88
|
+
}, (0, _react2.jsx)(_modal.EuiModalHeader, null, (0, _react2.jsx)(_title.EuiTitle, null, (0, _react2.jsx)("h1", {
|
|
89
|
+
id: helpModalTitleId
|
|
90
|
+
}, syntaxTitle))), (0, _react2.jsx)(_modal.EuiModalBody, null, (0, _react2.jsx)(_text.EuiText, null, (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
91
|
+
tokens: ['euiMarkdownEditorHelpButton.syntaxModalDescriptionPrefix', 'euiMarkdownEditorHelpButton.syntaxModalDescriptionSuffix'],
|
|
92
|
+
defaults: ['This editor uses', 'You can also utilize these additional syntax plugins to add rich content to your text.']
|
|
93
|
+
}, function (_ref3) {
|
|
94
|
+
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
95
|
+
syntaxModalDescriptionPrefix = _ref4[0],
|
|
96
|
+
syntaxModalDescriptionSuffix = _ref4[1];
|
|
97
|
+
return (0, _react2.jsx)("p", null, syntaxModalDescriptionPrefix, " ", mdSyntaxLink, ".", ' ', syntaxModalDescriptionSuffix);
|
|
98
|
+
})), (0, _react2.jsx)(_horizontal_rule.EuiHorizontalRule, null), uiPluginsWithHelpText.map(function (_ref5) {
|
|
99
|
+
var name = _ref5.name,
|
|
100
|
+
helpText = _ref5.helpText;
|
|
101
|
+
return (0, _react2.jsx)(_react.Fragment, {
|
|
102
|
+
key: name
|
|
103
|
+
}, (0, _react2.jsx)(_title.EuiTitle, {
|
|
104
|
+
size: "xxs"
|
|
105
|
+
}, (0, _react2.jsx)("p", null, (0, _react2.jsx)("strong", null, name))), (0, _react2.jsx)(_spacer.EuiSpacer, {
|
|
106
|
+
size: "s"
|
|
107
|
+
}), helpText, (0, _react2.jsx)(_spacer.EuiSpacer, {
|
|
108
|
+
size: "l"
|
|
109
|
+
}));
|
|
110
|
+
}), (0, _react2.jsx)(_horizontal_rule.EuiHorizontalRule, null)), (0, _react2.jsx)(_modal.EuiModalFooter, null, (0, _react2.jsx)(_button.EuiButton, {
|
|
111
|
+
onClick: function onClick() {
|
|
112
|
+
return setIsShowingHelpModal(false);
|
|
113
|
+
},
|
|
114
|
+
fill: true
|
|
115
|
+
}, (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
116
|
+
token: "euiMarkdownEditorHelpButton.closeButton",
|
|
117
|
+
default: "Close"
|
|
118
|
+
})))));
|
|
119
|
+
} else {
|
|
120
|
+
return (0, _react2.jsx)(_popover.EuiPopover, {
|
|
121
|
+
button: (0, _react2.jsx)(_button.EuiButtonIcon, {
|
|
122
|
+
title: syntaxTitle,
|
|
123
|
+
size: "s",
|
|
124
|
+
css: styles.euiMarkdownEditorFooter__helpButton,
|
|
125
|
+
className: "euiMarkdownEditorFooter__helpButton",
|
|
126
|
+
iconType: _markdown_logo.default,
|
|
127
|
+
color: "text",
|
|
128
|
+
"aria-label": ariaLabels.showMarkdownHelp,
|
|
129
|
+
onClick: function onClick() {
|
|
130
|
+
return setIsShowingHelpPopover(!isShowingHelpPopover);
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
isOpen: isShowingHelpPopover,
|
|
134
|
+
closePopover: function closePopover() {
|
|
135
|
+
return setIsShowingHelpPopover(false);
|
|
136
|
+
},
|
|
137
|
+
panelPaddingSize: "s",
|
|
138
|
+
anchorPosition: "upCenter",
|
|
139
|
+
"aria-labelledby": helpModalTitleId
|
|
140
|
+
}, (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
141
|
+
tokens: ['euiMarkdownEditorHelpButton.syntaxPopoverDescription'],
|
|
142
|
+
defaults: ['This editor uses']
|
|
143
|
+
}, function (_ref6) {
|
|
144
|
+
var _ref7 = (0, _slicedToArray2.default)(_ref6, 1),
|
|
145
|
+
syntaxPopoverDescription = _ref7[0];
|
|
146
|
+
return (0, _react2.jsx)("p", null, syntaxPopoverDescription, " ", mdSyntaxLink, ".");
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
EuiMarkdownEditorHelpButton.displayName = 'EuiMarkdownEditorHelpButton';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.euiMarkdownEditorHelpButtonStyles = void 0;
|
|
7
|
+
var _react = require("@emotion/react");
|
|
8
|
+
var _global_styling = require("../../global_styling");
|
|
9
|
+
/*
|
|
10
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
11
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
12
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
13
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
14
|
+
* Side Public License, v 1.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
var euiMarkdownEditorHelpButtonStyles = exports.euiMarkdownEditorHelpButtonStyles = function euiMarkdownEditorHelpButtonStyles() {
|
|
18
|
+
return {
|
|
19
|
+
// Override the default button icon width size
|
|
20
|
+
euiMarkdownEditorFooter__helpButton: /*#__PURE__*/(0, _react.css)(".euiIcon{", (0, _global_styling.logicalCSS)('width', '26px'), ";};label:euiMarkdownEditorFooter__helpButton;")
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -101,7 +101,8 @@ var EuiMarkdownEditorToolbar = exports.EuiMarkdownEditorToolbar = /*#__PURE__*/(
|
|
|
101
101
|
viewMode = _ref2.viewMode,
|
|
102
102
|
onClickPreview = _ref2.onClickPreview,
|
|
103
103
|
uiPlugins = _ref2.uiPlugins,
|
|
104
|
-
selectedNode = _ref2.selectedNode
|
|
104
|
+
selectedNode = _ref2.selectedNode,
|
|
105
|
+
right = _ref2.right;
|
|
105
106
|
var _useContext = (0, _react.useContext)(_markdown_context.EuiMarkdownContext),
|
|
106
107
|
openPluginEditor = _useContext.openPluginEditor,
|
|
107
108
|
readOnly = _useContext.readOnly;
|
|
@@ -188,27 +189,11 @@ var EuiMarkdownEditorToolbar = exports.EuiMarkdownEditorToolbar = /*#__PURE__*/(
|
|
|
188
189
|
label: button.label,
|
|
189
190
|
icon: button.iconType
|
|
190
191
|
}));
|
|
191
|
-
})) : null),
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
onClick: onClickPreview,
|
|
197
|
-
isDisabled: readOnly
|
|
198
|
-
}, (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
199
|
-
token: "euiMarkdownEditorToolbar.editor",
|
|
200
|
-
default: "Editor"
|
|
201
|
-
})) : (0, _react2.jsx)(_button.EuiButtonEmpty, {
|
|
202
|
-
"data-test-subj": "markdown_editor_preview_button",
|
|
203
|
-
iconType: "eye",
|
|
204
|
-
color: "text",
|
|
205
|
-
size: "s",
|
|
206
|
-
onClick: onClickPreview,
|
|
207
|
-
isDisabled: readOnly
|
|
208
|
-
}, (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
209
|
-
token: "euiMarkdownEditorToolbar.previewMarkdown",
|
|
210
|
-
default: "Preview"
|
|
211
|
-
})));
|
|
192
|
+
})) : null), right !== null && right !== void 0 ? right : (0, _react2.jsx)(PreviewEditorSwitch, {
|
|
193
|
+
isPreviewing: isPreviewing,
|
|
194
|
+
onClickPreview: onClickPreview,
|
|
195
|
+
readOnly: readOnly
|
|
196
|
+
}));
|
|
212
197
|
});
|
|
213
198
|
EuiMarkdownEditorToolbar.propTypes = {
|
|
214
199
|
className: _propTypes.default.string,
|
|
@@ -241,6 +226,26 @@ EuiMarkdownEditorToolbar.propTypes = {
|
|
|
241
226
|
trimFirst: _propTypes.default.bool
|
|
242
227
|
}),
|
|
243
228
|
editor: _propTypes.default.elementType
|
|
244
|
-
}).isRequired).isRequired
|
|
229
|
+
}).isRequired).isRequired,
|
|
230
|
+
right: _propTypes.default.node
|
|
231
|
+
};
|
|
232
|
+
var PreviewEditorSwitch = function PreviewEditorSwitch(_ref4) {
|
|
233
|
+
var isPreviewing = _ref4.isPreviewing,
|
|
234
|
+
onClickPreview = _ref4.onClickPreview,
|
|
235
|
+
readOnly = _ref4.readOnly;
|
|
236
|
+
return (0, _react2.jsx)(_button.EuiButtonEmpty, {
|
|
237
|
+
iconType: isPreviewing ? 'code' : 'eye',
|
|
238
|
+
color: "text",
|
|
239
|
+
size: "s",
|
|
240
|
+
onClick: onClickPreview,
|
|
241
|
+
isDisabled: readOnly,
|
|
242
|
+
"data-test-subj": isPreviewing ? 'markdown_editor_preview_button' : 'markdown_editor_edit_button'
|
|
243
|
+
}, isPreviewing ? (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
244
|
+
token: "euiMarkdownEditorToolbar.editor",
|
|
245
|
+
default: "Editor"
|
|
246
|
+
}) : (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
247
|
+
token: "euiMarkdownEditorToolbar.previewMarkdown",
|
|
248
|
+
default: "Preview"
|
|
249
|
+
}));
|
|
245
250
|
};
|
|
246
251
|
EuiMarkdownEditorToolbar.displayName = 'EuiMarkdownEditorToolbar';
|
|
@@ -157,7 +157,8 @@ var EuiPopover = exports.EuiPopover = /*#__PURE__*/function (_Component) {
|
|
|
157
157
|
// transition can take effect.
|
|
158
158
|
_this.closingTransitionAnimationFrame = window.requestAnimationFrame(function () {
|
|
159
159
|
_this.setState({
|
|
160
|
-
isOpening: true
|
|
160
|
+
isOpening: true,
|
|
161
|
+
isClosing: false
|
|
161
162
|
});
|
|
162
163
|
});
|
|
163
164
|
|