@gravity-ui/markdown-editor 13.24.0 → 13.25.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/README.md +2 -0
- package/build/cjs/bundle/MarkdownEditorView.js +18 -14
- package/build/cjs/bundle/config/action-names.d.ts +1 -1
- package/build/cjs/bundle/config/wysiwyg.js +1 -2
- package/build/cjs/bundle/settings/index.d.ts +1 -0
- package/build/cjs/bundle/settings/index.js +7 -6
- package/build/cjs/extensions/additional/GPT/MarkupGpt/commands.d.ts +4 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/commands.js +18 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/effects.d.ts +2 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/effects.js +6 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/index.d.ts +4 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/index.js +24 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/plugin.d.ts +22 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/plugin.js +121 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/popup.d.ts +11 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/popup.js +14 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/toolbar.d.ts +2 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/toolbar.js +18 -0
- package/build/cjs/extensions/{yfm → additional}/GPT/index.d.ts +1 -0
- package/build/cjs/extensions/{yfm → additional}/GPT/index.js +1 -0
- package/build/cjs/extensions/{yfm → additional}/GPT/plugin.js +6 -0
- package/build/cjs/extensions/{yfm → additional}/GPT/utils.d.ts +2 -0
- package/build/cjs/extensions/{yfm → additional}/GPT/utils.js +12 -1
- package/build/cjs/extensions/additional/index.d.ts +1 -0
- package/build/cjs/extensions/additional/index.js +4 -0
- package/build/cjs/extensions/behavior/SelectionContext/index.js +2 -1
- package/build/cjs/extensions/index.d.ts +1 -0
- package/build/cjs/extensions/index.js +1 -0
- package/build/cjs/extensions/yfm/index.d.ts +1 -1
- package/build/cjs/extensions/yfm/index.js +1 -1
- package/build/cjs/i18n/gpt/dialog/en.json +1 -1
- package/build/cjs/i18n/gpt/dialog/ru.json +1 -1
- package/build/cjs/i18n/menubar/index.d.ts +1 -1
- package/build/cjs/version.js +1 -1
- package/build/esm/bundle/MarkdownEditorView.js +18 -14
- package/build/esm/bundle/config/action-names.d.ts +1 -1
- package/build/esm/bundle/config/wysiwyg.js +1 -2
- package/build/esm/bundle/settings/index.d.ts +1 -0
- package/build/esm/bundle/settings/index.js +7 -6
- package/build/esm/extensions/additional/GPT/MarkupGpt/commands.d.ts +4 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/commands.js +12 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/effects.d.ts +2 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/effects.js +3 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/index.d.ts +4 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/index.js +17 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/plugin.d.ts +22 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/plugin.js +117 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/popup.d.ts +11 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/popup.js +9 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/toolbar.d.ts +2 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/toolbar.js +15 -0
- package/build/esm/extensions/{yfm → additional}/GPT/index.d.ts +1 -0
- package/build/esm/extensions/{yfm → additional}/GPT/index.js +1 -0
- package/build/esm/extensions/{yfm → additional}/GPT/plugin.js +6 -0
- package/build/esm/extensions/{yfm → additional}/GPT/utils.d.ts +2 -0
- package/build/esm/extensions/{yfm → additional}/GPT/utils.js +10 -0
- package/build/esm/extensions/additional/index.d.ts +1 -0
- package/build/esm/extensions/additional/index.js +1 -0
- package/build/esm/extensions/behavior/SelectionContext/index.js +3 -2
- package/build/esm/extensions/index.d.ts +1 -0
- package/build/esm/extensions/index.js +1 -0
- package/build/esm/extensions/yfm/index.d.ts +1 -1
- package/build/esm/extensions/yfm/index.js +1 -1
- package/build/esm/i18n/gpt/dialog/en.json +1 -1
- package/build/esm/i18n/gpt/dialog/ru.json +1 -1
- package/build/esm/i18n/menubar/index.d.ts +1 -1
- package/build/esm/version.js +1 -1
- package/build/styles.css +128 -128
- package/package.json +1 -1
- /package/build/cjs/extensions/{yfm → additional}/GPT/ErrorScreen/ErrorScreen.css +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/ErrorScreen/ErrorScreen.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/ErrorScreen/ErrorScreen.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/ErrorScreen/types.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/ErrorScreen/types.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/GptDialog/GptDialog.css +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/GptDialog/GptDialog.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/GptDialog/GptDialog.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/GptDialog/LoadingScreen/LoadingScreen.css +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/GptDialog/LoadingScreen/LoadingScreen.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/GptDialog/LoadingScreen/LoadingScreen.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.classname.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.classname.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.css +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/IconRefuge/index.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/IconRefuge/index.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/PresetList/PresetList.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/PresetList/PresetList.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/PresetList/Presetlist.css +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/actions.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/actions.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/commands.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/commands.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/constants.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/constants.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/gptExtension/gptExtension.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/gptExtension/gptExtension.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/gptExtension/view.css +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/gptExtension/view.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/gptExtension/view.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/useGpt.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/useGpt.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/useGptHotKeys.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/useGptHotKeys.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/useOverflowingHorizontalItems.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/useOverflowingHorizontalItems.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/usePresetList.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/usePresetList.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/plugin.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/toolbar.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/toolbar.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/ErrorScreen/ErrorScreen.css +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/ErrorScreen/ErrorScreen.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/ErrorScreen/ErrorScreen.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/ErrorScreen/types.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/ErrorScreen/types.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/GptDialog/GptDialog.css +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/GptDialog/GptDialog.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/GptDialog/GptDialog.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/GptDialog/LoadingScreen/LoadingScreen.css +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/GptDialog/LoadingScreen/LoadingScreen.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/GptDialog/LoadingScreen/LoadingScreen.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.classname.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.classname.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.css +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/IconRefuge/index.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/IconRefuge/index.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/PresetList/PresetList.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/PresetList/PresetList.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/PresetList/Presetlist.css +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/actions.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/actions.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/commands.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/commands.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/constants.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/constants.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/gptExtension/gptExtension.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/gptExtension/gptExtension.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/gptExtension/view.css +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/gptExtension/view.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/gptExtension/view.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/useGpt.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/useGpt.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/useGptHotKeys.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/useGptHotKeys.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/useOverflowingHorizontalItems.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/useOverflowingHorizontalItems.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/usePresetList.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/usePresetList.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/plugin.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/toolbar.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/toolbar.js +0 -0
package/README.md
CHANGED
|
@@ -59,6 +59,8 @@ Read more:
|
|
|
59
59
|
- [How to add Mermaid extension](https://github.com/gravity-ui/markdown-editor/blob/main/docs/how-to-connect-mermaid-extension.md)
|
|
60
60
|
- [How to write extension](https://github.com/gravity-ui/markdown-editor/blob/main/docs/how-to-create-extension.md)
|
|
61
61
|
- [How to add GPT extension](https://github.com/gravity-ui/markdown-editor/blob/main/docs/how-to-connect-gpt-extensions.md)
|
|
62
|
+
- [How to add text binding extension in markdown](https://github.com/gravity-ui/markdown-editor/blob/main/docs/how-to-add-text-binding-extension-in-markdown.md)
|
|
63
|
+
|
|
62
64
|
|
|
63
65
|
|
|
64
66
|
### i18n
|
|
@@ -60,7 +60,10 @@ exports.MarkdownEditorView = react_1.default.forwardRef((props, ref) => {
|
|
|
60
60
|
const editorMode = editor.currentMode;
|
|
61
61
|
const markupSplitMode = editor.splitModeEnabled && editor.splitMode && editorMode === 'markup';
|
|
62
62
|
const canRenderPreview = Boolean(editor.renderPreview && editorMode === 'markup' && !editor.splitModeEnabled);
|
|
63
|
-
(0, react_use_1.useKey)((e) => canRenderPreview && isPreviewKeyDown(e), () =>
|
|
63
|
+
(0, react_use_1.useKey)((e) => canRenderPreview && isPreviewKeyDown(e), (e) => {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
onShowPreviewChange(!showPreview);
|
|
66
|
+
}, { event: 'keydown' }, [showPreview, editorMode, onShowPreviewChange, canRenderPreview]);
|
|
64
67
|
const editorWrapperRef = (0, react_1.useRef)(null);
|
|
65
68
|
const splitModeViewWrapperRef = (0, react_1.useRef)(null);
|
|
66
69
|
(0, react_1.useEffect)(() => {
|
|
@@ -77,18 +80,19 @@ exports.MarkdownEditorView = react_1.default.forwardRef((props, ref) => {
|
|
|
77
80
|
onShowPreviewChange(false);
|
|
78
81
|
}
|
|
79
82
|
}, { event: 'keydown' }, [hidePreviewAfterSubmit, enableSubmitInPreview, showPreview, showPreview]);
|
|
80
|
-
const settings = (0, react_1.useMemo)(() => (react_1.default.createElement(Settings, { mode: editorMode, onModeChange: onModeChange, toolbarVisibility: editor.toolbarVisible && !showPreview, onToolbarVisibilityChange: onToolbarVisibilityChange, onSplitModeChange: onSplitModeChange, splitModeEnabled: editor.splitModeEnabled, splitMode: editor.splitMode, stickyToolbar: stickyToolbar, onShowPreviewChange: onShowPreviewChange, showPreview: showPreview, renderPreviewButton: canRenderPreview })), [
|
|
81
|
-
canRenderPreview,
|
|
82
|
-
stickyToolbar,
|
|
83
|
-
editor.splitMode,
|
|
84
|
-
editor.splitModeEnabled,
|
|
85
|
-
editor.toolbarVisible,
|
|
83
|
+
const settings = (0, react_1.useMemo)(() => (react_1.default.createElement(Settings, { mode: editorMode, settingsVisible: settingsVisible, onModeChange: onModeChange, toolbarVisibility: editor.toolbarVisible && !showPreview, onToolbarVisibilityChange: onToolbarVisibilityChange, onSplitModeChange: onSplitModeChange, splitModeEnabled: editor.splitModeEnabled, splitMode: editor.splitMode, stickyToolbar: stickyToolbar, onShowPreviewChange: onShowPreviewChange, showPreview: showPreview, renderPreviewButton: canRenderPreview })), [
|
|
86
84
|
editorMode,
|
|
85
|
+
settingsVisible,
|
|
86
|
+
editor.toolbarVisible,
|
|
87
|
+
editor.splitModeEnabled,
|
|
88
|
+
editor.splitMode,
|
|
87
89
|
onModeChange,
|
|
88
|
-
onShowPreviewChange,
|
|
89
|
-
onSplitModeChange,
|
|
90
|
-
onToolbarVisibilityChange,
|
|
91
90
|
showPreview,
|
|
91
|
+
onToolbarVisibilityChange,
|
|
92
|
+
onSplitModeChange,
|
|
93
|
+
stickyToolbar,
|
|
94
|
+
onShowPreviewChange,
|
|
95
|
+
canRenderPreview,
|
|
92
96
|
]);
|
|
93
97
|
return (react_1.default.createElement(react_error_boundary_1.ErrorBoundary, { onError: (e) => {
|
|
94
98
|
logger_1.logger.error(e);
|
|
@@ -121,8 +125,8 @@ exports.MarkdownEditorView = react_1.default.forwardRef((props, ref) => {
|
|
|
121
125
|
})),
|
|
122
126
|
settings)) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
123
127
|
editorMode === 'wysiwyg' && (react_1.default.createElement(WysiwygEditorView_1.WysiwygEditorView, { editor: editor, autofocus: autofocus, settingsVisible: settingsVisible, toolbarConfig: wysiwygToolbarConfig, toolbarVisible: editor.toolbarVisible, hiddenActionsConfig: wysiwygHiddenActionsConfig, className: b('editor', { mode: editorMode }), toolbarClassName: b('toolbar'), stickyToolbar: stickyToolbar }, editor.toolbarVisible && settingsVisible && settings)),
|
|
124
|
-
editorMode === 'markup' && (react_1.default.createElement(MarkupEditorView_1.MarkupEditorView, { editor: editor, autofocus: autofocus, settingsVisible: settingsVisible, toolbarConfig: markupToolbarConfig, toolbarVisible: editor.toolbarVisible, splitMode: editor.splitMode, splitModeEnabled: editor.splitModeEnabled, hiddenActionsConfig: markupHiddenActionsConfig, className: b('editor', { mode: editorMode }), toolbarClassName: b('toolbar'), stickyToolbar: stickyToolbar }, editor.toolbarVisible &&
|
|
125
|
-
!editor.toolbarVisible &&
|
|
128
|
+
editorMode === 'markup' && (react_1.default.createElement(MarkupEditorView_1.MarkupEditorView, { editor: editor, autofocus: autofocus, settingsVisible: settingsVisible, toolbarConfig: markupToolbarConfig, toolbarVisible: editor.toolbarVisible, splitMode: editor.splitMode, splitModeEnabled: editor.splitModeEnabled, hiddenActionsConfig: markupHiddenActionsConfig, className: b('editor', { mode: editorMode }), toolbarClassName: b('toolbar'), stickyToolbar: stickyToolbar }, editor.toolbarVisible && settings)),
|
|
129
|
+
!editor.toolbarVisible && settings))),
|
|
126
130
|
markupSplitMode && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
127
131
|
editor.splitMode === 'horizontal' ? (react_1.default.createElement(HorizontalDrag_1.HorizontalDrag, { editor: editor, isMounted: isMounted, leftElRef: editorWrapperRef, rightElRef: splitModeViewWrapperRef, wrapperRef: divRef })) : (react_1.default.createElement("div", { className: b('resizer') })),
|
|
128
132
|
react_1.default.createElement(SplitModeView_1.SplitModeView, { editor: editor, ref: splitModeViewWrapperRef })))))));
|
|
@@ -132,13 +136,13 @@ const MarkupSearchAnchor = ({ mode }) => (react_1.default.createElement(react_1.
|
|
|
132
136
|
function Settings(props) {
|
|
133
137
|
const wrapperRef = (0, react_1.useRef)(null);
|
|
134
138
|
const isSticky = (0, react_utils_1.useSticky)(wrapperRef) && props.toolbarVisibility && props.stickyToolbar;
|
|
135
|
-
return (react_1.default.createElement("div", { className: b('settings-wrapper') },
|
|
139
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, (props.renderPreviewButton || props.settingsVisible) && (react_1.default.createElement("div", { className: b('settings-wrapper') },
|
|
136
140
|
react_1.default.createElement("div", { ref: wrapperRef, className: sticky_1.stickyCn.settings({
|
|
137
141
|
withToolbar: props.toolbarVisibility,
|
|
138
142
|
stickyActive: isSticky,
|
|
139
143
|
}) },
|
|
140
144
|
react_1.default.createElement(settings_1.EditorSettings, Object.assign({}, props)),
|
|
141
|
-
react_1.default.createElement(MarkupSearchAnchor, Object.assign({}, props)))));
|
|
145
|
+
react_1.default.createElement(MarkupSearchAnchor, Object.assign({}, props)))))));
|
|
142
146
|
}
|
|
143
147
|
function isPreviewKeyDown(e) {
|
|
144
148
|
const modKey = (0, utils_1.isMac)() ? e.metaKey : e.ctrlKey;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const namesObj: Record<"bold" | "link" | "italic" | "strike" | "underline" | "mark" | "quote" | "mono" | "paragraph" | "anchor" | "table" | "image" | "code_inline" | "code_block" | "file" | "checkbox" | "bulletList" | "orderedList" | "emoji" | "tabs" | "yfm_cut" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "yfm_note" | "gpt" | "undo" | "redo" | "
|
|
1
|
+
declare const namesObj: Record<"bold" | "link" | "italic" | "strike" | "underline" | "mark" | "quote" | "mono" | "paragraph" | "anchor" | "table" | "image" | "code_inline" | "code_block" | "file" | "checkbox" | "bulletList" | "orderedList" | "emoji" | "tabs" | "yfm_cut" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "yfm_note" | "gpt" | "undo" | "redo" | "liftListItem" | "sinkListItem" | "yfm_block" | "yfm_html_block" | "yfm_layout" | "horizontalrule" | "math_inline" | "math_block" | "mermaid", string>;
|
|
2
2
|
export declare const ActionName: Readonly<typeof namesObj>;
|
|
3
3
|
export {};
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.wSelectionMenuConfigByPreset = exports.wHiddenDataByPreset = exports.wCommandMenuConfigByPreset = exports.wToolbarConfigByPreset = exports.wMermaidItemData = exports.wSelectionMenuConfig = exports.wToggleHeadingFoldingItemData = exports.wToolbarConfig = exports.wHiddenData = exports.wCommandMenuConfig = exports.wGptItemData = exports.wYfmHtmlBlockItemData = exports.wMathListItem = exports.wMathListConfig = exports.wMathBlockItemData = exports.wTabsItemData = exports.wMathInlineItemData = exports.wFileItemData = exports.wEmojiItemData = exports.wHruleItemData = exports.wImageItemData = exports.wCodeListConfig = exports.wCodeBlockItemData = exports.wCodeItemData = exports.wTableItemData = exports.wNoteItemData = exports.wListMoveListConfig = exports.wCutItemData = exports.wQuoteItemData = exports.wLinkItemData = exports.wCheckboxItemData = exports.wListsListConfig = exports.wHeadingListConfig = exports.wTextItemData = exports.wBiusGroupConfig = exports.wMarkedItemData = exports.wMonospaceItemData = exports.wStrikethroughItemData = exports.wUnderlineItemData = exports.wItalicItemData = exports.wBoldItemData = exports.wHistoryGroupConfig = void 0;
|
|
4
4
|
const extensions_1 = require("../../extensions");
|
|
5
|
-
|
|
6
|
-
const constants_1 = require("../../extensions/yfm/GPT/constants");
|
|
5
|
+
const constants_1 = require("../../extensions/additional/GPT/constants");
|
|
7
6
|
const hints_1 = require("../../i18n/hints");
|
|
8
7
|
const menubar_1 = require("../../i18n/menubar");
|
|
9
8
|
const shortcuts_1 = require("../../shortcuts");
|
|
@@ -3,6 +3,7 @@ import { ClassNameProps } from '../../classname';
|
|
|
3
3
|
import type { EditorMode, SplitMode } from '../Editor';
|
|
4
4
|
export declare type EditorSettingsProps = Omit<SettingsContentProps, 'onClose'> & {
|
|
5
5
|
renderPreviewButton?: boolean;
|
|
6
|
+
settingsVisible?: boolean;
|
|
6
7
|
};
|
|
7
8
|
export declare const EditorSettings: React.NamedExoticComponent<EditorSettingsProps>;
|
|
8
9
|
declare type SettingsContentProps = ClassNameProps & {
|
|
@@ -20,7 +20,7 @@ const placement = ['bottom-end', 'top-end'];
|
|
|
20
20
|
const bSettings = (0, classname_1.cn)('editor-settings');
|
|
21
21
|
const bContent = (0, classname_1.cn)('settings-content');
|
|
22
22
|
exports.EditorSettings = react_1.default.memo(function EditorSettings(props) {
|
|
23
|
-
const { className, onShowPreviewChange, showPreview, renderPreviewButton } = props;
|
|
23
|
+
const { className, onShowPreviewChange, showPreview, renderPreviewButton, settingsVisible } = props;
|
|
24
24
|
const chevronRef = react_1.default.useRef(null);
|
|
25
25
|
const [popupShown, , hidePopup, togglePopup] = (0, hooks_1.useBooleanState)(false);
|
|
26
26
|
return (react_1.default.createElement("div", { className: bSettings(null, [className]) },
|
|
@@ -28,11 +28,12 @@ exports.EditorSettings = react_1.default.memo(function EditorSettings(props) {
|
|
|
28
28
|
react_1.default.createElement(uikit_1.ActionTooltip, { openDelay: toolbar_1.ToolbarTooltipDelay.Open, closeDelay: toolbar_1.ToolbarTooltipDelay.Close, title: (0, bundle_1.i18n)('preview_hint'), hotkey: "mod+shift+p" },
|
|
29
29
|
react_1.default.createElement(uikit_1.Button, { size: "m", view: "flat", pin: "round-round", className: bSettings('preview-button'), onClick: () => onShowPreviewChange === null || onShowPreviewChange === void 0 ? void 0 : onShowPreviewChange(!showPreview), selected: showPreview },
|
|
30
30
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Eye }))),
|
|
31
|
-
react_1.default.createElement("div", { className: bSettings('separator') }))),
|
|
32
|
-
react_1.default.createElement(
|
|
33
|
-
react_1.default.createElement(uikit_1.
|
|
34
|
-
|
|
35
|
-
react_1.default.createElement(
|
|
31
|
+
settingsVisible && react_1.default.createElement("div", { className: bSettings('separator') }))),
|
|
32
|
+
settingsVisible && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
33
|
+
react_1.default.createElement(uikit_1.Button, { size: "m", view: "flat", ref: chevronRef, pin: "round-round", onClick: togglePopup, className: bSettings('dropdown-button') },
|
|
34
|
+
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Gear })),
|
|
35
|
+
react_1.default.createElement(uikit_1.Popup, { open: popupShown, anchorRef: chevronRef, placement: placement, onClose: hidePopup },
|
|
36
|
+
react_1.default.createElement(SettingsContent, Object.assign({}, props, { onClose: hidePopup, className: bSettings('content') })))))));
|
|
36
37
|
});
|
|
37
38
|
const mdHelpPlacement = ['bottom', 'bottom-end', 'right-start', 'right', 'left'];
|
|
38
39
|
const SettingsContent = function SettingsContent({ mode, onClose, onModeChange, toolbarVisibility, onToolbarVisibilityChange, onSplitModeChange, splitMode = false, splitModeEnabled, className, showPreview, }) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runMarkupGpt = exports.hideMarkupGpt = exports.showMarkupGpt = void 0;
|
|
4
|
+
const effects_1 = require("./effects");
|
|
5
|
+
const showMarkupGpt = (view) => {
|
|
6
|
+
view.dispatch({ effects: [effects_1.ShowMarkupGptEffect.of(null)] });
|
|
7
|
+
};
|
|
8
|
+
exports.showMarkupGpt = showMarkupGpt;
|
|
9
|
+
const hideMarkupGpt = (view) => {
|
|
10
|
+
view.dispatch({ effects: [effects_1.HideMarkupGptEffect.of(null)] });
|
|
11
|
+
};
|
|
12
|
+
exports.hideMarkupGpt = hideMarkupGpt;
|
|
13
|
+
const runMarkupGpt = (view) => {
|
|
14
|
+
if (view)
|
|
15
|
+
(0, exports.showMarkupGpt)(view);
|
|
16
|
+
return true;
|
|
17
|
+
};
|
|
18
|
+
exports.runMarkupGpt = runMarkupGpt;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HideMarkupGptEffect = exports.ShowMarkupGptEffect = void 0;
|
|
4
|
+
const state_1 = require("../../../../cm/state");
|
|
5
|
+
exports.ShowMarkupGptEffect = state_1.StateEffect.define();
|
|
6
|
+
exports.HideMarkupGptEffect = state_1.StateEffect.define();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mGptExtension = exports.hideMarkupGpt = exports.showMarkupGpt = exports.mGptToolbarItem = void 0;
|
|
4
|
+
const view_1 = require("@codemirror/view");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const commands_1 = require("./commands");
|
|
7
|
+
const plugin_1 = require("./plugin");
|
|
8
|
+
var toolbar_1 = require("./toolbar");
|
|
9
|
+
Object.defineProperty(exports, "mGptToolbarItem", { enumerable: true, get: function () { return toolbar_1.mGptToolbarItem; } });
|
|
10
|
+
var commands_2 = require("./commands");
|
|
11
|
+
Object.defineProperty(exports, "showMarkupGpt", { enumerable: true, get: function () { return commands_2.showMarkupGpt; } });
|
|
12
|
+
Object.defineProperty(exports, "hideMarkupGpt", { enumerable: true, get: function () { return commands_2.hideMarkupGpt; } });
|
|
13
|
+
function mGptExtension(props) {
|
|
14
|
+
return [
|
|
15
|
+
(0, plugin_1.mGptPlugin)(props).extension,
|
|
16
|
+
view_1.keymap.of([
|
|
17
|
+
{
|
|
18
|
+
key: constants_1.gptHotKeys.openGptKey,
|
|
19
|
+
run: commands_1.runMarkupGpt,
|
|
20
|
+
},
|
|
21
|
+
]),
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
exports.mGptExtension = mGptExtension;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GptWidgetOptions } from '../../..';
|
|
2
|
+
import { type DecorationSet, type EditorView, ViewPlugin, type ViewUpdate } from '../../../../cm/view';
|
|
3
|
+
export declare function mGptPlugin(gptProps: GptWidgetOptions): ViewPlugin<{
|
|
4
|
+
readonly _view: EditorView;
|
|
5
|
+
readonly _renderItem: import("../../..").RendererItem;
|
|
6
|
+
_anchor: Element | null;
|
|
7
|
+
decos: DecorationSet;
|
|
8
|
+
disablePromptPresets: boolean;
|
|
9
|
+
markup: string | null;
|
|
10
|
+
selectedPosition: {
|
|
11
|
+
from: number;
|
|
12
|
+
to: number;
|
|
13
|
+
};
|
|
14
|
+
update(update: ViewUpdate): void;
|
|
15
|
+
docViewUpdate(): void;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
renderPopup(): JSX.Element | null;
|
|
18
|
+
_getDecorationText(update: ViewUpdate, from: number, to: number): string;
|
|
19
|
+
_clearSelectedText(): void;
|
|
20
|
+
_setSelectedText(str: string): void;
|
|
21
|
+
_onApplyResult(changedMarkup: string): void;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mGptPlugin = void 0;
|
|
4
|
+
const view_1 = require("@codemirror/view");
|
|
5
|
+
const view_2 = require("../../../../cm/view");
|
|
6
|
+
const markup_1 = require("../../../../markup");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
const commands_1 = require("./commands");
|
|
10
|
+
const effects_1 = require("./effects");
|
|
11
|
+
const popup_1 = require("./popup");
|
|
12
|
+
class SpanWidget extends view_1.WidgetType {
|
|
13
|
+
constructor(className, textContent) {
|
|
14
|
+
super();
|
|
15
|
+
this.className = '';
|
|
16
|
+
this.textContent = '';
|
|
17
|
+
this.className = className;
|
|
18
|
+
this.textContent = textContent;
|
|
19
|
+
}
|
|
20
|
+
toDOM() {
|
|
21
|
+
const spanElem = document.createElement('span');
|
|
22
|
+
spanElem.className = this.className;
|
|
23
|
+
spanElem.textContent = this.textContent;
|
|
24
|
+
return spanElem;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function mGptPlugin(gptProps) {
|
|
28
|
+
return view_2.ViewPlugin.fromClass(class {
|
|
29
|
+
constructor(view) {
|
|
30
|
+
this._anchor = null;
|
|
31
|
+
this.decos = view_2.Decoration.none;
|
|
32
|
+
this.disablePromptPresets = true;
|
|
33
|
+
this.markup = null;
|
|
34
|
+
this.selectedPosition = {
|
|
35
|
+
from: 0,
|
|
36
|
+
to: 0,
|
|
37
|
+
};
|
|
38
|
+
this._view = view;
|
|
39
|
+
this._renderItem = view.state
|
|
40
|
+
.facet(markup_1.ReactRendererFacet)
|
|
41
|
+
.createItem('gpt-in-markup-mode', () => this.renderPopup());
|
|
42
|
+
}
|
|
43
|
+
update(update) {
|
|
44
|
+
if (update.docChanged || update.selectionSet) {
|
|
45
|
+
this.decos = view_2.Decoration.none;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.decos = this.decos.map(update.changes);
|
|
49
|
+
const { from, to } = update.state.selection.main;
|
|
50
|
+
this.selectedPosition.from = from;
|
|
51
|
+
this.selectedPosition.to = to;
|
|
52
|
+
for (const tr of update.transactions) {
|
|
53
|
+
for (const eff of tr.effects) {
|
|
54
|
+
if (eff.is(effects_1.ShowMarkupGptEffect)) {
|
|
55
|
+
this._setSelectedText(this._getDecorationText(update, from, to));
|
|
56
|
+
if (from === to) {
|
|
57
|
+
this.disablePromptPresets = true;
|
|
58
|
+
if ((0, utils_1.isEmptyGptPrompts)(gptProps, true))
|
|
59
|
+
return;
|
|
60
|
+
const decorationWidget = view_2.Decoration.widget({
|
|
61
|
+
widget: new SpanWidget(constants_1.WIDGET_DECO_CLASS_NAME, ' '),
|
|
62
|
+
});
|
|
63
|
+
this.decos = view_2.Decoration.set([decorationWidget.range(from)]);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
this.disablePromptPresets = false;
|
|
67
|
+
if ((0, utils_1.isEmptyGptPrompts)(gptProps, false))
|
|
68
|
+
return;
|
|
69
|
+
this.decos = view_2.Decoration.set([
|
|
70
|
+
{
|
|
71
|
+
from,
|
|
72
|
+
to,
|
|
73
|
+
value: view_2.Decoration.mark({ class: constants_1.WIDGET_DECO_CLASS_NAME }),
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
if (eff.is(effects_1.HideMarkupGptEffect)) {
|
|
78
|
+
this.decos = view_2.Decoration.none;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
docViewUpdate() {
|
|
84
|
+
this._anchor = this._view.dom
|
|
85
|
+
.getElementsByClassName(constants_1.WIDGET_DECO_CLASS_NAME)
|
|
86
|
+
.item(0);
|
|
87
|
+
this._renderItem.rerender();
|
|
88
|
+
}
|
|
89
|
+
destroy() {
|
|
90
|
+
this._clearSelectedText();
|
|
91
|
+
this._renderItem.remove();
|
|
92
|
+
}
|
|
93
|
+
renderPopup() {
|
|
94
|
+
if (!this._anchor || this.markup === null) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return (0, popup_1.renderPopup)(this._anchor, Object.assign(Object.assign({}, gptProps), { disablePromptPresets: this.disablePromptPresets, onClose: () => (0, commands_1.hideMarkupGpt)(this._view), markup: this.markup, onApplyResult: (changedMarkup) => this._onApplyResult(changedMarkup) }));
|
|
98
|
+
}
|
|
99
|
+
_getDecorationText(update, from, to) {
|
|
100
|
+
return update.state.doc.sliceString(from, to);
|
|
101
|
+
}
|
|
102
|
+
_clearSelectedText() {
|
|
103
|
+
this.markup = null;
|
|
104
|
+
}
|
|
105
|
+
_setSelectedText(str) {
|
|
106
|
+
this.markup = str;
|
|
107
|
+
}
|
|
108
|
+
_onApplyResult(changedMarkup) {
|
|
109
|
+
const { from, to } = this.selectedPosition;
|
|
110
|
+
const changes = [{ from: from, to: to, insert: changedMarkup }];
|
|
111
|
+
const transaction = this._view.state.update({
|
|
112
|
+
changes: changes,
|
|
113
|
+
effects: [effects_1.HideMarkupGptEffect.of(null)],
|
|
114
|
+
});
|
|
115
|
+
this._view.dispatch(transaction);
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
decorations: (value) => value.decos,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
exports.mGptPlugin = mGptPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PopupProps } from '@gravity-ui/uikit';
|
|
3
|
+
import { GptDialogProps } from '../GptDialog/GptDialog';
|
|
4
|
+
declare type Props = {
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
markup: string;
|
|
7
|
+
onConfirmOk?: () => void;
|
|
8
|
+
onConfirmCancel?: () => void;
|
|
9
|
+
} & GptDialogProps & Pick<PopupProps, 'anchorRef' | 'container'>;
|
|
10
|
+
export declare function renderPopup(anchor: HTMLElement, props: Props): JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderPopup = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
7
|
+
const GptDialog_1 = require("../GptDialog/GptDialog");
|
|
8
|
+
const view_1 = require("../gptExtension/view");
|
|
9
|
+
function renderPopup(anchor, props) {
|
|
10
|
+
const handleUpdate = (result) => { var _a; return (_a = props.onUpdate) === null || _a === void 0 ? void 0 : _a.call(props, result); };
|
|
11
|
+
return (react_1.default.createElement(uikit_1.Popup, { className: (0, view_1.cnGptPopup)(), contentClassName: (0, view_1.cnGptPopup)('content'), open: true, anchorRef: { current: anchor }, onOutsideClick: props.onClose, focusTrap: true, strategy: "absolute", onEscapeKeyDown: props.onClose },
|
|
12
|
+
react_1.default.createElement(GptDialog_1.GptDialog, { markup: props.markup, answerRender: props.answerRender, promptPresets: props.promptPresets, disablePromptPresets: props.disablePromptPresets, customPromptPlaceholder: props.customPromptPlaceholder, disabledPromptPlaceholder: props.disabledPromptPlaceholder, onApplyResult: props.onApplyResult, onCustomPromptApply: props.onCustomPromptApply, onPromptPresetClick: props.onPromptPresetClick, onTryAgain: props.onTryAgain, onLike: props.onLike, onDislike: props.onDislike, onClose: props.onClose, onUpdate: handleUpdate, gptAlertProps: props.gptAlertProps })));
|
|
13
|
+
}
|
|
14
|
+
exports.renderPopup = renderPopup;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mGptToolbarItem = void 0;
|
|
4
|
+
const extension_1 = require("../../../../i18n/gpt/extension");
|
|
5
|
+
const icons_1 = require("../../../../icons");
|
|
6
|
+
const toolbar_1 = require("../../../../toolbar");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const commands_1 = require("./commands");
|
|
9
|
+
exports.mGptToolbarItem = {
|
|
10
|
+
id: 'gpt',
|
|
11
|
+
type: toolbar_1.ToolbarDataType.SingleButton,
|
|
12
|
+
hotkey: constants_1.gptHotKeys.openGptKeyTooltip,
|
|
13
|
+
title: () => `${(0, extension_1.i18n)('help-with-text')}`,
|
|
14
|
+
icon: { data: icons_1.GPTIcon },
|
|
15
|
+
exec: (e) => (0, commands_1.showMarkupGpt)(e.cm),
|
|
16
|
+
isActive: () => false,
|
|
17
|
+
isEnable: () => true,
|
|
18
|
+
};
|
|
@@ -3,3 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./toolbar"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./gptExtension/gptExtension"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./MarkupGpt"), exports);
|
|
@@ -5,6 +5,7 @@ const prosemirror_state_1 = require("prosemirror-state");
|
|
|
5
5
|
const prosemirror_view_1 = require("prosemirror-view");
|
|
6
6
|
const constants_1 = require("./constants");
|
|
7
7
|
const view_1 = require("./gptExtension/view");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
8
9
|
const key = new prosemirror_state_1.PluginKey('gpt-widget');
|
|
9
10
|
exports.pluginKey = key;
|
|
10
11
|
const gptWidgetPlugin = (params) => {
|
|
@@ -15,18 +16,23 @@ const gptWidgetPlugin = (params) => {
|
|
|
15
16
|
apply: (tr, decos) => {
|
|
16
17
|
const meta = tr.getMeta(key);
|
|
17
18
|
const paramsGpt = params;
|
|
19
|
+
paramsGpt.disablePromptPresets = false;
|
|
18
20
|
if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'show') {
|
|
19
21
|
if (meta.to === meta.from) {
|
|
20
22
|
const spanElem = document.createElement('span');
|
|
21
23
|
spanElem.className = constants_1.WIDGET_DECO_CLASS_NAME;
|
|
22
24
|
spanElem.textContent = ' ';
|
|
23
25
|
paramsGpt.disablePromptPresets = true;
|
|
26
|
+
if ((0, utils_1.isEmptyGptPrompts)(paramsGpt, true))
|
|
27
|
+
return prosemirror_view_1.DecorationSet.empty;
|
|
24
28
|
return prosemirror_view_1.DecorationSet.create(tr.doc, [
|
|
25
29
|
prosemirror_view_1.Decoration.widget(meta.from, spanElem, {
|
|
26
30
|
[constants_1.WIDGET_DECO_SPEC_FLAG]: true,
|
|
27
31
|
}),
|
|
28
32
|
]);
|
|
29
33
|
}
|
|
34
|
+
if ((0, utils_1.isEmptyGptPrompts)(paramsGpt, false))
|
|
35
|
+
return prosemirror_view_1.DecorationSet.empty;
|
|
30
36
|
return prosemirror_view_1.DecorationSet.create(tr.doc, [
|
|
31
37
|
prosemirror_view_1.Decoration.inline(meta.from, meta.to, { nodeName: 'span', class: constants_1.WIDGET_DECO_CLASS_NAME }, { [constants_1.WIDGET_DECO_SPEC_FLAG]: true }),
|
|
32
38
|
]);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import { GptDialogProps } from './GptDialog/GptDialog';
|
|
3
|
+
import { GptWidgetOptions } from './gptExtension/gptExtension';
|
|
3
4
|
declare type CombinedKeyboardEvent = KeyboardEvent | React.KeyboardEvent;
|
|
4
5
|
export declare function getAlertGptInfo(gptAlert: GptDialogProps['gptAlertProps']): {
|
|
5
6
|
alertMessage: string;
|
|
@@ -10,4 +11,5 @@ export declare function getDisableReplaceButtonText(disablePromptPresets?: boole
|
|
|
10
11
|
export declare function getInputPlaceHolder(disablePromptPresets?: boolean, disabledPromptPlaceholder?: string, customPromptPlaceholder?: string): string | undefined;
|
|
11
12
|
export declare const isEnter: (event: CombinedKeyboardEvent) => boolean;
|
|
12
13
|
export declare function focusWithoutScroll(element?: HTMLElement | null): void;
|
|
14
|
+
export declare function isEmptyGptPrompts(gptWidgetOptions: GptWidgetOptions, disablePromptPresets: boolean): boolean;
|
|
13
15
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.focusWithoutScroll = exports.isEnter = exports.getInputPlaceHolder = exports.getDisableReplaceButtonText = exports.getAlertGptInfo = void 0;
|
|
3
|
+
exports.isEmptyGptPrompts = exports.focusWithoutScroll = exports.isEnter = exports.getInputPlaceHolder = exports.getDisableReplaceButtonText = exports.getAlertGptInfo = void 0;
|
|
4
4
|
const dialog_1 = require("../../../i18n/gpt/dialog");
|
|
5
5
|
function getAlertGptInfo(gptAlert) {
|
|
6
6
|
return {
|
|
@@ -29,3 +29,14 @@ function focusWithoutScroll(element) {
|
|
|
29
29
|
window.scrollTo(x, y);
|
|
30
30
|
}
|
|
31
31
|
exports.focusWithoutScroll = focusWithoutScroll;
|
|
32
|
+
function isEmptyGptPrompts(gptWidgetOptions, disablePromptPresets) {
|
|
33
|
+
var _a;
|
|
34
|
+
if (disablePromptPresets && !gptWidgetOptions.onCustomPromptApply)
|
|
35
|
+
return true;
|
|
36
|
+
if (!disablePromptPresets &&
|
|
37
|
+
!((_a = gptWidgetOptions.promptPresets) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
38
|
+
!gptWidgetOptions.onCustomPromptApply)
|
|
39
|
+
return true;
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
exports.isEmptyGptPrompts = isEmptyGptPrompts;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GPT';
|
|
@@ -78,7 +78,8 @@ class SelectionTooltip {
|
|
|
78
78
|
return;
|
|
79
79
|
const { selection } = state;
|
|
80
80
|
// Hide the tooltip if the selection is empty
|
|
81
|
-
if (selection.empty ||
|
|
81
|
+
if (selection.empty ||
|
|
82
|
+
!(selection instanceof prosemirror_state_1.TextSelection || selection instanceof prosemirror_state_1.AllSelection)) {
|
|
82
83
|
this.tooltip.hide(view);
|
|
83
84
|
return;
|
|
84
85
|
}
|
|
@@ -14,4 +14,4 @@ tslib_1.__exportStar(require("./YfmHeading"), exports);
|
|
|
14
14
|
tslib_1.__exportStar(require("./YfmNote"), exports);
|
|
15
15
|
tslib_1.__exportStar(require("./YfmTable"), exports);
|
|
16
16
|
tslib_1.__exportStar(require("./YfmTabs"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("
|
|
17
|
+
tslib_1.__exportStar(require("../additional/GPT"), exports);
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
"replace": "Заменить выделенный текст",
|
|
13
13
|
"replace-disabled": "Вставить текст",
|
|
14
14
|
"try-again": "Иначе",
|
|
15
|
-
"alert-gpt-presets-info": "Выделите текст, чтобы увидеть пресеты
|
|
15
|
+
"alert-gpt-presets-info": "Выделите текст, чтобы увидеть пресеты GPT"
|
|
16
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const i18n: <G extends "bold" | "code" | "link" | "italic" | "strike" | "underline" | "mark" | "quote" | "colorify" | "mono" | "text" | "html" | "cut" | "table" | "image" | "code_inline" | "list" | "heading" | "note" | "file" | "codeblock" | "checkbox" | "emoji" | "tabs" | "math" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "gpt" | "undo" | "redo" | "math_inline" | "math_block" | "colorify__color_blue" | "colorify__color_default" | "colorify__color_gray" | "colorify__color_green" | "colorify__color_orange" | "colorify__color_red" | "colorify__color_violet" | "colorify__color_yellow" | "colorify__group_text" | "folding-heading" | "folding-heading_hint" | "hrule" | "list__action_lift" | "list__action_sink" | "list_action_disabled" | "
|
|
1
|
+
export declare const i18n: <G extends "bold" | "code" | "link" | "italic" | "strike" | "underline" | "mark" | "quote" | "colorify" | "mono" | "text" | "html" | "cut" | "table" | "image" | "code_inline" | "list" | "heading" | "note" | "file" | "codeblock" | "checkbox" | "emoji" | "tabs" | "math" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "gpt" | "undo" | "redo" | "math_inline" | "math_block" | "mermaid" | "colorify__color_blue" | "colorify__color_default" | "colorify__color_gray" | "colorify__color_green" | "colorify__color_orange" | "colorify__color_red" | "colorify__color_violet" | "colorify__color_yellow" | "colorify__group_text" | "folding-heading" | "folding-heading_hint" | "hrule" | "list__action_lift" | "list__action_sink" | "list_action_disabled" | "more_action" | "olist" | "ulist", S extends string>(key: G | (string extends S ? S : never), params?: {
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
} | undefined) => S extends G ? {
|
|
4
4
|
bold: string;
|
package/build/cjs/version.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
/** During build process, the current version will be injected here */
|
|
5
|
-
exports.VERSION = typeof '13.
|
|
5
|
+
exports.VERSION = typeof '13.25.0' !== 'undefined' ? '13.25.0' : 'unknown';
|