@dhis2/analytics 23.11.1 → 23.12.2
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/CHANGELOG.md +21 -0
- package/build/cjs/components/Interpretations/InterpretationModal/Comment.js +64 -0
- package/build/cjs/components/Interpretations/InterpretationModal/CommentAddForm.js +93 -0
- package/build/cjs/components/Interpretations/InterpretationModal/CommentDeleteButton.js +62 -0
- package/build/cjs/components/Interpretations/InterpretationModal/CommentUpdateForm.js +95 -0
- package/build/cjs/components/Interpretations/InterpretationModal/InterpretationModal.js +187 -0
- package/build/cjs/components/Interpretations/InterpretationModal/InterpretationThread.js +100 -0
- package/build/cjs/components/Interpretations/InterpretationModal/index.js +13 -0
- package/build/cjs/components/Interpretations/InterpretationModal/useModalContentWidth.js +39 -0
- package/build/cjs/components/Interpretations/InterpretationsUnit/InterpretationForm.js +94 -0
- package/build/cjs/components/Interpretations/InterpretationsUnit/InterpretationList.js +94 -0
- package/build/cjs/components/Interpretations/InterpretationsUnit/InterpretationsUnit.js +135 -0
- package/build/cjs/components/Interpretations/InterpretationsUnit/index.js +13 -0
- package/build/cjs/components/Interpretations/common/Interpretation/Interpretation.js +110 -0
- package/build/cjs/components/Interpretations/common/Interpretation/InterpretationDeleteButton.js +58 -0
- package/build/cjs/components/Interpretations/common/Interpretation/InterpretationSharingLink.js +50 -0
- package/build/cjs/components/Interpretations/common/Interpretation/InterpretationUpdateForm.js +108 -0
- package/build/cjs/components/Interpretations/common/Interpretation/index.js +21 -0
- package/build/cjs/components/Interpretations/common/Interpretation/useLike.js +53 -0
- package/build/cjs/components/Interpretations/common/Message/Message.js +55 -0
- package/build/cjs/components/Interpretations/common/Message/MessageButtonStrip.js +33 -0
- package/build/cjs/components/Interpretations/common/Message/MessageEditorContainer.js +42 -0
- package/build/cjs/components/Interpretations/common/Message/MessageIconButton.js +67 -0
- package/build/cjs/components/Interpretations/common/Message/MessageInput.js +31 -0
- package/build/cjs/components/Interpretations/common/Message/MessageStatsBar.js +33 -0
- package/build/cjs/components/Interpretations/common/Message/index.js +53 -0
- package/build/cjs/components/Interpretations/common/RichTextEditor/RichTextEditor.js +262 -0
- package/build/cjs/components/Interpretations/common/RichTextEditor/index.js +13 -0
- package/build/cjs/components/Interpretations/common/RichTextEditor/markdownHandler.js +148 -0
- package/build/cjs/components/Interpretations/common/RichTextEditor/styles/RichTextEditor.style.js +21 -0
- package/build/cjs/components/Interpretations/common/UserMention/UserList.js +48 -0
- package/build/cjs/components/Interpretations/common/UserMention/UserMentionWrapper.js +226 -0
- package/build/cjs/components/Interpretations/common/UserMention/styles/UserMentionWrapper.style.js +30 -0
- package/build/cjs/components/Interpretations/common/UserMention/useUserSearchResults.js +78 -0
- package/build/cjs/components/Interpretations/common/index.js +44 -0
- package/build/cjs/index.js +16 -0
- package/build/cjs/locales/ar/translations.json +32 -1
- package/build/cjs/locales/ar_EG/translations.json +32 -1
- package/build/cjs/locales/ar_IQ/translations.json +32 -1
- package/build/cjs/locales/ckb/translations.json +32 -1
- package/build/cjs/locales/cs/translations.json +32 -1
- package/build/cjs/locales/da/translations.json +32 -1
- package/build/cjs/locales/en/translations.json +32 -1
- package/build/cjs/locales/es/translations.json +32 -1
- package/build/cjs/locales/fr/translations.json +32 -1
- package/build/cjs/locales/id/translations.json +32 -1
- package/build/cjs/locales/km/translations.json +32 -1
- package/build/cjs/locales/lo/translations.json +32 -1
- package/build/cjs/locales/my/translations.json +32 -1
- package/build/cjs/locales/nb/translations.json +32 -1
- package/build/cjs/locales/nl/translations.json +32 -1
- package/build/cjs/locales/or/translations.json +32 -1
- package/build/cjs/locales/prs/translations.json +32 -1
- package/build/cjs/locales/ps/translations.json +32 -1
- package/build/cjs/locales/pt/translations.json +32 -1
- package/build/cjs/locales/pt_BR/translations.json +32 -1
- package/build/cjs/locales/ro/translations.json +32 -1
- package/build/cjs/locales/ru/translations.json +32 -1
- package/build/cjs/locales/sv/translations.json +32 -1
- package/build/cjs/locales/tet/translations.json +32 -1
- package/build/cjs/locales/tg/translations.json +32 -1
- package/build/cjs/locales/uk/translations.json +32 -1
- package/build/cjs/locales/ur/translations.json +32 -1
- package/build/cjs/locales/uz/translations.json +32 -1
- package/build/cjs/locales/uz_Latn/translations.json +32 -1
- package/build/cjs/locales/vi/translations.json +32 -1
- package/build/cjs/locales/zh/translations.json +32 -1
- package/build/cjs/locales/zh_CN/translations.json +32 -1
- package/build/es/components/Interpretations/InterpretationModal/Comment.js +45 -0
- package/build/es/components/Interpretations/InterpretationModal/CommentAddForm.js +70 -0
- package/build/es/components/Interpretations/InterpretationModal/CommentDeleteButton.js +47 -0
- package/build/es/components/Interpretations/InterpretationModal/CommentUpdateForm.js +73 -0
- package/build/es/components/Interpretations/InterpretationModal/InterpretationModal.js +165 -0
- package/build/es/components/Interpretations/InterpretationModal/InterpretationThread.js +79 -0
- package/build/es/components/Interpretations/InterpretationModal/index.js +1 -0
- package/build/es/components/Interpretations/InterpretationModal/useModalContentWidth.js +28 -0
- package/build/es/components/Interpretations/InterpretationsUnit/InterpretationForm.js +71 -0
- package/build/es/components/Interpretations/InterpretationsUnit/InterpretationList.js +78 -0
- package/build/es/components/Interpretations/InterpretationsUnit/InterpretationsUnit.js +112 -0
- package/build/es/components/Interpretations/InterpretationsUnit/index.js +1 -0
- package/build/es/components/Interpretations/common/Interpretation/Interpretation.js +87 -0
- package/build/es/components/Interpretations/common/Interpretation/InterpretationDeleteButton.js +43 -0
- package/build/es/components/Interpretations/common/Interpretation/InterpretationSharingLink.js +33 -0
- package/build/es/components/Interpretations/common/Interpretation/InterpretationUpdateForm.js +85 -0
- package/build/es/components/Interpretations/common/Interpretation/index.js +2 -0
- package/build/es/components/Interpretations/common/Interpretation/useLike.js +45 -0
- package/build/es/components/Interpretations/common/Message/Message.js +41 -0
- package/build/es/components/Interpretations/common/Message/MessageButtonStrip.js +21 -0
- package/build/es/components/Interpretations/common/Message/MessageEditorContainer.js +30 -0
- package/build/es/components/Interpretations/common/Message/MessageIconButton.js +54 -0
- package/build/es/components/Interpretations/common/Message/MessageInput.js +16 -0
- package/build/es/components/Interpretations/common/Message/MessageStatsBar.js +21 -0
- package/build/es/components/Interpretations/common/Message/index.js +6 -0
- package/build/es/components/Interpretations/common/RichTextEditor/RichTextEditor.js +240 -0
- package/build/es/components/Interpretations/common/RichTextEditor/index.js +1 -0
- package/build/es/components/Interpretations/common/RichTextEditor/markdownHandler.js +128 -0
- package/build/es/components/Interpretations/common/RichTextEditor/styles/RichTextEditor.style.js +9 -0
- package/build/es/components/Interpretations/common/UserMention/UserList.js +33 -0
- package/build/es/components/Interpretations/common/UserMention/UserMentionWrapper.js +202 -0
- package/build/es/components/Interpretations/common/UserMention/styles/UserMentionWrapper.style.js +17 -0
- package/build/es/components/Interpretations/common/UserMention/useUserSearchResults.js +63 -0
- package/build/es/components/Interpretations/common/index.js +3 -0
- package/build/es/index.js +2 -0
- package/build/es/locales/ar/translations.json +32 -1
- package/build/es/locales/ar_EG/translations.json +32 -1
- package/build/es/locales/ar_IQ/translations.json +32 -1
- package/build/es/locales/ckb/translations.json +32 -1
- package/build/es/locales/cs/translations.json +32 -1
- package/build/es/locales/da/translations.json +32 -1
- package/build/es/locales/en/translations.json +32 -1
- package/build/es/locales/es/translations.json +32 -1
- package/build/es/locales/fr/translations.json +32 -1
- package/build/es/locales/id/translations.json +32 -1
- package/build/es/locales/km/translations.json +32 -1
- package/build/es/locales/lo/translations.json +32 -1
- package/build/es/locales/my/translations.json +32 -1
- package/build/es/locales/nb/translations.json +32 -1
- package/build/es/locales/nl/translations.json +32 -1
- package/build/es/locales/or/translations.json +32 -1
- package/build/es/locales/prs/translations.json +32 -1
- package/build/es/locales/ps/translations.json +32 -1
- package/build/es/locales/pt/translations.json +32 -1
- package/build/es/locales/pt_BR/translations.json +32 -1
- package/build/es/locales/ro/translations.json +32 -1
- package/build/es/locales/ru/translations.json +32 -1
- package/build/es/locales/sv/translations.json +32 -1
- package/build/es/locales/tet/translations.json +32 -1
- package/build/es/locales/tg/translations.json +32 -1
- package/build/es/locales/uk/translations.json +32 -1
- package/build/es/locales/ur/translations.json +32 -1
- package/build/es/locales/uz/translations.json +32 -1
- package/build/es/locales/uz_Latn/translations.json +32 -1
- package/build/es/locales/vi/translations.json +32 -1
- package/build/es/locales/zh/translations.json +32 -1
- package/build/es/locales/zh_CN/translations.json +32 -1
- package/package.json +2 -1
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RichTextEditor = void 0;
|
|
7
|
+
|
|
8
|
+
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
+
|
|
10
|
+
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
11
|
+
|
|
12
|
+
var _d2UiRichText = require("@dhis2/d2-ui-rich-text");
|
|
13
|
+
|
|
14
|
+
var _ui = require("@dhis2/ui");
|
|
15
|
+
|
|
16
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
+
|
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
+
|
|
20
|
+
var _UserMentionWrapper = require("../UserMention/UserMentionWrapper.js");
|
|
21
|
+
|
|
22
|
+
var _markdownHandler = require("./markdownHandler.js");
|
|
23
|
+
|
|
24
|
+
var _RichTextEditorStyle = require("./styles/RichTextEditor.style.js");
|
|
25
|
+
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
|
|
32
|
+
const EmojisPopover = _ref => {
|
|
33
|
+
let {
|
|
34
|
+
onInsertMarkdown,
|
|
35
|
+
onClose,
|
|
36
|
+
reference
|
|
37
|
+
} = _ref;
|
|
38
|
+
return /*#__PURE__*/_react.default.createElement(_ui.Popover, {
|
|
39
|
+
reference: reference,
|
|
40
|
+
onClickOutside: onClose
|
|
41
|
+
}, /*#__PURE__*/_react.default.createElement("ul", {
|
|
42
|
+
className: "jsx-".concat(_RichTextEditorStyle.emojisPopoverClasses.__hash) + " " + "emojisList"
|
|
43
|
+
}, /*#__PURE__*/_react.default.createElement("li", {
|
|
44
|
+
onClick: () => onInsertMarkdown(_markdownHandler.EMOJI_SMILEY_FACE),
|
|
45
|
+
className: "jsx-".concat(_RichTextEditorStyle.emojisPopoverClasses.__hash)
|
|
46
|
+
}, /*#__PURE__*/_react.default.createElement(_d2UiRichText.Parser, null, _markdownHandler.emojis[_markdownHandler.EMOJI_SMILEY_FACE])), /*#__PURE__*/_react.default.createElement("li", {
|
|
47
|
+
onClick: () => onInsertMarkdown(_markdownHandler.EMOJI_SAD_FACE),
|
|
48
|
+
className: "jsx-".concat(_RichTextEditorStyle.emojisPopoverClasses.__hash)
|
|
49
|
+
}, /*#__PURE__*/_react.default.createElement(_d2UiRichText.Parser, null, _markdownHandler.emojis[_markdownHandler.EMOJI_SAD_FACE])), /*#__PURE__*/_react.default.createElement("li", {
|
|
50
|
+
onClick: () => onInsertMarkdown(_markdownHandler.EMOJI_THUMBS_UP),
|
|
51
|
+
className: "jsx-".concat(_RichTextEditorStyle.emojisPopoverClasses.__hash)
|
|
52
|
+
}, /*#__PURE__*/_react.default.createElement(_d2UiRichText.Parser, null, _markdownHandler.emojis[_markdownHandler.EMOJI_THUMBS_UP])), /*#__PURE__*/_react.default.createElement("li", {
|
|
53
|
+
onClick: () => onInsertMarkdown(_markdownHandler.EMOJI_THUMBS_DOWN),
|
|
54
|
+
className: "jsx-".concat(_RichTextEditorStyle.emojisPopoverClasses.__hash)
|
|
55
|
+
}, /*#__PURE__*/_react.default.createElement(_d2UiRichText.Parser, null, _markdownHandler.emojis[_markdownHandler.EMOJI_THUMBS_DOWN]))), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
56
|
+
id: _RichTextEditorStyle.emojisPopoverClasses.__hash
|
|
57
|
+
}, _RichTextEditorStyle.emojisPopoverClasses));
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
EmojisPopover.propTypes = {
|
|
61
|
+
onClose: _propTypes.default.func.isRequired,
|
|
62
|
+
onInsertMarkdown: _propTypes.default.func.isRequired,
|
|
63
|
+
reference: _propTypes.default.object
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const IconButtonWithTooltip = _ref2 => {
|
|
67
|
+
let {
|
|
68
|
+
tooltipContent,
|
|
69
|
+
disabled,
|
|
70
|
+
icon,
|
|
71
|
+
onClick
|
|
72
|
+
} = _ref2;
|
|
73
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ui.Tooltip, {
|
|
74
|
+
content: tooltipContent,
|
|
75
|
+
placement: "bottom",
|
|
76
|
+
closeDelay: 200
|
|
77
|
+
}, _ref3 => {
|
|
78
|
+
let {
|
|
79
|
+
ref,
|
|
80
|
+
onMouseOver,
|
|
81
|
+
onMouseOut
|
|
82
|
+
} = _ref3;
|
|
83
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
84
|
+
ref: ref,
|
|
85
|
+
onMouseOver: onMouseOver,
|
|
86
|
+
onMouseOut: onMouseOut,
|
|
87
|
+
className: "jsx-".concat(_RichTextEditorStyle.tooltipAnchorClasses.__hash) + " " + "tooltip"
|
|
88
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
89
|
+
secondary: true,
|
|
90
|
+
small: true,
|
|
91
|
+
disabled: disabled,
|
|
92
|
+
icon: icon,
|
|
93
|
+
onClick: onClick
|
|
94
|
+
}));
|
|
95
|
+
}), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
96
|
+
id: _RichTextEditorStyle.tooltipAnchorClasses.__hash
|
|
97
|
+
}, _RichTextEditorStyle.tooltipAnchorClasses));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
IconButtonWithTooltip.propTypes = {
|
|
101
|
+
disabled: _propTypes.default.bool,
|
|
102
|
+
icon: _propTypes.default.node,
|
|
103
|
+
tooltipContent: _propTypes.default.string,
|
|
104
|
+
onClick: _propTypes.default.func
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const Toolbar = _ref4 => {
|
|
108
|
+
let {
|
|
109
|
+
disabled,
|
|
110
|
+
onInsertMarkdown,
|
|
111
|
+
onTogglePreview,
|
|
112
|
+
previewButtonDisabled,
|
|
113
|
+
previewMode
|
|
114
|
+
} = _ref4;
|
|
115
|
+
const emojisButtonRef = (0, _react.useRef)();
|
|
116
|
+
const [emojisPopoverIsOpen, setEmojisPopoverIsOpen] = (0, _react.useState)(false);
|
|
117
|
+
const iconColor = disabled ? _ui.colors.grey600 : _ui.colors.grey700;
|
|
118
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
119
|
+
className: "jsx-".concat(_RichTextEditorStyle.tooltipAnchorClasses.__hash, " jsx-").concat(_RichTextEditorStyle.toolbarClasses.__hash) + " " + "toolbar"
|
|
120
|
+
}, !previewMode ? /*#__PURE__*/_react.default.createElement("div", {
|
|
121
|
+
className: "jsx-".concat(_RichTextEditorStyle.tooltipAnchorClasses.__hash, " jsx-").concat(_RichTextEditorStyle.toolbarClasses.__hash) + " " + "actionsWrapper"
|
|
122
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
123
|
+
className: "jsx-".concat(_RichTextEditorStyle.tooltipAnchorClasses.__hash, " jsx-").concat(_RichTextEditorStyle.toolbarClasses.__hash) + " " + "mainActions"
|
|
124
|
+
}, /*#__PURE__*/_react.default.createElement(IconButtonWithTooltip, {
|
|
125
|
+
tooltipContent: _d2I18n.default.t('Bold text'),
|
|
126
|
+
disabled: disabled,
|
|
127
|
+
icon: /*#__PURE__*/_react.default.createElement(_ui.IconTextBold24, {
|
|
128
|
+
color: iconColor
|
|
129
|
+
}),
|
|
130
|
+
onClick: () => onInsertMarkdown(_markdownHandler.BOLD)
|
|
131
|
+
}), /*#__PURE__*/_react.default.createElement(IconButtonWithTooltip, {
|
|
132
|
+
tooltipContent: _d2I18n.default.t('Italic text'),
|
|
133
|
+
disabled: disabled,
|
|
134
|
+
icon: /*#__PURE__*/_react.default.createElement(_ui.IconTextItalic24, {
|
|
135
|
+
color: iconColor
|
|
136
|
+
}),
|
|
137
|
+
onClick: () => onInsertMarkdown(_markdownHandler.ITALIC)
|
|
138
|
+
}), /*#__PURE__*/_react.default.createElement(IconButtonWithTooltip, {
|
|
139
|
+
tooltipContent: _d2I18n.default.t('Link to a URL'),
|
|
140
|
+
disabled: disabled,
|
|
141
|
+
icon: /*#__PURE__*/_react.default.createElement(_ui.IconLink24, {
|
|
142
|
+
color: iconColor
|
|
143
|
+
}),
|
|
144
|
+
onClick: () => onInsertMarkdown(_markdownHandler.LINK)
|
|
145
|
+
}), /*#__PURE__*/_react.default.createElement(IconButtonWithTooltip, {
|
|
146
|
+
tooltipContent: _d2I18n.default.t('Mention a user'),
|
|
147
|
+
disabled: disabled,
|
|
148
|
+
icon: /*#__PURE__*/_react.default.createElement(_ui.IconAt24, {
|
|
149
|
+
color: iconColor
|
|
150
|
+
}),
|
|
151
|
+
onClick: () => onInsertMarkdown(_markdownHandler.MENTION)
|
|
152
|
+
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
153
|
+
ref: emojisButtonRef,
|
|
154
|
+
className: "jsx-".concat(_RichTextEditorStyle.tooltipAnchorClasses.__hash, " jsx-").concat(_RichTextEditorStyle.toolbarClasses.__hash) + " " + "tooltip"
|
|
155
|
+
}, /*#__PURE__*/_react.default.createElement(IconButtonWithTooltip, {
|
|
156
|
+
tooltipContent: _d2I18n.default.t('Add emoji'),
|
|
157
|
+
disabled: disabled,
|
|
158
|
+
icon: /*#__PURE__*/_react.default.createElement(_ui.IconFaceAdd24, {
|
|
159
|
+
color: iconColor
|
|
160
|
+
}),
|
|
161
|
+
onClick: () => setEmojisPopoverIsOpen(true)
|
|
162
|
+
})), emojisPopoverIsOpen && /*#__PURE__*/_react.default.createElement(EmojisPopover, {
|
|
163
|
+
onClose: () => setEmojisPopoverIsOpen(false),
|
|
164
|
+
onInsertMarkdown: markup => {
|
|
165
|
+
onInsertMarkdown(markup);
|
|
166
|
+
setEmojisPopoverIsOpen(false);
|
|
167
|
+
},
|
|
168
|
+
reference: emojisButtonRef
|
|
169
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
170
|
+
className: "jsx-".concat(_RichTextEditorStyle.tooltipAnchorClasses.__hash, " jsx-").concat(_RichTextEditorStyle.toolbarClasses.__hash) + " " + "sideActions"
|
|
171
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
172
|
+
secondary: true,
|
|
173
|
+
small: true,
|
|
174
|
+
disabled: previewButtonDisabled || disabled,
|
|
175
|
+
onClick: onTogglePreview
|
|
176
|
+
}, _d2I18n.default.t('Preview')))) : /*#__PURE__*/_react.default.createElement("div", {
|
|
177
|
+
className: "jsx-".concat(_RichTextEditorStyle.tooltipAnchorClasses.__hash, " jsx-").concat(_RichTextEditorStyle.toolbarClasses.__hash) + " " + "previewWrapper"
|
|
178
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
179
|
+
secondary: true,
|
|
180
|
+
small: true,
|
|
181
|
+
onClick: onTogglePreview,
|
|
182
|
+
disabled: disabled
|
|
183
|
+
}, _d2I18n.default.t('Back to write mode'))), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
184
|
+
id: _RichTextEditorStyle.tooltipAnchorClasses.__hash
|
|
185
|
+
}, _RichTextEditorStyle.tooltipAnchorClasses), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
186
|
+
id: _RichTextEditorStyle.toolbarClasses.__hash
|
|
187
|
+
}, _RichTextEditorStyle.toolbarClasses));
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
Toolbar.propTypes = {
|
|
191
|
+
previewButtonDisabled: _propTypes.default.bool.isRequired,
|
|
192
|
+
previewMode: _propTypes.default.bool.isRequired,
|
|
193
|
+
onInsertMarkdown: _propTypes.default.func.isRequired,
|
|
194
|
+
onTogglePreview: _propTypes.default.func.isRequired,
|
|
195
|
+
disabled: _propTypes.default.bool
|
|
196
|
+
};
|
|
197
|
+
const RichTextEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref5, externalRef) => {
|
|
198
|
+
let {
|
|
199
|
+
value,
|
|
200
|
+
disabled,
|
|
201
|
+
inputPlaceholder,
|
|
202
|
+
onChange,
|
|
203
|
+
errorText
|
|
204
|
+
} = _ref5;
|
|
205
|
+
const [previewMode, setPreviewMode] = (0, _react.useState)(false);
|
|
206
|
+
const internalRef = (0, _react.useRef)();
|
|
207
|
+
const textareaRef = externalRef || internalRef;
|
|
208
|
+
(0, _react.useEffect)(() => {
|
|
209
|
+
var _textareaRef$current;
|
|
210
|
+
|
|
211
|
+
return (_textareaRef$current = textareaRef.current) === null || _textareaRef$current === void 0 ? void 0 : _textareaRef$current.focus();
|
|
212
|
+
}, [textareaRef.current]);
|
|
213
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
214
|
+
className: "jsx-".concat(_RichTextEditorStyle.mainClasses.__hash) + " " + "container"
|
|
215
|
+
}, /*#__PURE__*/_react.default.createElement(Toolbar, {
|
|
216
|
+
onInsertMarkdown: markdown => {
|
|
217
|
+
(0, _markdownHandler.insertMarkdown)(markdown, textareaRef.current, (text, caretPos) => {
|
|
218
|
+
onChange(text);
|
|
219
|
+
textareaRef.current.focus();
|
|
220
|
+
textareaRef.current.selectionEnd = caretPos;
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
if (markdown === _markdownHandler.MENTION) {
|
|
224
|
+
textareaRef.current.dispatchEvent(new KeyboardEvent('keydown', {
|
|
225
|
+
key: '@',
|
|
226
|
+
bubbles: true
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
onTogglePreview: () => setPreviewMode(!previewMode),
|
|
231
|
+
previewMode: previewMode,
|
|
232
|
+
previewButtonDisabled: !value,
|
|
233
|
+
disabled: disabled
|
|
234
|
+
}), previewMode ? /*#__PURE__*/_react.default.createElement("div", {
|
|
235
|
+
className: "jsx-".concat(_RichTextEditorStyle.mainClasses.__hash) + " " + "preview"
|
|
236
|
+
}, /*#__PURE__*/_react.default.createElement(_d2UiRichText.Parser, null, value)) : /*#__PURE__*/_react.default.createElement(_ui.Field, {
|
|
237
|
+
error: !!errorText,
|
|
238
|
+
validationText: errorText
|
|
239
|
+
}, /*#__PURE__*/_react.default.createElement(_UserMentionWrapper.UserMentionWrapper, {
|
|
240
|
+
onUserSelect: onChange,
|
|
241
|
+
inputReference: textareaRef
|
|
242
|
+
}, /*#__PURE__*/_react.default.createElement("textarea", {
|
|
243
|
+
ref: textareaRef,
|
|
244
|
+
placeholder: inputPlaceholder,
|
|
245
|
+
disabled: disabled,
|
|
246
|
+
value: value,
|
|
247
|
+
onChange: event => onChange(event.target.value),
|
|
248
|
+
onKeyDown: event => (0, _markdownHandler.convertCtrlKey)(event, onChange),
|
|
249
|
+
className: "jsx-".concat(_RichTextEditorStyle.mainClasses.__hash) + " " + "textarea"
|
|
250
|
+
}))), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
251
|
+
id: _RichTextEditorStyle.mainClasses.__hash
|
|
252
|
+
}, _RichTextEditorStyle.mainClasses));
|
|
253
|
+
});
|
|
254
|
+
exports.RichTextEditor = RichTextEditor;
|
|
255
|
+
RichTextEditor.displayName = 'RichTextEditor';
|
|
256
|
+
RichTextEditor.propTypes = {
|
|
257
|
+
value: _propTypes.default.string.isRequired,
|
|
258
|
+
onChange: _propTypes.default.func.isRequired,
|
|
259
|
+
disabled: _propTypes.default.bool,
|
|
260
|
+
errorText: _propTypes.default.string,
|
|
261
|
+
inputPlaceholder: _propTypes.default.string
|
|
262
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "RichTextEditor", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _RichTextEditor.RichTextEditor;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _RichTextEditor = require("./RichTextEditor.js");
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.insertMarkdown = exports.emojis = exports.convertCtrlKey = exports.MENTION = exports.LINK = exports.ITALIC = exports.EMOJI_THUMBS_UP = exports.EMOJI_THUMBS_DOWN = exports.EMOJI_SMILEY_FACE = exports.EMOJI_SAD_FACE = exports.BOLD = void 0;
|
|
7
|
+
const BOLD = 'bold';
|
|
8
|
+
exports.BOLD = BOLD;
|
|
9
|
+
const ITALIC = 'italic';
|
|
10
|
+
exports.ITALIC = ITALIC;
|
|
11
|
+
const LINK = 'link';
|
|
12
|
+
exports.LINK = LINK;
|
|
13
|
+
const MENTION = 'mention';
|
|
14
|
+
exports.MENTION = MENTION;
|
|
15
|
+
const EMOJI_SMILEY_FACE = 'smileyFace';
|
|
16
|
+
exports.EMOJI_SMILEY_FACE = EMOJI_SMILEY_FACE;
|
|
17
|
+
const EMOJI_SAD_FACE = 'sadFace';
|
|
18
|
+
exports.EMOJI_SAD_FACE = EMOJI_SAD_FACE;
|
|
19
|
+
const EMOJI_THUMBS_UP = 'thumbsUp';
|
|
20
|
+
exports.EMOJI_THUMBS_UP = EMOJI_THUMBS_UP;
|
|
21
|
+
const EMOJI_THUMBS_DOWN = 'thumsDown';
|
|
22
|
+
exports.EMOJI_THUMBS_DOWN = EMOJI_THUMBS_DOWN;
|
|
23
|
+
const emojis = {
|
|
24
|
+
[EMOJI_SMILEY_FACE]: ':-)',
|
|
25
|
+
[EMOJI_SAD_FACE]: ':-(',
|
|
26
|
+
[EMOJI_THUMBS_UP]: ':+1',
|
|
27
|
+
[EMOJI_THUMBS_DOWN]: ':-1'
|
|
28
|
+
};
|
|
29
|
+
exports.emojis = emojis;
|
|
30
|
+
const markdownMap = {
|
|
31
|
+
[ITALIC]: {
|
|
32
|
+
prefix: '_',
|
|
33
|
+
postfix: '_'
|
|
34
|
+
},
|
|
35
|
+
[BOLD]: {
|
|
36
|
+
prefix: '*',
|
|
37
|
+
postfix: '*'
|
|
38
|
+
},
|
|
39
|
+
[LINK]: {
|
|
40
|
+
prefix: '[',
|
|
41
|
+
postfix: '](https://link-url)'
|
|
42
|
+
},
|
|
43
|
+
[MENTION]: {
|
|
44
|
+
prefix: '@'
|
|
45
|
+
},
|
|
46
|
+
[EMOJI_SMILEY_FACE]: {
|
|
47
|
+
prefix: emojis[EMOJI_SMILEY_FACE]
|
|
48
|
+
},
|
|
49
|
+
[EMOJI_SAD_FACE]: {
|
|
50
|
+
prefix: emojis[EMOJI_SAD_FACE]
|
|
51
|
+
},
|
|
52
|
+
[EMOJI_THUMBS_UP]: {
|
|
53
|
+
prefix: emojis[EMOJI_THUMBS_UP]
|
|
54
|
+
},
|
|
55
|
+
[EMOJI_THUMBS_DOWN]: {
|
|
56
|
+
prefix: emojis[EMOJI_THUMBS_DOWN]
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const trim = str => {
|
|
61
|
+
const leftSpaces = /^\s+/;
|
|
62
|
+
const rightSpaces = /\s+$/;
|
|
63
|
+
return str.replace(leftSpaces, '').replace(rightSpaces, '');
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const insertMarkdown = (markdown, target, cb) => {
|
|
67
|
+
const {
|
|
68
|
+
selectionStart: start,
|
|
69
|
+
selectionEnd: end,
|
|
70
|
+
value
|
|
71
|
+
} = target;
|
|
72
|
+
const marker = markdownMap[markdown] || null;
|
|
73
|
+
|
|
74
|
+
if (!marker || !cb || start < 0) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let newValue;
|
|
79
|
+
let caretPos = end + 1;
|
|
80
|
+
|
|
81
|
+
const padMarkers = text => {
|
|
82
|
+
// is caret between two markers (i.e., "**" or "__")? Then do not add padding
|
|
83
|
+
if (start === end && value.length && start > 0) {
|
|
84
|
+
if (value[start - 1] === markdownMap[BOLD].prefix && value[start] === markdownMap[BOLD].prefix || value[start - 1] === markdownMap[ITALIC].prefix && value[start] === markdownMap[ITALIC].prefix) {
|
|
85
|
+
return text;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (value.length && start > 0 && value[start - 1] !== ' ') {
|
|
90
|
+
text = " ".concat(text);
|
|
91
|
+
++caretPos;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (value.length && end !== value.length && value[end] !== ' ') {
|
|
95
|
+
text = "".concat(text, " ");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return text;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
if (start === end) {
|
|
102
|
+
//no text
|
|
103
|
+
const valueArr = value.split('');
|
|
104
|
+
let markdown = marker.prefix;
|
|
105
|
+
|
|
106
|
+
if (marker.postfix) {
|
|
107
|
+
markdown += marker.postfix;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
valueArr.splice(start, 0, padMarkers(markdown));
|
|
111
|
+
newValue = valueArr.join('');
|
|
112
|
+
} else {
|
|
113
|
+
const text = value.slice(start, end);
|
|
114
|
+
const trimmedText = trim(text); // TODO really needed?
|
|
115
|
+
// adjust caretPos based on trimmed text selection
|
|
116
|
+
|
|
117
|
+
caretPos = caretPos - (text.length - trimmedText.length) + 1;
|
|
118
|
+
let markdown = "".concat(marker.prefix).concat(trimmedText);
|
|
119
|
+
|
|
120
|
+
if (marker.postfix) {
|
|
121
|
+
markdown += marker.postfix;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
newValue = [value.slice(0, start), padMarkers(markdown), value.slice(end)].join('');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
cb(newValue, caretPos);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
exports.insertMarkdown = insertMarkdown;
|
|
131
|
+
|
|
132
|
+
const convertCtrlKey = (event, cb) => {
|
|
133
|
+
const {
|
|
134
|
+
key,
|
|
135
|
+
ctrlKey,
|
|
136
|
+
metaKey
|
|
137
|
+
} = event;
|
|
138
|
+
|
|
139
|
+
if (key === 'b' && (ctrlKey || metaKey)) {
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
insertMarkdown(BOLD, event.target, cb);
|
|
142
|
+
} else if (key === 'i' && (ctrlKey || metaKey)) {
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
insertMarkdown(ITALIC, event.target, cb);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
exports.convertCtrlKey = convertCtrlKey;
|
package/build/cjs/components/Interpretations/common/RichTextEditor/styles/RichTextEditor.style.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.tooltipAnchorClasses = exports.toolbarClasses = exports.mainClasses = exports.emojisPopoverClasses = void 0;
|
|
7
|
+
|
|
8
|
+
var _ui = require("@dhis2/ui");
|
|
9
|
+
|
|
10
|
+
const mainClasses = [".container.jsx-2278350860{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;width:100%;}", ".preview.jsx-2278350860{font-size:14px;line-height:19px;color:".concat(_ui.colors.grey900, ";}"), ".textarea.jsx-2278350860{width:100%;box-sizing:border-box;padding:".concat(_ui.spacers.dp8, " ").concat(_ui.spacers.dp12, ";color:").concat(_ui.colors.grey900, ";background-color:").concat(_ui.colors.white, ";border:1px solid ").concat(_ui.colors.grey500, ";border-radius:3px;box-shadow:inset 0 0 0 1px rgba(102,113,123,0.15), inset 0 1px 2px 0 rgba(102,113,123,0.1);outline:0;font-size:14px;line-height:").concat(_ui.spacers.dp16, ";-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;}"), ".textarea.jsx-2278350860:focus{outline:none;box-shadow:0 0 0 3px ".concat(_ui.theme.focus, ";}"), ".textarea.jsx-2278350860:disabled{background-color:".concat(_ui.colors.grey100, ";border-color:").concat(_ui.colors.grey500, ";color:").concat(_ui.theme.disabled, ";cursor:not-allowed;}")];
|
|
11
|
+
exports.mainClasses = mainClasses;
|
|
12
|
+
mainClasses.__hash = "2278350860";
|
|
13
|
+
const toolbarClasses = [".toolbar.jsx-1189800463{background:".concat(_ui.colors.grey050, ";border-radius:3px;border:1px solid ").concat(_ui.colors.grey300, ";margin-bottom:").concat(_ui.spacers.dp4, ";}"), ".actionsWrapper.jsx-1189800463{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:".concat(_ui.spacers.dp4, ";-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:").concat(_ui.spacers.dp4, ";}"), ".mainActions.jsx-1189800463{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:".concat(_ui.spacers.dp4, ";margin-top:").concat(_ui.spacers.dp2, ";}"), ".sideActions.jsx-1189800463{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;margin-left:auto;}", ".previewWrapper.jsx-1189800463{margin:".concat(_ui.spacers.dp4, ";text-align:right;}")];
|
|
14
|
+
exports.toolbarClasses = toolbarClasses;
|
|
15
|
+
toolbarClasses.__hash = "1189800463";
|
|
16
|
+
const tooltipAnchorClasses = [".tooltip.jsx-2182400256{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}"];
|
|
17
|
+
exports.tooltipAnchorClasses = tooltipAnchorClasses;
|
|
18
|
+
tooltipAnchorClasses.__hash = "2182400256";
|
|
19
|
+
const emojisPopoverClasses = [".emojisList.jsx-2802175370{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:".concat(_ui.spacers.dp8, ";list-style-type:none;margin:0 ").concat(_ui.spacers.dp4, " 0 ").concat(_ui.spacers.dp8, ";padding:0;}"), ".emojisList.jsx-2802175370 li.jsx-2802175370{cursor:pointer;}"];
|
|
20
|
+
exports.emojisPopoverClasses = emojisPopoverClasses;
|
|
21
|
+
emojisPopoverClasses.__hash = "2802175370";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UserList = void 0;
|
|
7
|
+
|
|
8
|
+
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
9
|
+
|
|
10
|
+
var _ui = require("@dhis2/ui");
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
const UserList = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
users,
|
|
21
|
+
selectedUserIndex,
|
|
22
|
+
onUserClick,
|
|
23
|
+
pager
|
|
24
|
+
} = _ref;
|
|
25
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, users.map(u => {
|
|
26
|
+
var _users$selectedUserIn;
|
|
27
|
+
|
|
28
|
+
return /*#__PURE__*/_react.default.createElement(_ui.MenuItem, {
|
|
29
|
+
dense: true,
|
|
30
|
+
key: u.id,
|
|
31
|
+
onClick: onUserClick(u),
|
|
32
|
+
label: "".concat(u.displayName, " (").concat(u.username, ")"),
|
|
33
|
+
active: ((_users$selectedUserIn = users[selectedUserIndex]) === null || _users$selectedUserIn === void 0 ? void 0 : _users$selectedUserIn.id) === u.id
|
|
34
|
+
});
|
|
35
|
+
}), pager.total > pager.pageSize && /*#__PURE__*/_react.default.createElement(_ui.MenuItem, {
|
|
36
|
+
dense: true,
|
|
37
|
+
disabled: true,
|
|
38
|
+
label: _d2I18n.default.t('Too many results. Try refining the search.')
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.UserList = UserList;
|
|
43
|
+
UserList.propTypes = {
|
|
44
|
+
pager: _propTypes.default.object.isRequired,
|
|
45
|
+
selectedUserIndex: _propTypes.default.number.isRequired,
|
|
46
|
+
users: _propTypes.default.array.isRequired,
|
|
47
|
+
onUserClick: _propTypes.default.func.isRequired
|
|
48
|
+
};
|