@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
|
@@ -56,7 +56,7 @@ export const BaseSchemaSpecs = (builder, opts) => {
|
|
|
56
56
|
An empty line is added only if there is some content in the parent element.
|
|
57
57
|
This is necessary in order to prevent an empty document with empty lines
|
|
58
58
|
*/
|
|
59
|
-
if (opts.preserveEmptyRows &&
|
|
59
|
+
if (opts.preserveEmptyRows && isEmptyString(node)) {
|
|
60
60
|
let isParentEmpty = true;
|
|
61
61
|
for (let index = 0; index < parent.content.childCount; index++) {
|
|
62
62
|
const parentChild = parent.content.child(index);
|
|
@@ -76,3 +76,15 @@ export const BaseSchemaSpecs = (builder, opts) => {
|
|
|
76
76
|
},
|
|
77
77
|
}));
|
|
78
78
|
};
|
|
79
|
+
const isEmptyString = (node) => {
|
|
80
|
+
var _a;
|
|
81
|
+
if (!node.content.size) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
if (node.childCount === 1 &&
|
|
85
|
+
node.child(0).type.name === 'text' &&
|
|
86
|
+
((_a = node.child(0).text) === null || _a === void 0 ? void 0 : _a.trim()) === '') {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PopupProps } from '@gravity-ui/uikit';
|
|
2
|
-
import { EditorState } from 'prosemirror-state';
|
|
3
|
-
import { EditorView } from 'prosemirror-view';
|
|
4
|
-
import { ActionStorage } from '../../../core';
|
|
5
|
-
import { ToolbarButtonPopupData, ToolbarGroupItemData, ToolbarSingleItemData } from '../../../toolbar';
|
|
1
|
+
import { type PopupProps } from '@gravity-ui/uikit';
|
|
2
|
+
import type { EditorState } from 'prosemirror-state';
|
|
3
|
+
import type { EditorView } from 'prosemirror-view';
|
|
4
|
+
import type { ActionStorage } from '../../../core';
|
|
5
|
+
import type { ToolbarButtonPopupData, ToolbarGroupItemData, ToolbarSingleItemData } from '../../../toolbar';
|
|
6
6
|
export declare type ContextGroupItemData = (ToolbarGroupItemData<ActionStorage> & {
|
|
7
7
|
condition?: (state: EditorState) => void;
|
|
8
8
|
}) | ((ToolbarSingleItemData<ActionStorage> | ToolbarButtonPopupData<ActionStorage>) & {
|
|
@@ -5,7 +5,7 @@ import { Popup } from '@gravity-ui/uikit';
|
|
|
5
5
|
import { isFunction } from '../../../lodash';
|
|
6
6
|
import { logger } from '../../../logger';
|
|
7
7
|
import { ErrorLoggerBoundary } from '../../../react-utils/ErrorBoundary';
|
|
8
|
-
import { Toolbar
|
|
8
|
+
import { Toolbar } from '../../../toolbar';
|
|
9
9
|
import { getReactRendererFromState } from '../ReactRenderer';
|
|
10
10
|
const SelectionTooltip = (_a) => {
|
|
11
11
|
var { show, poppupProps } = _a, toolbarProps = __rest(_a, ["show", "poppupProps"]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Action, ExtensionAuto } from '../../../core';
|
|
2
2
|
import { AddImageAttrs } from './actions';
|
|
3
3
|
import { addImageAction } from './const';
|
|
4
|
-
import { ImageUrlPasteOptions } from './imageUrlPaste';
|
|
4
|
+
import { type ImageUrlPasteOptions } from './imageUrlPaste';
|
|
5
5
|
export { imageNodeName, imageType, ImageAttr } from './ImageSpecs';
|
|
6
6
|
/** @deprecated Use `imageType` instead */
|
|
7
7
|
export declare const imgType: (schema: import("prosemirror-model").Schema<any, any>) => import("prosemirror-model").NodeType;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Transaction } from 'prosemirror-state';
|
|
3
|
-
import { EditorView } from 'prosemirror-view';
|
|
4
|
-
import { ExtensionDeps } from '../../../../core';
|
|
2
|
+
import type { Transaction } from 'prosemirror-state';
|
|
3
|
+
import type { EditorView } from 'prosemirror-view';
|
|
4
|
+
import type { ExtensionDeps } from '../../../../core';
|
|
5
5
|
import { ReactWidgetDescriptor } from '../../../behavior/WidgetDecoration/ReactWidgetDescriptor';
|
|
6
6
|
import { LinkPlaceholderWidgetProps } from './widget';
|
|
7
7
|
export declare const addPlaceholder: (tr: Transaction, deps: ExtensionDeps) => Transaction;
|
|
@@ -3,7 +3,8 @@ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { removeDecoration } from '../../../behavior/WidgetDecoration';
|
|
5
5
|
import { ReactWidgetDescriptor } from '../../../behavior/WidgetDecoration/ReactWidgetDescriptor';
|
|
6
|
-
import { LinkAttr, linkType
|
|
6
|
+
import { LinkAttr, linkType } from '../LinkSpecs';
|
|
7
|
+
import { normalizeUrlFactory } from '../utils';
|
|
7
8
|
import { LinkPlaceholderWidget } from './widget';
|
|
8
9
|
export const addPlaceholder = (tr, deps) => {
|
|
9
10
|
return new LinkWidgetDescriptor(tr.selection.from, deps).applyTo(tr);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Command } from 'prosemirror-state';
|
|
2
|
-
import { ActionSpec, ExtensionDeps } from '../../../../core';
|
|
1
|
+
import { type Command } from 'prosemirror-state';
|
|
2
|
+
import type { ActionSpec, ExtensionDeps } from '../../../../core';
|
|
3
3
|
export declare const addEmptyLink: Command;
|
|
4
4
|
export declare const addLinkCmd2: (deps: ExtensionDeps) => Command;
|
|
5
5
|
export declare const linkActionSpec2: (deps: ExtensionDeps) => ActionSpec;
|
|
@@ -3,8 +3,10 @@ import { NodeSelection, TextSelection } from 'prosemirror-state';
|
|
|
3
3
|
import { isNodeSelection } from 'prosemirror-utils';
|
|
4
4
|
import { isMarkActive } from '../../../../utils/marks';
|
|
5
5
|
import { imageRendererKey } from '../../../yfm/ImgSize/const';
|
|
6
|
-
import {
|
|
6
|
+
import { imageType } from '../../Image/ImageSpecs';
|
|
7
|
+
import { LinkAttr, linkType } from '../LinkSpecs';
|
|
7
8
|
import { addLinkPlaceholder } from '../PlaceholderWidget/commands';
|
|
9
|
+
import { removeLink } from '../commands';
|
|
8
10
|
export const addEmptyLink = (state, dispatch) => {
|
|
9
11
|
const linkMarkType = linkType(state.schema);
|
|
10
12
|
const { selection } = state;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toggleMark } from 'prosemirror-commands';
|
|
2
2
|
import { isMarkActive } from '../../../utils/marks';
|
|
3
|
-
import { linkType } from '
|
|
3
|
+
import { linkType } from './LinkSpecs';
|
|
4
4
|
export const removeLink = (state, dispatch) => {
|
|
5
5
|
const linkMarkType = linkType(state.schema);
|
|
6
6
|
if (isMarkActive(state, linkMarkType))
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ActionSpec } from '../../../../core';
|
|
2
|
-
export declare const innerActions: Record<"
|
|
2
|
+
export declare const innerActions: Record<"setCellLeftAlign" | "setCellCenterAlign" | "setCellRightAlign" | "addRow" | "deleteRow" | "addColumn" | "deleteColumn", ActionSpec>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Plugin } from 'prosemirror-state';
|
|
2
2
|
import { bindActions } from '../../../../../core';
|
|
3
3
|
import { i18n } from '../../../../../i18n/yfm-table';
|
|
4
|
-
import { convertToYfmTable } from '../../../../yfm';
|
|
4
|
+
import { convertToYfmTable } from '../../../../yfm/YfmTable/commands/convert-table';
|
|
5
5
|
import { TableNode } from '../../TableSpecs';
|
|
6
6
|
import { innerActions } from '../../actions/innerActions';
|
|
7
7
|
import { deleteTableAction } from '../../actions/tableActions';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Action, ExtensionAuto } from '../../../core';
|
|
2
|
-
import { ImagePasteOptions } from './ImagePaste';
|
|
3
|
-
import { ImgSizeSpecsOptions } from './ImgSizeSpecs';
|
|
4
|
-
import { AddImageAttrs } from './actions';
|
|
2
|
+
import { type ImagePasteOptions } from './ImagePaste';
|
|
3
|
+
import { type ImgSizeSpecsOptions } from './ImgSizeSpecs';
|
|
4
|
+
import { type AddImageAttrs } from './actions';
|
|
5
5
|
import { addImageAction } from './const';
|
|
6
6
|
export declare type ImgSizeOptions = ImgSizeSpecsOptions & {
|
|
7
7
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { NodeSpec } from 'prosemirror-model';
|
|
2
1
|
import type { ExtensionAuto, ExtensionNodeSpec } from '../../../../core';
|
|
2
|
+
import { type YfmCutSchemaOptions } from './schema';
|
|
3
3
|
export { CutAttr, CutNode, cutType, cutTitleType, cutContentType } from './const';
|
|
4
4
|
declare global {
|
|
5
5
|
namespace MarkdownEditor {
|
|
@@ -8,17 +8,9 @@ declare global {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
export declare type YfmCutSpecsOptions = {
|
|
11
|
+
export declare type YfmCutSpecsOptions = YfmCutSchemaOptions & {
|
|
12
12
|
cutView?: ExtensionNodeSpec['view'];
|
|
13
13
|
cutTitleView?: ExtensionNodeSpec['view'];
|
|
14
14
|
cutContentView?: ExtensionNodeSpec['view'];
|
|
15
|
-
/**
|
|
16
|
-
* @deprecated: use placeholder option in BehaviorPreset instead.
|
|
17
|
-
*/
|
|
18
|
-
yfmCutTitlePlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated: use placeholder option in BehaviorPreset instead.
|
|
21
|
-
*/
|
|
22
|
-
yfmCutContentPlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
|
|
23
15
|
};
|
|
24
16
|
export declare const YfmCutSpecs: ExtensionAuto<YfmCutSpecsOptions>;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { NodeSpec } from 'prosemirror-model';
|
|
2
2
|
import type { PlaceholderOptions } from '../../../../utils/placeholder';
|
|
3
3
|
import { CutNode } from './const';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export declare type YfmCutSchemaOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated: use placeholder option in BehaviorPreset instead.
|
|
7
|
+
*/
|
|
8
|
+
yfmCutTitlePlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated: use placeholder option in BehaviorPreset instead.
|
|
11
|
+
*/
|
|
12
|
+
yfmCutContentPlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
|
|
13
|
+
};
|
|
14
|
+
export declare const getSchemaSpecs: (opts?: YfmCutSchemaOptions, placeholder?: PlaceholderOptions) => Record<CutNode, NodeSpec>;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import type { NodeSpec } from 'prosemirror-model';
|
|
2
1
|
import type { ExtensionWithOptions } from '../../../../core';
|
|
2
|
+
import { type YfmTableSchemaOptions } from './schema';
|
|
3
3
|
export { YfmTableNode } from './const';
|
|
4
4
|
export { yfmTableType, yfmTableBodyType, yfmTableRowType, yfmTableCellType } from './utils';
|
|
5
|
-
export declare type YfmTableSpecsOptions = {
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated: use placeholder option in BehaviorPreset instead.
|
|
8
|
-
*/
|
|
9
|
-
yfmTableCellPlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
|
|
10
|
-
};
|
|
5
|
+
export declare type YfmTableSpecsOptions = YfmTableSchemaOptions & {};
|
|
11
6
|
export declare const YfmTableSpecs: ExtensionWithOptions<YfmTableSpecsOptions>;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { NodeSpec } from 'prosemirror-model';
|
|
2
2
|
import { PlaceholderOptions } from '../../../../utils/placeholder';
|
|
3
3
|
import { YfmTableNode } from './const';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export declare type YfmTableSchemaOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated: use placeholder option in BehaviorPreset instead.
|
|
7
|
+
*/
|
|
8
|
+
yfmTableCellPlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
|
|
9
|
+
};
|
|
10
|
+
export declare const getSchemaSpecs: (opts?: YfmTableSchemaOptions, placeholder?: PlaceholderOptions) => Record<YfmTableNode, NodeSpec>;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { NodeSpec } from 'prosemirror-model';
|
|
2
1
|
import type { ExtensionAuto, ExtensionNodeSpec } from '../../../../core';
|
|
2
|
+
import { type YfmTabsSchemaOptions } from './schema';
|
|
3
3
|
export { TabsNode } from './const';
|
|
4
4
|
export declare const tabPanelType: (schema: import("prosemirror-model").Schema<any, any>) => import("prosemirror-model").NodeType;
|
|
5
5
|
export declare const tabType: (schema: import("prosemirror-model").Schema<any, any>) => import("prosemirror-model").NodeType;
|
|
6
6
|
export declare const tabsType: (schema: import("prosemirror-model").Schema<any, any>) => import("prosemirror-model").NodeType;
|
|
7
7
|
export declare const tabsListType: (schema: import("prosemirror-model").Schema<any, any>) => import("prosemirror-model").NodeType;
|
|
8
|
-
export declare type YfmTabsSpecsOptions = {
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated: use placeholder option in BehaviorPreset instead.
|
|
11
|
-
*/
|
|
12
|
-
tabPlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
|
|
8
|
+
export declare type YfmTabsSpecsOptions = YfmTabsSchemaOptions & {
|
|
13
9
|
tabView?: ExtensionNodeSpec['view'];
|
|
14
10
|
tabsListView?: ExtensionNodeSpec['view'];
|
|
15
11
|
tabPanelView?: ExtensionNodeSpec['view'];
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { NodeSpec } from 'prosemirror-model';
|
|
2
|
-
import { PlaceholderOptions } from '../../../../utils/placeholder';
|
|
2
|
+
import type { PlaceholderOptions } from '../../../../utils/placeholder';
|
|
3
3
|
import { TabsNode } from './const';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export declare type YfmTabsSchemaOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated: use placeholder option in BehaviorPreset instead.
|
|
7
|
+
*/
|
|
8
|
+
tabPlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
|
|
9
|
+
};
|
|
10
|
+
export declare const getSchemaSpecs: (opts: YfmTabsSchemaOptions, placeholder?: PlaceholderOptions) => Record<TabsNode, NodeSpec>;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { generateID } from '@diplodoc/transform/lib/plugins/utils';
|
|
2
2
|
import { pType } from '../../base/BaseSchema';
|
|
3
|
-
import { TabAttrs, TabPanelAttrs, TabsAttrs } from './
|
|
4
|
-
import { tabActiveClassname, tabPanelActiveClassname } from './const';
|
|
5
|
-
import { tabPanelType, tabType, tabsListType, tabsType } from '.';
|
|
3
|
+
import { TabAttrs, TabPanelAttrs, TabsAttrs, tabActiveClassname, tabPanelActiveClassname, tabPanelType, tabType, tabsListType, tabsType, } from './const';
|
|
6
4
|
export const createYfmTabsCommand = (state, dispatch) => {
|
|
7
5
|
if (dispatch) {
|
|
8
6
|
const { schema } = state;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export * from './YfmTabsSpecs/const';
|
|
2
|
+
export { tabType, tabPanelType, tabsListType, tabsType } from './YfmTabsSpecs';
|
|
3
|
+
export declare const YFM_TAB_CLASSNAME = "yfm-tab";
|
|
4
|
+
export declare const DIPLODOC_ID_ATTR = "data-diplodoc-id";
|
|
5
|
+
export declare const tabActiveClassname: string;
|
|
3
6
|
export declare const tabInactiveClassname = "yfm-tab";
|
|
4
7
|
export declare const tabPanelActiveClassname = "yfm-tab-panel active";
|
|
5
8
|
export declare const tabPanelInactiveClassname = "yfm-tab-panel";
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export const
|
|
1
|
+
export * from './YfmTabsSpecs/const';
|
|
2
|
+
export { tabType, tabPanelType, tabsListType, tabsType } from './YfmTabsSpecs';
|
|
3
|
+
export const YFM_TAB_CLASSNAME = 'yfm-tab';
|
|
4
|
+
export const DIPLODOC_ID_ATTR = 'data-diplodoc-id';
|
|
5
|
+
export const tabActiveClassname = `${YFM_TAB_CLASSNAME} active`;
|
|
6
|
+
export const tabInactiveClassname = YFM_TAB_CLASSNAME;
|
|
4
7
|
export const tabPanelActiveClassname = 'yfm-tab-panel active';
|
|
5
8
|
export const tabPanelInactiveClassname = 'yfm-tab-panel';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Command, Plugin } from 'prosemirror-state';
|
|
2
|
-
import { NodeWithPos } from 'prosemirror-utils';
|
|
1
|
+
import { type Command, Plugin } from 'prosemirror-state';
|
|
2
|
+
import { type NodeWithPos } from 'prosemirror-utils';
|
|
3
3
|
export declare const dragAutoSwitch: () => Plugin<any>;
|
|
4
4
|
export declare const tabPanelArrowDown: Command;
|
|
5
5
|
export declare const tabEnter: Command;
|
|
@@ -8,8 +8,8 @@ import { findChildIndex } from '../../../table-utils/helpers';
|
|
|
8
8
|
import { isSameNodeType } from '../../../utils';
|
|
9
9
|
import { get$Cursor, isTextSelection } from '../../../utils/selection';
|
|
10
10
|
import { TabAttrs, TabPanelAttrs } from './YfmTabsSpecs/const';
|
|
11
|
-
import {
|
|
12
|
-
import { atEndOfPanel } from './utils';
|
|
11
|
+
import { tabInactiveClassname, tabPanelActiveClassname, tabPanelInactiveClassname, tabPanelType, tabType, tabsListType, tabsType, } from './const';
|
|
12
|
+
import { atEndOfPanel, execAfterPaint, switchTabByElem, switchTabById } from './utils';
|
|
13
13
|
export const dragAutoSwitch = () => new Plugin({
|
|
14
14
|
view: TabsAutoSwitchOnDragOver.view,
|
|
15
15
|
});
|
|
@@ -35,12 +35,12 @@ class TabsAutoSwitchOnDragOver {
|
|
|
35
35
|
const pos = view.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
36
36
|
if (pos) {
|
|
37
37
|
const elem = findDomRefAtPos(pos.pos, view.domAtPos.bind(view));
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
38
|
+
const tabElem = elem.closest(TabsAutoSwitchOnDragOver.TAB_SELECTOR);
|
|
39
|
+
if (tabElem === this._tabElem)
|
|
40
40
|
return;
|
|
41
41
|
this._clear();
|
|
42
|
-
if (
|
|
43
|
-
this._setTabElem(
|
|
42
|
+
if (tabElem)
|
|
43
|
+
this._setTabElem(tabElem);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
_clear() {
|
|
@@ -55,29 +55,7 @@ class TabsAutoSwitchOnDragOver {
|
|
|
55
55
|
}
|
|
56
56
|
_switchTab() {
|
|
57
57
|
if (this._editorView.dragging && this._tabElem) {
|
|
58
|
-
|
|
59
|
-
const $pos = this._editorView.state.doc.resolve(pos);
|
|
60
|
-
const { state } = this._editorView;
|
|
61
|
-
let { depth } = $pos;
|
|
62
|
-
let tabId = '';
|
|
63
|
-
let tabsNode = null;
|
|
64
|
-
do {
|
|
65
|
-
const node = $pos.node(depth);
|
|
66
|
-
if (node.type === tabType(state.schema)) {
|
|
67
|
-
tabId = node.attrs[TabAttrs.dataDiplodocid];
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
if (node.type === tabsType(state.schema)) {
|
|
71
|
-
tabsNode = { node, pos: $pos.before(depth) };
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
} while (--depth >= 0);
|
|
75
|
-
if (tabId && tabsNode) {
|
|
76
|
-
const { tr } = state;
|
|
77
|
-
if (switchYfmTab(tabsNode, tabId, tr)) {
|
|
78
|
-
this._editorView.dispatch(tr.setMeta('addToHistory', false));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
58
|
+
switchTabByElem(this._tabElem);
|
|
81
59
|
}
|
|
82
60
|
this._clear();
|
|
83
61
|
}
|
|
@@ -87,49 +65,6 @@ TabsAutoSwitchOnDragOver.TAB_SELECTOR = '.yfm-tab:not([data-diplodoc-is-active=t
|
|
|
87
65
|
TabsAutoSwitchOnDragOver.OPEN_TIMEOUT = 500; //ms
|
|
88
66
|
TabsAutoSwitchOnDragOver.THROTTLE_WAIT = 50; //ms
|
|
89
67
|
TabsAutoSwitchOnDragOver.view = (view) => new _a(view);
|
|
90
|
-
function switchYfmTab({ node: tabsNode, pos: tabsPos }, tabId, tr) {
|
|
91
|
-
const { schema } = tabsNode.type;
|
|
92
|
-
if (tabsNode.type !== tabsType(schema))
|
|
93
|
-
return false;
|
|
94
|
-
const tabsList = tabsNode.firstChild;
|
|
95
|
-
if ((tabsList === null || tabsList === void 0 ? void 0 : tabsList.type) !== tabsListType(schema))
|
|
96
|
-
return false;
|
|
97
|
-
const tabsListPos = tabsPos + 1;
|
|
98
|
-
let panelId = null;
|
|
99
|
-
tabsList.forEach((node, offset) => {
|
|
100
|
-
if (node.type !== tabType(schema))
|
|
101
|
-
return;
|
|
102
|
-
const tabPos = tabsListPos + 1 + offset;
|
|
103
|
-
const tabAttrs = Object.assign(Object.assign({}, node.attrs), { [TabAttrs.ariaSelected]: 'false', [TabAttrs.dataDiplodocIsActive]: 'false' });
|
|
104
|
-
if (node.attrs[TabAttrs.dataDiplodocid] === tabId) {
|
|
105
|
-
panelId = node.attrs[TabAttrs.ariaControls];
|
|
106
|
-
tabAttrs[TabAttrs.ariaSelected] = 'true';
|
|
107
|
-
tabAttrs[TabAttrs.dataDiplodocIsActive] = 'true';
|
|
108
|
-
}
|
|
109
|
-
tr.setNodeMarkup(tabPos, null, tabAttrs);
|
|
110
|
-
});
|
|
111
|
-
if (!panelId)
|
|
112
|
-
return false;
|
|
113
|
-
tabsNode.forEach((node, offset) => {
|
|
114
|
-
var _b;
|
|
115
|
-
if (node.type !== tabPanelType(schema))
|
|
116
|
-
return;
|
|
117
|
-
const tabPanelPos = tabsPos + 1 + offset;
|
|
118
|
-
const tabPanelAttrs = Object.assign({}, node.attrs);
|
|
119
|
-
const tabPanelClassList = new Set(((_b = node.attrs[TabPanelAttrs.class]) !== null && _b !== void 0 ? _b : '')
|
|
120
|
-
.split(' ')
|
|
121
|
-
.filter((val) => Boolean(val.trim())));
|
|
122
|
-
if (node.attrs[TabPanelAttrs.id] === panelId) {
|
|
123
|
-
tabPanelClassList.add('active');
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
tabPanelClassList.delete('active');
|
|
127
|
-
}
|
|
128
|
-
tabPanelAttrs[TabPanelAttrs.class] = Array.from(tabPanelClassList).join(' ');
|
|
129
|
-
tr.setNodeMarkup(tabPanelPos, null, tabPanelAttrs);
|
|
130
|
-
});
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
68
|
export const tabPanelArrowDown = (state, dispatch, view) => {
|
|
134
69
|
var _b;
|
|
135
70
|
const { selection: sel } = state;
|
|
@@ -182,22 +117,6 @@ export const liftEmptyBlockFromTabPanel = (state, dispatch) => {
|
|
|
182
117
|
}
|
|
183
118
|
return false;
|
|
184
119
|
};
|
|
185
|
-
const makeTabsInactive = (tabNodes, tabPanels, tr) => {
|
|
186
|
-
// Find all active tabs and make them inactive
|
|
187
|
-
const activeTabs = tabNodes.filter((v) => v.node.attrs[TabAttrs.dataDiplodocIsActive] === 'true');
|
|
188
|
-
if (activeTabs.length) {
|
|
189
|
-
activeTabs.forEach((tab) => {
|
|
190
|
-
tr.setNodeMarkup(tab.pos, null, Object.assign(Object.assign({}, tab.node.attrs), { class: tabInactiveClassname, [TabAttrs.dataDiplodocIsActive]: 'false' }));
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
// Find all active panels and make them inactive
|
|
194
|
-
const activePanels = tabPanels.filter((v) => v.node.attrs[TabPanelAttrs.class] === tabPanelActiveClassname);
|
|
195
|
-
if (activePanels.length) {
|
|
196
|
-
activePanels.forEach((tabPanel) => {
|
|
197
|
-
tr.setNodeMarkup(tr.mapping.map(tabPanel.pos), null, Object.assign(Object.assign({}, tabPanel.node.attrs), { class: tabPanelInactiveClassname }));
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
120
|
export const createTab = (afterTab, tabsParentNode) => (state, dispatch, view) => {
|
|
202
121
|
const tabNodes = findChildren(tabsParentNode.node, (node) => node.type.name === tabType(state.schema).name);
|
|
203
122
|
const tabPanels = findChildren(tabsParentNode.node, (tabNode) => {
|
|
@@ -210,14 +129,14 @@ export const createTab = (afterTab, tabsParentNode) => (state, dispatch, view) =
|
|
|
210
129
|
const newPanel = tabPanelType(state.schema).create({
|
|
211
130
|
[TabPanelAttrs.ariaLabelledby]: tabId,
|
|
212
131
|
[TabPanelAttrs.id]: panelId,
|
|
213
|
-
[TabPanelAttrs.class]:
|
|
132
|
+
[TabPanelAttrs.class]: tabPanelInactiveClassname,
|
|
214
133
|
}, pType(state.schema).createAndFill());
|
|
215
134
|
const newTab = tabType(state.schema).create({
|
|
216
135
|
[TabAttrs.id]: tabId,
|
|
217
136
|
[TabAttrs.dataDiplodocid]: tabId,
|
|
218
137
|
[TabAttrs.dataDiplodocKey]: tabId,
|
|
219
|
-
[TabAttrs.dataDiplodocIsActive]: '
|
|
220
|
-
[TabAttrs.class]:
|
|
138
|
+
[TabAttrs.dataDiplodocIsActive]: 'false',
|
|
139
|
+
[TabAttrs.class]: tabInactiveClassname,
|
|
221
140
|
[TabAttrs.role]: 'tab',
|
|
222
141
|
[TabAttrs.ariaControls]: panelId,
|
|
223
142
|
});
|
|
@@ -229,12 +148,14 @@ export const createTab = (afterTab, tabsParentNode) => (state, dispatch, view) =
|
|
|
229
148
|
tabPanels.forEach((v) => {
|
|
230
149
|
v.pos = v.pos + tabsParentNode.pos + 1;
|
|
231
150
|
});
|
|
232
|
-
makeTabsInactive(tabNodes, tabPanels, tr);
|
|
233
151
|
dispatch === null || dispatch === void 0 ? void 0 : dispatch(tr
|
|
234
152
|
.insert(afterPanelNode.pos + afterPanelNode.node.nodeSize, newPanel)
|
|
235
153
|
.insert(afterTab.pos + afterTab.node.nodeSize, newTab)
|
|
236
154
|
.setSelection(TextSelection.create(tr.doc, afterTab.pos + afterTab.node.nodeSize + 1)));
|
|
237
155
|
view === null || view === void 0 ? void 0 : view.focus();
|
|
156
|
+
if (view) {
|
|
157
|
+
execAfterPaint(() => switchTabById(view.dom, tabId));
|
|
158
|
+
}
|
|
238
159
|
return true;
|
|
239
160
|
};
|
|
240
161
|
export const removeTab = (tabToRemove, tabsParentNode) => (state, dispatch, view) => {
|
|
@@ -263,18 +184,16 @@ export const removeTab = (tabToRemove, tabsParentNode) => (state, dispatch, view
|
|
|
263
184
|
v.pos = v.pos + tabsParentNode.pos + 1;
|
|
264
185
|
});
|
|
265
186
|
const newTabNode = tabNodes[newTabIdx];
|
|
266
|
-
const
|
|
267
|
-
makeTabsInactive(tabNodes, tabPanels, tr);
|
|
187
|
+
const newActiveTabId = newTabNode.node.attrs[TabAttrs.dataDiplodocid];
|
|
268
188
|
tr
|
|
269
189
|
// Delete panel
|
|
270
190
|
.delete(panelToRemove.pos, panelToRemove.pos + panelToRemove.node.nodeSize)
|
|
271
191
|
// Delete tab
|
|
272
192
|
.delete(tabToRemove.pos, tabToRemove.pos + tabToRemove.node.nodeSize)
|
|
273
|
-
// Set new active tab
|
|
274
|
-
.setNodeMarkup(tr.mapping.map(newTabNode.pos), null, Object.assign(Object.assign({}, newTabNode.node.attrs), { class: tabActiveClassname, [TabAttrs.dataDiplodocIsActive]: 'true' }))
|
|
275
|
-
// Set new active panel
|
|
276
|
-
.setNodeMarkup(tr.mapping.map(newTabPanelNode.pos), null, Object.assign(Object.assign({}, newTabPanelNode.node.attrs), { class: tabPanelActiveClassname }))
|
|
277
193
|
.setSelection(TextSelection.create(tr.doc, tr.mapping.map(newTabNode.pos + newTabNode.node.nodeSize - 1)));
|
|
194
|
+
// Set new active tab
|
|
195
|
+
if (view)
|
|
196
|
+
execAfterPaint(() => switchTabById(view.dom, newActiveTabId));
|
|
278
197
|
}
|
|
279
198
|
dispatch(tr);
|
|
280
199
|
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,4 +1,9 @@
|
|
|
1
|
-
import { tabPanelType } from '
|
|
1
|
+
import { DIPLODOC_ID_ATTR, YFM_TAB_CLASSNAME, tabPanelType } from './const';
|
|
2
|
+
export const execAfterPaint = (fn) => {
|
|
3
|
+
requestAnimationFrame(() => {
|
|
4
|
+
requestAnimationFrame(fn);
|
|
5
|
+
});
|
|
6
|
+
};
|
|
2
7
|
export const atEndOfPanel = (view) => {
|
|
3
8
|
if (!view)
|
|
4
9
|
return null;
|
|
@@ -14,3 +19,15 @@ export const atEndOfPanel = (view) => {
|
|
|
14
19
|
}
|
|
15
20
|
return null;
|
|
16
21
|
};
|
|
22
|
+
export const switchTabByElem = (tabElem) => {
|
|
23
|
+
if (tabElem.classList.contains(YFM_TAB_CLASSNAME)) {
|
|
24
|
+
tabElem.click();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export const switchTabById = (container, tabId) => {
|
|
28
|
+
const selector = `.${YFM_TAB_CLASSNAME}[${DIPLODOC_ID_ATTR}="${tabId}"]`;
|
|
29
|
+
const tabElem = container.querySelector(selector);
|
|
30
|
+
if (tabElem) {
|
|
31
|
+
switchTabByElem(tabElem);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { TextSelection } from 'prosemirror-state';
|
|
1
2
|
import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
|
|
2
3
|
import { cn } from '../../../classname';
|
|
4
|
+
import { tabType, tabsType } from './const';
|
|
3
5
|
import { crossSvg, plusSvg } from './icons';
|
|
4
6
|
import { createTab, removeTab } from './plugins';
|
|
5
|
-
import {
|
|
7
|
+
import { execAfterPaint } from './utils';
|
|
6
8
|
import './index.css';
|
|
7
9
|
const cnYfmTab = cn('yfm-tab');
|
|
8
|
-
const ignoreMutation = (
|
|
10
|
+
const ignoreMutation = (_node, _view, _getPos) => (mutation) => {
|
|
9
11
|
if (mutation instanceof MutationRecord &&
|
|
10
12
|
mutation.type === 'attributes' &&
|
|
11
13
|
mutation.attributeName) {
|
|
12
|
-
const newAttr = mutation.target.getAttribute(mutation.attributeName);
|
|
13
|
-
view.dispatch(view.state.tr.setNodeMarkup(getPos(), null, Object.assign(Object.assign({}, node.attrs), { [mutation.attributeName]: newAttr })));
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
16
16
|
return false;
|
|
@@ -29,6 +29,26 @@ export const tabView = (node, view, getPos) => {
|
|
|
29
29
|
wrapperElem.addEventListener('click', () => {
|
|
30
30
|
// Click on parent node to trigger event listener that selects current tab
|
|
31
31
|
tabElem.click();
|
|
32
|
+
{
|
|
33
|
+
/**
|
|
34
|
+
* Hack for empty tabs
|
|
35
|
+
*
|
|
36
|
+
* Problem: when clicking on an empty tab (without text content) it focuses, and selection doesn't move to beginning of tab
|
|
37
|
+
*
|
|
38
|
+
* Temporary fix: manually return focus to pm-view, move text selection to beginning of tab
|
|
39
|
+
*/
|
|
40
|
+
view.focus();
|
|
41
|
+
// tab is empty
|
|
42
|
+
if (node.nodeSize < 3) {
|
|
43
|
+
execAfterPaint(() => {
|
|
44
|
+
const pos = getPos();
|
|
45
|
+
if (pos !== undefined) {
|
|
46
|
+
const { tr } = view.state;
|
|
47
|
+
view.dispatch(tr.setSelection(TextSelection.create(tr.doc, pos + 1)).scrollIntoView());
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
32
52
|
});
|
|
33
53
|
const removeTabButton = document.createElement('div');
|
|
34
54
|
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.
|