@gravity-ui/markdown-editor 14.10.5 → 14.11.1
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/build/cjs/bundle/MarkdownEditorView.d.ts +1 -1
- package/build/cjs/bundle/MarkupEditorView.d.ts +2 -2
- package/build/cjs/bundle/WysiwygEditorView.d.ts +2 -2
- package/build/cjs/bundle/config/action-names.d.ts +1 -1
- package/build/cjs/bundle/config/markup.d.ts +3 -13
- package/build/cjs/bundle/config/markup.js +1 -1
- package/build/cjs/bundle/config/w-heading-config.d.ts +9 -0
- package/build/cjs/bundle/config/w-heading-config.js +85 -0
- package/build/cjs/bundle/config/wysiwyg.d.ts +3 -24
- package/build/cjs/bundle/config/wysiwyg.js +110 -183
- package/build/cjs/bundle/index.d.ts +1 -0
- package/build/cjs/bundle/index.js +2 -0
- package/build/cjs/bundle/toolbar/ToolbarSelect.d.ts +2 -3
- package/build/cjs/bundle/toolbar/markup/MToolbarColors.d.ts +2 -2
- package/build/cjs/bundle/toolbar/markup/MToolbarImagePopup.d.ts +1 -1
- package/build/cjs/bundle/toolbar/types.d.ts +21 -0
- package/build/cjs/bundle/toolbar/types.js +4 -0
- package/build/cjs/bundle/toolbar/utils/flattenPreset.d.ts +2 -2
- package/build/cjs/bundle/toolbar/utils/flattenPreset.js +1 -1
- package/build/cjs/bundle/toolbar/utils/toolbarsConfigs.d.ts +5 -5
- package/build/cjs/bundle/toolbar/utils/toolbarsConfigs.js +3 -3
- package/build/cjs/bundle/toolbar/wysiwyg/WToolbarColors.d.ts +2 -2
- package/build/cjs/bundle/toolbar/wysiwyg/WToolbarTextSelect.d.ts +2 -2
- package/build/cjs/bundle/toolbar/wysiwyg/WToolbarTextSelect.js +2 -2
- package/build/cjs/extensions/additional/GPT/MarkupGpt/toolbar.d.ts +1 -1
- package/build/cjs/extensions/additional/GPT/MarkupGpt/toolbar.js +2 -2
- package/build/cjs/extensions/additional/GPT/wGptItemData.d.ts +1 -1
- package/build/cjs/extensions/additional/GPT/wGptItemData.js +2 -2
- package/build/cjs/extensions/additional/Mermaid/MermaidSpecs/index.js +3 -2
- package/build/cjs/extensions/base/BaseSchema/BaseSchemaSpecs/index.js +13 -1
- package/build/cjs/extensions/behavior/SelectionContext/tooltip.d.ts +5 -5
- package/build/cjs/extensions/markdown/Image/index.d.ts +1 -1
- package/build/cjs/extensions/markdown/Link/LinkSpecs/index.js +1 -1
- package/build/cjs/extensions/markdown/Link/PlaceholderWidget/descriptor.d.ts +3 -3
- package/build/cjs/extensions/markdown/Link/PlaceholderWidget/descriptor.js +4 -3
- package/build/cjs/extensions/markdown/Link/actions/linkEnhanceActions.d.ts +2 -2
- package/build/cjs/extensions/markdown/Link/actions/linkEnhanceActions.js +10 -8
- package/build/cjs/extensions/markdown/Link/commands.js +2 -2
- package/build/cjs/extensions/markdown/Table/actions/innerActions.d.ts +1 -1
- package/build/cjs/extensions/markdown/Table/plugins/TableCellContextPlugin/index.js +3 -3
- package/build/cjs/extensions/yfm/ImgSize/index.d.ts +3 -3
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/index.d.ts +2 -10
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/schema.d.ts +11 -2
- package/build/cjs/extensions/yfm/YfmTable/YfmTableSpecs/index.d.ts +2 -7
- package/build/cjs/extensions/yfm/YfmTable/YfmTableSpecs/schema.d.ts +7 -2
- package/build/cjs/extensions/yfm/YfmTabs/YfmTabsSpecs/index.d.ts +2 -6
- package/build/cjs/extensions/yfm/YfmTabs/YfmTabsSpecs/schema.d.ts +8 -3
- package/build/cjs/extensions/yfm/YfmTabs/actions.js +7 -9
- package/build/cjs/extensions/yfm/YfmTabs/const.d.ts +5 -2
- package/build/cjs/extensions/yfm/YfmTabs/const.js +7 -4
- package/build/cjs/extensions/yfm/YfmTabs/plugins.d.ts +2 -2
- package/build/cjs/extensions/yfm/YfmTabs/plugins.js +15 -96
- package/build/cjs/extensions/yfm/YfmTabs/utils.d.ts +4 -1
- package/build/cjs/extensions/yfm/YfmTabs/utils.js +23 -3
- package/build/cjs/extensions/yfm/YfmTabs/views.d.ts +1 -1
- package/build/cjs/extensions/yfm/YfmTabs/views.js +26 -6
- package/build/cjs/i18n/menubar/index.d.ts +1 -1
- package/build/cjs/i18n/placeholder/index.d.ts +1 -1
- package/build/cjs/i18n/yfm-note/index.d.ts +1 -1
- package/build/cjs/markup/codemirror/html-to-markdown/handlers.d.ts +1 -1
- package/build/cjs/markup/codemirror/search-plugin/plugin.d.ts +6 -16
- package/build/cjs/markup/codemirror/search-plugin/plugin.js +7 -8
- package/build/cjs/markup/codemirror/search-plugin/view/SearchPopup.d.ts +6 -10
- package/build/cjs/markup/codemirror/search-plugin/view/SearchPopup.js +13 -13
- package/build/cjs/markup/codemirror/yfm.d.ts +1 -1
- package/build/cjs/markup/editor.d.ts +1 -1
- package/build/cjs/react-utils/react-node-view.d.ts +2 -2
- package/build/cjs/react-utils/react-node-view.js +2 -2
- package/build/cjs/table-utils/commands/appendColumn.js +2 -2
- package/build/cjs/table-utils/commands/appendRow.js +2 -2
- package/build/cjs/table-utils/commands/removeRow.js +2 -2
- package/build/cjs/toolbar/FlexToolbar.d.ts +2 -2
- package/build/cjs/toolbar/Toolbar.d.ts +2 -3
- package/build/cjs/toolbar/ToolbarGroup.d.ts +2 -2
- package/build/cjs/toolbar/ToolbarListButton.d.ts +2 -9
- package/build/cjs/toolbar/flexible.d.ts +1 -2
- package/build/cjs/toolbar/index.d.ts +0 -1
- package/build/cjs/toolbar/index.js +0 -1
- package/build/cjs/toolbar/types.d.ts +10 -1
- package/build/cjs/version.js +1 -1
- package/build/esm/bundle/MarkdownEditorView.d.ts +1 -1
- package/build/esm/bundle/MarkupEditorView.d.ts +2 -2
- package/build/esm/bundle/WysiwygEditorView.d.ts +2 -2
- package/build/esm/bundle/config/action-names.d.ts +1 -1
- package/build/esm/bundle/config/markup.d.ts +3 -13
- package/build/esm/bundle/config/markup.js +1 -1
- package/build/esm/bundle/config/w-heading-config.d.ts +9 -0
- package/build/esm/bundle/config/w-heading-config.js +82 -0
- package/build/esm/bundle/config/wysiwyg.d.ts +3 -24
- package/build/esm/bundle/config/wysiwyg.js +6 -79
- package/build/esm/bundle/index.d.ts +1 -0
- package/build/esm/bundle/index.js +2 -0
- package/build/esm/bundle/toolbar/ToolbarSelect.d.ts +2 -3
- package/build/esm/bundle/toolbar/markup/MToolbarColors.d.ts +2 -2
- package/build/esm/bundle/toolbar/markup/MToolbarImagePopup.d.ts +1 -1
- package/build/esm/bundle/toolbar/types.d.ts +21 -0
- package/build/esm/bundle/toolbar/types.js +1 -0
- package/build/esm/bundle/toolbar/utils/flattenPreset.d.ts +2 -2
- package/build/esm/bundle/toolbar/utils/flattenPreset.js +1 -1
- package/build/esm/bundle/toolbar/utils/toolbarsConfigs.d.ts +5 -5
- package/build/esm/bundle/toolbar/utils/toolbarsConfigs.js +1 -1
- package/build/esm/bundle/toolbar/wysiwyg/WToolbarColors.d.ts +2 -2
- package/build/esm/bundle/toolbar/wysiwyg/WToolbarTextSelect.d.ts +2 -2
- package/build/esm/bundle/toolbar/wysiwyg/WToolbarTextSelect.js +1 -1
- package/build/esm/extensions/additional/GPT/MarkupGpt/toolbar.d.ts +1 -1
- package/build/esm/extensions/additional/GPT/MarkupGpt/toolbar.js +1 -1
- package/build/esm/extensions/additional/GPT/wGptItemData.d.ts +1 -1
- package/build/esm/extensions/additional/GPT/wGptItemData.js +1 -1
- package/build/esm/extensions/additional/Mermaid/MermaidSpecs/index.js +4 -3
- package/build/esm/extensions/base/BaseSchema/BaseSchemaSpecs/index.js +13 -1
- package/build/esm/extensions/behavior/SelectionContext/tooltip.d.ts +5 -5
- package/build/esm/extensions/behavior/SelectionContext/tooltip.js +1 -1
- package/build/esm/extensions/markdown/Image/index.d.ts +1 -1
- package/build/esm/extensions/markdown/Link/LinkSpecs/index.js +1 -1
- package/build/esm/extensions/markdown/Link/PlaceholderWidget/descriptor.d.ts +3 -3
- package/build/esm/extensions/markdown/Link/PlaceholderWidget/descriptor.js +2 -1
- package/build/esm/extensions/markdown/Link/actions/linkEnhanceActions.d.ts +2 -2
- package/build/esm/extensions/markdown/Link/actions/linkEnhanceActions.js +3 -1
- package/build/esm/extensions/markdown/Link/commands.js +1 -1
- package/build/esm/extensions/markdown/Table/actions/innerActions.d.ts +1 -1
- package/build/esm/extensions/markdown/Table/plugins/TableCellContextPlugin/index.js +1 -1
- package/build/esm/extensions/yfm/ImgSize/index.d.ts +3 -3
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/index.d.ts +2 -10
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/schema.d.ts +11 -2
- package/build/esm/extensions/yfm/YfmTable/YfmTableSpecs/index.d.ts +2 -7
- package/build/esm/extensions/yfm/YfmTable/YfmTableSpecs/schema.d.ts +7 -2
- package/build/esm/extensions/yfm/YfmTabs/YfmTabsSpecs/index.d.ts +2 -6
- package/build/esm/extensions/yfm/YfmTabs/YfmTabsSpecs/schema.d.ts +8 -3
- package/build/esm/extensions/yfm/YfmTabs/actions.js +1 -3
- package/build/esm/extensions/yfm/YfmTabs/const.d.ts +5 -2
- package/build/esm/extensions/yfm/YfmTabs/const.js +6 -3
- package/build/esm/extensions/yfm/YfmTabs/plugins.d.ts +2 -2
- package/build/esm/extensions/yfm/YfmTabs/plugins.js +17 -98
- package/build/esm/extensions/yfm/YfmTabs/utils.d.ts +4 -1
- package/build/esm/extensions/yfm/YfmTabs/utils.js +18 -1
- package/build/esm/extensions/yfm/YfmTabs/views.d.ts +1 -1
- package/build/esm/extensions/yfm/YfmTabs/views.js +24 -4
- package/build/esm/i18n/menubar/index.d.ts +1 -1
- package/build/esm/i18n/placeholder/index.d.ts +1 -1
- package/build/esm/i18n/yfm-note/index.d.ts +1 -1
- package/build/esm/markup/codemirror/html-to-markdown/handlers.d.ts +1 -1
- package/build/esm/markup/codemirror/search-plugin/plugin.d.ts +6 -16
- package/build/esm/markup/codemirror/search-plugin/plugin.js +8 -9
- package/build/esm/markup/codemirror/search-plugin/view/SearchPopup.d.ts +6 -10
- package/build/esm/markup/codemirror/search-plugin/view/SearchPopup.js +13 -13
- package/build/esm/markup/codemirror/yfm.d.ts +1 -1
- package/build/esm/markup/editor.d.ts +1 -1
- package/build/esm/react-utils/react-node-view.d.ts +2 -2
- package/build/esm/react-utils/react-node-view.js +1 -1
- package/build/esm/table-utils/commands/appendColumn.js +1 -1
- package/build/esm/table-utils/commands/appendRow.js +1 -1
- package/build/esm/table-utils/commands/removeRow.js +1 -1
- package/build/esm/toolbar/FlexToolbar.d.ts +2 -2
- package/build/esm/toolbar/Toolbar.d.ts +2 -3
- package/build/esm/toolbar/ToolbarGroup.d.ts +2 -2
- package/build/esm/toolbar/ToolbarListButton.d.ts +2 -9
- package/build/esm/toolbar/flexible.d.ts +1 -2
- package/build/esm/toolbar/index.d.ts +0 -1
- package/build/esm/toolbar/index.js +0 -1
- package/build/esm/toolbar/types.d.ts +10 -1
- package/build/esm/version.js +1 -1
- package/package.json +3 -1
|
@@ -39,12 +39,12 @@ class TabsAutoSwitchOnDragOver {
|
|
|
39
39
|
const pos = view.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
40
40
|
if (pos) {
|
|
41
41
|
const elem = (0, prosemirror_utils_1.findDomRefAtPos)(pos.pos, view.domAtPos.bind(view));
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
42
|
+
const tabElem = elem.closest(TabsAutoSwitchOnDragOver.TAB_SELECTOR);
|
|
43
|
+
if (tabElem === this._tabElem)
|
|
44
44
|
return;
|
|
45
45
|
this._clear();
|
|
46
|
-
if (
|
|
47
|
-
this._setTabElem(
|
|
46
|
+
if (tabElem)
|
|
47
|
+
this._setTabElem(tabElem);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
_clear() {
|
|
@@ -59,29 +59,7 @@ class TabsAutoSwitchOnDragOver {
|
|
|
59
59
|
}
|
|
60
60
|
_switchTab() {
|
|
61
61
|
if (this._editorView.dragging && this._tabElem) {
|
|
62
|
-
|
|
63
|
-
const $pos = this._editorView.state.doc.resolve(pos);
|
|
64
|
-
const { state } = this._editorView;
|
|
65
|
-
let { depth } = $pos;
|
|
66
|
-
let tabId = '';
|
|
67
|
-
let tabsNode = null;
|
|
68
|
-
do {
|
|
69
|
-
const node = $pos.node(depth);
|
|
70
|
-
if (node.type === (0, const_2.tabType)(state.schema)) {
|
|
71
|
-
tabId = node.attrs[const_1.TabAttrs.dataDiplodocid];
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
if (node.type === (0, const_2.tabsType)(state.schema)) {
|
|
75
|
-
tabsNode = { node, pos: $pos.before(depth) };
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
} while (--depth >= 0);
|
|
79
|
-
if (tabId && tabsNode) {
|
|
80
|
-
const { tr } = state;
|
|
81
|
-
if (switchYfmTab(tabsNode, tabId, tr)) {
|
|
82
|
-
this._editorView.dispatch(tr.setMeta('addToHistory', false));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
62
|
+
(0, utils_3.switchTabByElem)(this._tabElem);
|
|
85
63
|
}
|
|
86
64
|
this._clear();
|
|
87
65
|
}
|
|
@@ -91,49 +69,6 @@ TabsAutoSwitchOnDragOver.TAB_SELECTOR = '.yfm-tab:not([data-diplodoc-is-active=t
|
|
|
91
69
|
TabsAutoSwitchOnDragOver.OPEN_TIMEOUT = 500; //ms
|
|
92
70
|
TabsAutoSwitchOnDragOver.THROTTLE_WAIT = 50; //ms
|
|
93
71
|
TabsAutoSwitchOnDragOver.view = (view) => new _a(view);
|
|
94
|
-
function switchYfmTab({ node: tabsNode, pos: tabsPos }, tabId, tr) {
|
|
95
|
-
const { schema } = tabsNode.type;
|
|
96
|
-
if (tabsNode.type !== (0, const_2.tabsType)(schema))
|
|
97
|
-
return false;
|
|
98
|
-
const tabsList = tabsNode.firstChild;
|
|
99
|
-
if ((tabsList === null || tabsList === void 0 ? void 0 : tabsList.type) !== (0, const_2.tabsListType)(schema))
|
|
100
|
-
return false;
|
|
101
|
-
const tabsListPos = tabsPos + 1;
|
|
102
|
-
let panelId = null;
|
|
103
|
-
tabsList.forEach((node, offset) => {
|
|
104
|
-
if (node.type !== (0, const_2.tabType)(schema))
|
|
105
|
-
return;
|
|
106
|
-
const tabPos = tabsListPos + 1 + offset;
|
|
107
|
-
const tabAttrs = Object.assign(Object.assign({}, node.attrs), { [const_1.TabAttrs.ariaSelected]: 'false', [const_1.TabAttrs.dataDiplodocIsActive]: 'false' });
|
|
108
|
-
if (node.attrs[const_1.TabAttrs.dataDiplodocid] === tabId) {
|
|
109
|
-
panelId = node.attrs[const_1.TabAttrs.ariaControls];
|
|
110
|
-
tabAttrs[const_1.TabAttrs.ariaSelected] = 'true';
|
|
111
|
-
tabAttrs[const_1.TabAttrs.dataDiplodocIsActive] = 'true';
|
|
112
|
-
}
|
|
113
|
-
tr.setNodeMarkup(tabPos, null, tabAttrs);
|
|
114
|
-
});
|
|
115
|
-
if (!panelId)
|
|
116
|
-
return false;
|
|
117
|
-
tabsNode.forEach((node, offset) => {
|
|
118
|
-
var _b;
|
|
119
|
-
if (node.type !== (0, const_2.tabPanelType)(schema))
|
|
120
|
-
return;
|
|
121
|
-
const tabPanelPos = tabsPos + 1 + offset;
|
|
122
|
-
const tabPanelAttrs = Object.assign({}, node.attrs);
|
|
123
|
-
const tabPanelClassList = new Set(((_b = node.attrs[const_1.TabPanelAttrs.class]) !== null && _b !== void 0 ? _b : '')
|
|
124
|
-
.split(' ')
|
|
125
|
-
.filter((val) => Boolean(val.trim())));
|
|
126
|
-
if (node.attrs[const_1.TabPanelAttrs.id] === panelId) {
|
|
127
|
-
tabPanelClassList.add('active');
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
tabPanelClassList.delete('active');
|
|
131
|
-
}
|
|
132
|
-
tabPanelAttrs[const_1.TabPanelAttrs.class] = Array.from(tabPanelClassList).join(' ');
|
|
133
|
-
tr.setNodeMarkup(tabPanelPos, null, tabPanelAttrs);
|
|
134
|
-
});
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
72
|
const tabPanelArrowDown = (state, dispatch, view) => {
|
|
138
73
|
var _b;
|
|
139
74
|
const { selection: sel } = state;
|
|
@@ -189,22 +124,6 @@ const liftEmptyBlockFromTabPanel = (state, dispatch) => {
|
|
|
189
124
|
return false;
|
|
190
125
|
};
|
|
191
126
|
exports.liftEmptyBlockFromTabPanel = liftEmptyBlockFromTabPanel;
|
|
192
|
-
const makeTabsInactive = (tabNodes, tabPanels, tr) => {
|
|
193
|
-
// Find all active tabs and make them inactive
|
|
194
|
-
const activeTabs = tabNodes.filter((v) => v.node.attrs[const_1.TabAttrs.dataDiplodocIsActive] === 'true');
|
|
195
|
-
if (activeTabs.length) {
|
|
196
|
-
activeTabs.forEach((tab) => {
|
|
197
|
-
tr.setNodeMarkup(tab.pos, null, Object.assign(Object.assign({}, tab.node.attrs), { class: const_2.tabInactiveClassname, [const_1.TabAttrs.dataDiplodocIsActive]: 'false' }));
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
// Find all active panels and make them inactive
|
|
201
|
-
const activePanels = tabPanels.filter((v) => v.node.attrs[const_1.TabPanelAttrs.class] === const_2.tabPanelActiveClassname);
|
|
202
|
-
if (activePanels.length) {
|
|
203
|
-
activePanels.forEach((tabPanel) => {
|
|
204
|
-
tr.setNodeMarkup(tr.mapping.map(tabPanel.pos), null, Object.assign(Object.assign({}, tabPanel.node.attrs), { class: const_2.tabPanelInactiveClassname }));
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
127
|
const createTab = (afterTab, tabsParentNode) => (state, dispatch, view) => {
|
|
209
128
|
const tabNodes = (0, prosemirror_utils_1.findChildren)(tabsParentNode.node, (node) => node.type.name === (0, const_2.tabType)(state.schema).name);
|
|
210
129
|
const tabPanels = (0, prosemirror_utils_1.findChildren)(tabsParentNode.node, (tabNode) => {
|
|
@@ -217,14 +136,14 @@ const createTab = (afterTab, tabsParentNode) => (state, dispatch, view) => {
|
|
|
217
136
|
const newPanel = (0, const_2.tabPanelType)(state.schema).create({
|
|
218
137
|
[const_1.TabPanelAttrs.ariaLabelledby]: tabId,
|
|
219
138
|
[const_1.TabPanelAttrs.id]: panelId,
|
|
220
|
-
[const_1.TabPanelAttrs.class]: const_2.
|
|
139
|
+
[const_1.TabPanelAttrs.class]: const_2.tabPanelInactiveClassname,
|
|
221
140
|
}, (0, __1.pType)(state.schema).createAndFill());
|
|
222
141
|
const newTab = (0, const_2.tabType)(state.schema).create({
|
|
223
142
|
[const_1.TabAttrs.id]: tabId,
|
|
224
143
|
[const_1.TabAttrs.dataDiplodocid]: tabId,
|
|
225
144
|
[const_1.TabAttrs.dataDiplodocKey]: tabId,
|
|
226
|
-
[const_1.TabAttrs.dataDiplodocIsActive]: '
|
|
227
|
-
[const_1.TabAttrs.class]: const_2.
|
|
145
|
+
[const_1.TabAttrs.dataDiplodocIsActive]: 'false',
|
|
146
|
+
[const_1.TabAttrs.class]: const_2.tabInactiveClassname,
|
|
228
147
|
[const_1.TabAttrs.role]: 'tab',
|
|
229
148
|
[const_1.TabAttrs.ariaControls]: panelId,
|
|
230
149
|
});
|
|
@@ -236,12 +155,14 @@ const createTab = (afterTab, tabsParentNode) => (state, dispatch, view) => {
|
|
|
236
155
|
tabPanels.forEach((v) => {
|
|
237
156
|
v.pos = v.pos + tabsParentNode.pos + 1;
|
|
238
157
|
});
|
|
239
|
-
makeTabsInactive(tabNodes, tabPanels, tr);
|
|
240
158
|
dispatch === null || dispatch === void 0 ? void 0 : dispatch(tr
|
|
241
159
|
.insert(afterPanelNode.pos + afterPanelNode.node.nodeSize, newPanel)
|
|
242
160
|
.insert(afterTab.pos + afterTab.node.nodeSize, newTab)
|
|
243
161
|
.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, afterTab.pos + afterTab.node.nodeSize + 1)));
|
|
244
162
|
view === null || view === void 0 ? void 0 : view.focus();
|
|
163
|
+
if (view) {
|
|
164
|
+
(0, utils_3.execAfterPaint)(() => (0, utils_3.switchTabById)(view.dom, tabId));
|
|
165
|
+
}
|
|
245
166
|
return true;
|
|
246
167
|
};
|
|
247
168
|
exports.createTab = createTab;
|
|
@@ -271,18 +192,16 @@ const removeTab = (tabToRemove, tabsParentNode) => (state, dispatch, view) => {
|
|
|
271
192
|
v.pos = v.pos + tabsParentNode.pos + 1;
|
|
272
193
|
});
|
|
273
194
|
const newTabNode = tabNodes[newTabIdx];
|
|
274
|
-
const
|
|
275
|
-
makeTabsInactive(tabNodes, tabPanels, tr);
|
|
195
|
+
const newActiveTabId = newTabNode.node.attrs[const_1.TabAttrs.dataDiplodocid];
|
|
276
196
|
tr
|
|
277
197
|
// Delete panel
|
|
278
198
|
.delete(panelToRemove.pos, panelToRemove.pos + panelToRemove.node.nodeSize)
|
|
279
199
|
// Delete tab
|
|
280
200
|
.delete(tabToRemove.pos, tabToRemove.pos + tabToRemove.node.nodeSize)
|
|
281
|
-
// Set new active tab
|
|
282
|
-
.setNodeMarkup(tr.mapping.map(newTabNode.pos), null, Object.assign(Object.assign({}, newTabNode.node.attrs), { class: const_2.tabActiveClassname, [const_1.TabAttrs.dataDiplodocIsActive]: 'true' }))
|
|
283
|
-
// Set new active panel
|
|
284
|
-
.setNodeMarkup(tr.mapping.map(newTabPanelNode.pos), null, Object.assign(Object.assign({}, newTabPanelNode.node.attrs), { class: const_2.tabPanelActiveClassname }))
|
|
285
201
|
.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, tr.mapping.map(newTabNode.pos + newTabNode.node.nodeSize - 1)));
|
|
202
|
+
// Set new active tab
|
|
203
|
+
if (view)
|
|
204
|
+
(0, utils_3.execAfterPaint)(() => (0, utils_3.switchTabById)(view.dom, newActiveTabId));
|
|
286
205
|
}
|
|
287
206
|
dispatch(tr);
|
|
288
207
|
view === null || view === void 0 ? void 0 : view.focus();
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import { EditorView } from 'prosemirror-view';
|
|
1
|
+
import type { EditorView } from 'prosemirror-view';
|
|
2
|
+
export declare const execAfterPaint: (fn: () => void) => void;
|
|
2
3
|
export declare const atEndOfPanel: (view?: EditorView) => number | false | null;
|
|
4
|
+
export declare const switchTabByElem: (tabElem: HTMLElement) => void;
|
|
5
|
+
export declare const switchTabById: (container: HTMLElement, tabId: string) => void;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.atEndOfPanel = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.switchTabById = exports.switchTabByElem = exports.atEndOfPanel = exports.execAfterPaint = void 0;
|
|
4
|
+
const const_1 = require("./const");
|
|
5
|
+
const execAfterPaint = (fn) => {
|
|
6
|
+
requestAnimationFrame(() => {
|
|
7
|
+
requestAnimationFrame(fn);
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
exports.execAfterPaint = execAfterPaint;
|
|
5
11
|
const atEndOfPanel = (view) => {
|
|
6
12
|
if (!view)
|
|
7
13
|
return null;
|
|
@@ -10,7 +16,7 @@ const atEndOfPanel = (view) => {
|
|
|
10
16
|
const parent = $head.node(d), index = $head.indexAfter(d);
|
|
11
17
|
if (index !== parent.childCount)
|
|
12
18
|
return false;
|
|
13
|
-
if (parent.type === (0,
|
|
19
|
+
if (parent.type === (0, const_1.tabPanelType)(view.state.schema)) {
|
|
14
20
|
const panelPos = $head.before(d);
|
|
15
21
|
return (view === null || view === void 0 ? void 0 : view.endOfTextblock('down')) ? panelPos : null;
|
|
16
22
|
}
|
|
@@ -18,3 +24,17 @@ const atEndOfPanel = (view) => {
|
|
|
18
24
|
return null;
|
|
19
25
|
};
|
|
20
26
|
exports.atEndOfPanel = atEndOfPanel;
|
|
27
|
+
const switchTabByElem = (tabElem) => {
|
|
28
|
+
if (tabElem.classList.contains(const_1.YFM_TAB_CLASSNAME)) {
|
|
29
|
+
tabElem.click();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.switchTabByElem = switchTabByElem;
|
|
33
|
+
const switchTabById = (container, tabId) => {
|
|
34
|
+
const selector = `.${const_1.YFM_TAB_CLASSNAME}[${const_1.DIPLODOC_ID_ATTR}="${tabId}"]`;
|
|
35
|
+
const tabElem = container.querySelector(selector);
|
|
36
|
+
if (tabElem) {
|
|
37
|
+
(0, exports.switchTabByElem)(tabElem);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.switchTabById = switchTabById;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeViewConstructor } from 'prosemirror-view';
|
|
1
|
+
import { type NodeViewConstructor } from 'prosemirror-view';
|
|
2
2
|
export declare const tabView: NodeViewConstructor;
|
|
3
3
|
export declare const tabPanelView: NodeViewConstructor;
|
|
4
4
|
export declare const vtabView: NodeViewConstructor;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.vtabInputView = exports.vtabView = exports.tabPanelView = exports.tabView = void 0;
|
|
4
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
4
5
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
5
6
|
const classname_1 = require("../../../classname");
|
|
7
|
+
const const_1 = require("./const");
|
|
6
8
|
const icons_1 = require("./icons");
|
|
7
9
|
const plugins_1 = require("./plugins");
|
|
8
|
-
const
|
|
10
|
+
const utils_1 = require("./utils");
|
|
9
11
|
const cnYfmTab = (0, classname_1.cn)('yfm-tab');
|
|
10
|
-
const ignoreMutation = (
|
|
12
|
+
const ignoreMutation = (_node, _view, _getPos) => (mutation) => {
|
|
11
13
|
if (mutation instanceof MutationRecord &&
|
|
12
14
|
mutation.type === 'attributes' &&
|
|
13
15
|
mutation.attributeName) {
|
|
14
|
-
const newAttr = mutation.target.getAttribute(mutation.attributeName);
|
|
15
|
-
view.dispatch(view.state.tr.setNodeMarkup(getPos(), null, Object.assign(Object.assign({}, node.attrs), { [mutation.attributeName]: newAttr })));
|
|
16
16
|
return true;
|
|
17
17
|
}
|
|
18
18
|
return false;
|
|
19
19
|
};
|
|
20
20
|
const getTabNodes = (state, getPos) => {
|
|
21
|
-
const currentTab = (0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)(state.tr.doc.resolve(getPos() + 1), (0,
|
|
22
|
-
const tabsParentNode = (0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)(state.tr.doc.resolve(getPos()), (0,
|
|
21
|
+
const currentTab = (0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)(state.tr.doc.resolve(getPos() + 1), (0, const_1.tabType)(state.schema));
|
|
22
|
+
const tabsParentNode = (0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)(state.tr.doc.resolve(getPos()), (0, const_1.tabsType)(state.schema));
|
|
23
23
|
return { currentTab, tabsParentNode };
|
|
24
24
|
};
|
|
25
25
|
const tabView = (node, view, getPos) => {
|
|
@@ -31,6 +31,26 @@ const tabView = (node, view, getPos) => {
|
|
|
31
31
|
wrapperElem.addEventListener('click', () => {
|
|
32
32
|
// Click on parent node to trigger event listener that selects current tab
|
|
33
33
|
tabElem.click();
|
|
34
|
+
{
|
|
35
|
+
/**
|
|
36
|
+
* Hack for empty tabs
|
|
37
|
+
*
|
|
38
|
+
* Problem: when clicking on an empty tab (without text content) it focuses, and selection doesn't move to beginning of tab
|
|
39
|
+
*
|
|
40
|
+
* Temporary fix: manually return focus to pm-view, move text selection to beginning of tab
|
|
41
|
+
*/
|
|
42
|
+
view.focus();
|
|
43
|
+
// tab is empty
|
|
44
|
+
if (node.nodeSize < 3) {
|
|
45
|
+
(0, utils_1.execAfterPaint)(() => {
|
|
46
|
+
const pos = getPos();
|
|
47
|
+
if (pos !== undefined) {
|
|
48
|
+
const { tr } = view.state;
|
|
49
|
+
view.dispatch(tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, pos + 1)).scrollIntoView());
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
34
54
|
});
|
|
35
55
|
const removeTabButton = document.createElement('div');
|
|
36
56
|
removeTabButton.setAttribute('class', cnYfmTab('remove-button'));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const i18n: <G extends "bold" | "code" | "
|
|
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" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "emoji" | "tabs" | "math" | "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" | "emoji__hint" | "folding-heading" | "folding-heading__hint" | "hrule" | "list__action_lift" | "list__action_sink" | "list_action_disabled" | "mermaid" | "more_action" | "move_list" | "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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const i18n: <G extends "block" | "heading" | "
|
|
1
|
+
export declare const i18n: <G extends "block" | "heading" | "codeblock" | "doc_empty" | "checkbox" | "deflist_term" | "deflist_desc" | "cut_title" | "cut_content" | "note_title" | "note_content" | "layout_cell" | "table_cell" | "select_filter", S extends string>(key: G | (string extends S ? S : never), params?: {
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
} | undefined) => S extends G ? {
|
|
4
4
|
doc_empty: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const i18n: <G extends "remove" | "info" | "
|
|
1
|
+
export declare const i18n: <G extends "remove" | "info" | "alert" | "tip" | "warning", S extends string>(key: G | (string extends S ? S : never), params?: {
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
} | undefined) => S extends G ? {
|
|
4
4
|
info: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HTMLNodeVisitor } from './converters';
|
|
1
|
+
import type { HTMLNodeVisitor } from './converters';
|
|
2
2
|
/**
|
|
3
3
|
* Base handler class implementing the Chain of Responsibility pattern for HTML node processing.
|
|
4
4
|
* Each concrete handler decides whether it can process a node or should pass it to the next handler.
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
+
import { SearchQuery } from '@codemirror/search';
|
|
1
2
|
import { EditorView, ViewPlugin, ViewUpdate } from '@codemirror/view';
|
|
2
3
|
import type { MarkdownEditorMode } from '../../../bundle';
|
|
3
4
|
import type { EventMap } from '../../../bundle/Editor';
|
|
4
5
|
import type { RendererItem } from '../../../extensions';
|
|
5
6
|
import { Receiver } from '../../../utils';
|
|
6
|
-
|
|
7
|
-
search: string;
|
|
8
|
-
caseSensitive?: boolean;
|
|
9
|
-
literal?: boolean;
|
|
10
|
-
regexp?: boolean;
|
|
11
|
-
replace?: string;
|
|
12
|
-
valid?: boolean;
|
|
13
|
-
wholeWord?: boolean;
|
|
14
|
-
}
|
|
7
|
+
declare type SearchQueryConfig = ConstructorParameters<typeof SearchQuery>[0];
|
|
15
8
|
export interface SearchPanelPluginParams {
|
|
16
9
|
anchorSelector: string;
|
|
17
10
|
inputDelay?: number;
|
|
@@ -22,12 +15,12 @@ export declare const SearchPanelPlugin: (params: SearchPanelPluginParams) => Vie
|
|
|
22
15
|
readonly params: SearchPanelPluginParams;
|
|
23
16
|
anchor: HTMLElement | null;
|
|
24
17
|
renderer: RendererItem | null;
|
|
25
|
-
|
|
18
|
+
searchConfig: SearchQueryConfig;
|
|
26
19
|
receiver: Receiver<EventMap> | undefined;
|
|
27
|
-
setViewSearchWithDelay: (config: Partial<
|
|
20
|
+
setViewSearchWithDelay: (config: Partial<SearchQueryConfig>) => void;
|
|
28
21
|
update(update: ViewUpdate): void;
|
|
29
22
|
destroy(): void;
|
|
30
|
-
setViewSearch(config: Partial<
|
|
23
|
+
setViewSearch(config: Partial<SearchQueryConfig>): void;
|
|
31
24
|
handleEditorModeChange({ mode }: {
|
|
32
25
|
mode: MarkdownEditorMode;
|
|
33
26
|
}): void;
|
|
@@ -35,9 +28,6 @@ export declare const SearchPanelPlugin: (params: SearchPanelPluginParams) => Vie
|
|
|
35
28
|
handleClose(): void;
|
|
36
29
|
handleSearchNext(): void;
|
|
37
30
|
handleSearchPrev(): void;
|
|
38
|
-
handleSearchConfigChange(
|
|
39
|
-
isCaseSensitive?: boolean | undefined;
|
|
40
|
-
isWholeWord?: boolean | undefined;
|
|
41
|
-
}): void;
|
|
31
|
+
handleSearchConfigChange(config: Partial<SearchQueryConfig>): void;
|
|
42
32
|
}>;
|
|
43
33
|
export {};
|
|
@@ -10,7 +10,7 @@ const INPUT_DELAY = 200;
|
|
|
10
10
|
const SearchPanelPlugin = (params) => view_1.ViewPlugin.fromClass(class {
|
|
11
11
|
constructor(view) {
|
|
12
12
|
var _a, _b;
|
|
13
|
-
this.
|
|
13
|
+
this.searchConfig = {
|
|
14
14
|
search: '',
|
|
15
15
|
caseSensitive: false,
|
|
16
16
|
wholeWord: false,
|
|
@@ -33,10 +33,12 @@ const SearchPanelPlugin = (params) => view_1.ViewPlugin.fromClass(class {
|
|
|
33
33
|
var _a;
|
|
34
34
|
const isPanelOpen = (0, search_1.searchPanelOpen)(update.state);
|
|
35
35
|
if (isPanelOpen && !this.renderer) {
|
|
36
|
+
const initial = (0, search_1.getSearchQuery)(update.state);
|
|
36
37
|
this.anchor = document.querySelector(this.params.anchorSelector);
|
|
37
38
|
this.renderer = this.view.state
|
|
38
39
|
.facet(react_facet_1.ReactRendererFacet)
|
|
39
40
|
.createItem('cm-search', () => (0, SearchPopup_1.renderSearchPopup)({
|
|
41
|
+
initial,
|
|
40
42
|
open: true,
|
|
41
43
|
anchor: this.anchor,
|
|
42
44
|
onChange: this.handleChange,
|
|
@@ -58,8 +60,8 @@ const SearchPanelPlugin = (params) => view_1.ViewPlugin.fromClass(class {
|
|
|
58
60
|
(_b = this.receiver) === null || _b === void 0 ? void 0 : _b.off('change-editor-mode', this.handleEditorModeChange);
|
|
59
61
|
}
|
|
60
62
|
setViewSearch(config) {
|
|
61
|
-
this.
|
|
62
|
-
const searchQuery = new search_1.SearchQuery(Object.assign({}, this.
|
|
63
|
+
this.searchConfig = Object.assign(Object.assign({}, this.searchConfig), config);
|
|
64
|
+
const searchQuery = new search_1.SearchQuery(Object.assign({}, this.searchConfig));
|
|
63
65
|
this.view.dispatch({ effects: search_1.setSearchQuery.of(searchQuery) });
|
|
64
66
|
}
|
|
65
67
|
handleEditorModeChange({ mode }) {
|
|
@@ -80,11 +82,8 @@ const SearchPanelPlugin = (params) => view_1.ViewPlugin.fromClass(class {
|
|
|
80
82
|
handleSearchPrev() {
|
|
81
83
|
(0, search_1.findPrevious)(this.view);
|
|
82
84
|
}
|
|
83
|
-
handleSearchConfigChange(
|
|
84
|
-
this.setViewSearch(
|
|
85
|
-
caseSensitive: isCaseSensitive,
|
|
86
|
-
wholeWord: isWholeWord,
|
|
87
|
-
});
|
|
85
|
+
handleSearchConfigChange(config) {
|
|
86
|
+
this.setViewSearch(config);
|
|
88
87
|
}
|
|
89
88
|
}, {
|
|
90
89
|
provide: () => [
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
2
|
+
import type { SearchQuery } from '@codemirror/search';
|
|
3
|
+
declare type SearchInitial = Pick<SearchQuery, 'search' | 'caseSensitive' | 'wholeWord'>;
|
|
4
|
+
declare type SearchConfig = Pick<SearchInitial, 'caseSensitive' | 'wholeWord'>;
|
|
6
5
|
interface SearchCardProps {
|
|
6
|
+
initial: SearchInitial;
|
|
7
7
|
onSearchKeyDown?: (query: string) => void;
|
|
8
8
|
onChange?: (query: string) => void;
|
|
9
9
|
onClose?: (query: string) => void;
|
|
@@ -12,14 +12,10 @@ interface SearchCardProps {
|
|
|
12
12
|
onConfigChange?: (config: SearchConfig) => void;
|
|
13
13
|
}
|
|
14
14
|
export declare const SearchCard: React.FC<SearchCardProps>;
|
|
15
|
-
export interface SearchPopupProps {
|
|
15
|
+
export interface SearchPopupProps extends SearchCardProps {
|
|
16
|
+
open: boolean;
|
|
16
17
|
anchor: HTMLElement;
|
|
17
|
-
onChange: (query: string) => void;
|
|
18
18
|
onClose: () => void;
|
|
19
|
-
onSearchNext: () => void;
|
|
20
|
-
onSearchPrev: () => void;
|
|
21
|
-
onConfigChange: (config: SearchConfig) => void;
|
|
22
|
-
open: boolean;
|
|
23
19
|
}
|
|
24
20
|
export declare const SearchPopup: React.FC<SearchPopupProps>;
|
|
25
21
|
interface SearchPopupWithRefProps extends Omit<SearchPopupProps, 'anchor'> {
|
|
@@ -10,17 +10,17 @@ const search_1 = require("../../../../i18n/search");
|
|
|
10
10
|
const handlers_1 = require("../../../../utils/handlers");
|
|
11
11
|
const b = (0, classname_1.cn)('search-card');
|
|
12
12
|
const noop = () => { };
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const [
|
|
16
|
-
const [
|
|
13
|
+
const inverse = (val) => !val;
|
|
14
|
+
const SearchCard = ({ initial, onChange = noop, onClose = noop, onSearchPrev = noop, onSearchNext = noop, onConfigChange = noop, }) => {
|
|
15
|
+
const [query, setQuery] = (0, react_1.useState)(initial.search);
|
|
16
|
+
const [isCaseSensitive, setIsCaseSensitive] = (0, react_1.useState)(initial.caseSensitive);
|
|
17
|
+
const [isWholeWord, setIsWholeWord] = (0, react_1.useState)(initial.wholeWord);
|
|
17
18
|
const textInputRef = (0, react_1.useRef)(null);
|
|
18
19
|
const setInputFocus = () => {
|
|
19
20
|
var _a;
|
|
20
21
|
(_a = textInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
21
22
|
};
|
|
22
|
-
const handleInputChange = (
|
|
23
|
-
const { target: { value }, } = event;
|
|
23
|
+
const handleInputChange = (value) => {
|
|
24
24
|
setQuery(value);
|
|
25
25
|
onChange(value);
|
|
26
26
|
};
|
|
@@ -39,18 +39,18 @@ const SearchCard = ({ onChange = noop, onClose = noop, onSearchPrev = noop, onSe
|
|
|
39
39
|
};
|
|
40
40
|
const handleIsCaseSensitive = () => {
|
|
41
41
|
onConfigChange({
|
|
42
|
-
|
|
43
|
-
isWholeWord,
|
|
42
|
+
caseSensitive: !isCaseSensitive,
|
|
43
|
+
wholeWord: isWholeWord,
|
|
44
44
|
});
|
|
45
|
-
setIsCaseSensitive(
|
|
45
|
+
setIsCaseSensitive(inverse);
|
|
46
46
|
setInputFocus();
|
|
47
47
|
};
|
|
48
48
|
const handleIsWholeWord = () => {
|
|
49
49
|
onConfigChange({
|
|
50
|
-
isCaseSensitive,
|
|
51
|
-
|
|
50
|
+
caseSensitive: isCaseSensitive,
|
|
51
|
+
wholeWord: !isWholeWord,
|
|
52
52
|
});
|
|
53
|
-
setIsWholeWord(
|
|
53
|
+
setIsWholeWord(inverse);
|
|
54
54
|
setInputFocus();
|
|
55
55
|
};
|
|
56
56
|
const handleSearchKeyPress = (0, handlers_1.enterKeyHandler)(handleNext);
|
|
@@ -61,7 +61,7 @@ const SearchCard = ({ onChange = noop, onClose = noop, onSearchPrev = noop, onSe
|
|
|
61
61
|
(0, search_1.i18n)('title')),
|
|
62
62
|
react_1.default.createElement(uikit_1.Button, { onClick: handleClose, size: "s", view: "flat" },
|
|
63
63
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Xmark, size: 14 }))),
|
|
64
|
-
react_1.default.createElement(uikit_1.TextInput, { controlRef: textInputRef, className: (0, uikit_1.sp)({ mb: 2 }), size: "s", autoFocus: true, onKeyPress: handleSearchKeyPress,
|
|
64
|
+
react_1.default.createElement(uikit_1.TextInput, { controlRef: textInputRef, className: (0, uikit_1.sp)({ mb: 2 }), size: "s", autoFocus: true, onKeyPress: handleSearchKeyPress, onUpdate: handleInputChange, value: query, endContent: react_1.default.createElement(react_1.default.Fragment, null,
|
|
65
65
|
react_1.default.createElement(uikit_1.Button, { onClick: handlePrev },
|
|
66
66
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.ChevronUp, size: 12 })),
|
|
67
67
|
react_1.default.createElement(uikit_1.Button, { onClick: handleNext },
|
|
@@ -8,7 +8,7 @@ export declare const customTags: {
|
|
|
8
8
|
};
|
|
9
9
|
export declare type YfmNoteType = 'info' | 'tip' | 'warning' | 'alert';
|
|
10
10
|
export declare const yfmNoteTypes: readonly YfmNoteType[];
|
|
11
|
-
export declare const yfmNoteSnippetTemplate: (type: YfmNoteType) => "{% note info %}\n\n#{}\n\n{% endnote %}\n\n" | "{% note
|
|
11
|
+
export declare const yfmNoteSnippetTemplate: (type: YfmNoteType) => "{% note info %}\n\n#{}\n\n{% endnote %}\n\n" | "{% note alert %}\n\n#{}\n\n{% endnote %}\n\n" | "{% note tip %}\n\n#{}\n\n{% endnote %}\n\n" | "{% note warning %}\n\n#{}\n\n{% endnote %}\n\n";
|
|
12
12
|
export declare const yfmNoteSnippets: Record<YfmNoteType, ReturnType<typeof snippet>>;
|
|
13
13
|
export declare const yfmCutSnippetTemplate = "{% cut \"#{title}\" %}\n\n#{}\n\n{% endcut %}\n\n";
|
|
14
14
|
export declare const yfmCutSnippet: (editor: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Mark, Node } from 'prosemirror-model';
|
|
3
3
|
import type { EditorView, NodeView, NodeViewConstructor } from 'prosemirror-view';
|
|
4
|
-
import { ExtensionDeps, Serializer } from '../core';
|
|
4
|
+
import type { ExtensionDeps, Serializer } from '../core';
|
|
5
5
|
declare type ReactNodeViewOptions<T> = {
|
|
6
6
|
isInline?: boolean;
|
|
7
7
|
reactNodeWrapperCn?: string;
|
|
@@ -22,7 +22,7 @@ export declare class ReactNodeView<T extends object = {}> implements NodeView {
|
|
|
22
22
|
node: Node;
|
|
23
23
|
readonly view: EditorView;
|
|
24
24
|
readonly serializer: Serializer;
|
|
25
|
-
readonly renderItem: import("../extensions").RendererItem;
|
|
25
|
+
readonly renderItem: import("../extensions/behavior/ReactRenderer").RendererItem;
|
|
26
26
|
readonly getPos: () => number | undefined;
|
|
27
27
|
constructor(Component: React.FC<ReactNodeViewProps<T>>, opts: {
|
|
28
28
|
node: Node;
|
|
@@ -4,7 +4,7 @@ exports.reactNodeViewFactory = exports.ReactNodeView = exports.ReactNodeStopEven
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const react_dom_1 = require("react-dom");
|
|
7
|
-
const
|
|
7
|
+
const ReactRenderer_1 = require("../extensions/behavior/ReactRenderer");
|
|
8
8
|
exports.ReactNodeStopEventCn = 'prosemirror-stop-event';
|
|
9
9
|
class ReactNodeView {
|
|
10
10
|
constructor(Component, opts) {
|
|
@@ -21,7 +21,7 @@ class ReactNodeView {
|
|
|
21
21
|
this.serializer = serializer;
|
|
22
22
|
this.view = view;
|
|
23
23
|
this.getPos = getPos;
|
|
24
|
-
this.renderItem = (0,
|
|
24
|
+
this.renderItem = (0, ReactRenderer_1.getReactRendererFromState)(view.state).createItem(`${Component.displayName || this.node.type.name}-view`, () => (0, react_dom_1.createPortal)(react_1.default.createElement(Component, { dom: this.dom, view: this.view, updateAttributes: this.updateAttributes.bind(this), node: this.node, getPos: this.getPos.bind(this), serializer: this.serializer, extensionOptions: options === null || options === void 0 ? void 0 : options.extensionOptions }), this.dom));
|
|
25
25
|
}
|
|
26
26
|
update(node) {
|
|
27
27
|
if (node.type !== this.node.type)
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.appendColumn = void 0;
|
|
4
4
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
5
|
-
const __1 = require("..");
|
|
6
5
|
const table_desc_1 = require("../table-desc");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
7
|
const appendColumn = (state, dispatch, _, attrs) => {
|
|
8
8
|
if (!attrs)
|
|
9
9
|
return false;
|
|
10
10
|
const { tablePos, columnNumber, direction = 'after' } = attrs;
|
|
11
|
-
const res = (0, prosemirror_utils_1.findParentNodeClosestToPos)(state.doc.resolve(tablePos + 1),
|
|
11
|
+
const res = (0, prosemirror_utils_1.findParentNodeClosestToPos)(state.doc.resolve(tablePos + 1), utils_1.isTableNode);
|
|
12
12
|
if (!res)
|
|
13
13
|
return false;
|
|
14
14
|
const tableNode = res.node;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.appendRow = void 0;
|
|
4
4
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
5
|
-
const __1 = require("..");
|
|
6
5
|
const table_desc_1 = require("../table-desc");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
7
|
const appendRow = (state, dispatch, _, attrs) => {
|
|
8
8
|
if (!attrs)
|
|
9
9
|
return false;
|
|
10
10
|
const { tablePos, rowNumber, direction = 'after' } = attrs;
|
|
11
|
-
const res = (0, prosemirror_utils_1.findParentNodeClosestToPos)(state.doc.resolve(tablePos + 1),
|
|
11
|
+
const res = (0, prosemirror_utils_1.findParentNodeClosestToPos)(state.doc.resolve(tablePos + 1), utils_1.isTableNode);
|
|
12
12
|
if (!res)
|
|
13
13
|
return false;
|
|
14
14
|
const tableNode = res.node;
|
|
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.removeRow = void 0;
|
|
4
4
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
5
5
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
6
|
-
const __1 = require("..");
|
|
7
6
|
const core_1 = require("../../core");
|
|
8
7
|
const table_desc_1 = require("../table-desc");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
9
|
const removeRow = (state, dispatch, _, attrs = {}) => {
|
|
10
10
|
var _a;
|
|
11
11
|
const { tablePos, rowNumber } = attrs;
|
|
12
12
|
if (tablePos === undefined || rowNumber === undefined)
|
|
13
13
|
return false;
|
|
14
|
-
const tableNode = (_a = (0, prosemirror_utils_1.findParentNodeClosestToPos)(state.doc.resolve(tablePos + 1),
|
|
14
|
+
const tableNode = (_a = (0, prosemirror_utils_1.findParentNodeClosestToPos)(state.doc.resolve(tablePos + 1), utils_1.isTableNode)) === null || _a === void 0 ? void 0 : _a.node;
|
|
15
15
|
if (!tableNode)
|
|
16
16
|
return false;
|
|
17
17
|
const tableDesc = table_desc_1.TableDesc.create(tableNode);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ToolbarProps } from './Toolbar';
|
|
3
|
-
import { ToolbarItemData } from './types';
|
|
2
|
+
import { type ToolbarProps } from './Toolbar';
|
|
3
|
+
import { type ToolbarItemData } from './types';
|
|
4
4
|
export declare type FlexToolbarProps<E> = ToolbarProps<E> & {
|
|
5
5
|
dotsTitle: string | (() => string);
|
|
6
6
|
hiddenActions?: ToolbarItemData<E>[];
|