@gravity-ui/markdown-editor 14.4.0 → 14.5.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/Editor.js +1 -0
- package/build/cjs/bundle/config/markup.d.ts +41 -17
- package/build/cjs/bundle/config/markup.js +413 -308
- package/build/cjs/bundle/config/wysiwyg.d.ts +29 -18
- package/build/cjs/bundle/config/wysiwyg.js +526 -310
- package/build/cjs/bundle/sticky/sticky.css +1 -1
- package/build/cjs/bundle/types.d.ts +2 -0
- package/build/cjs/extensions/behavior/Clipboard/utils.d.ts +1 -0
- package/build/cjs/extensions/behavior/Clipboard/utils.js +1 -0
- package/build/cjs/extensions/markdown/CodeBlock/handle-paste.js +5 -17
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/const.d.ts +7 -0
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/const.js +8 -1
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/index.d.ts +1 -1
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/index.js +2 -1
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/schema.d.ts +1 -1
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/schema.js +7 -7
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/serializer.d.ts +1 -1
- package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/serializer.js +2 -2
- package/build/cjs/extensions/yfm/Checkbox/const.d.ts +1 -1
- package/build/cjs/extensions/yfm/Checkbox/const.js +2 -1
- package/build/cjs/extensions/yfm/Checkbox/index.d.ts +2 -2
- package/build/cjs/extensions/yfm/Checkbox/index.js +4 -38
- package/build/cjs/extensions/yfm/Checkbox/nodeviews.d.ts +16 -0
- package/build/cjs/extensions/yfm/Checkbox/nodeviews.js +56 -0
- package/build/cjs/extensions/yfm/YfmFile/YfmFileSpecs/const.d.ts +12 -0
- package/build/cjs/extensions/yfm/YfmFile/YfmFileSpecs/const.js +21 -2
- package/build/cjs/extensions/yfm/YfmFile/YfmFileSpecs/index.d.ts +8 -1
- package/build/cjs/extensions/yfm/YfmFile/YfmFileSpecs/index.js +29 -5
- package/build/cjs/markup/codemirror/create.d.ts +1 -0
- package/build/cjs/markup/codemirror/create.js +41 -4
- package/build/cjs/markup/codemirror/html-to-markdown/converters.d.ts +111 -0
- package/build/cjs/markup/codemirror/html-to-markdown/converters.js +214 -0
- package/build/cjs/markup/codemirror/html-to-markdown/handlers.d.ts +104 -0
- package/build/cjs/markup/codemirror/html-to-markdown/handlers.js +233 -0
- package/build/cjs/markup/codemirror/html-to-markdown/helpers.d.ts +1 -0
- package/build/cjs/markup/codemirror/html-to-markdown/helpers.js +21 -0
- package/build/cjs/markup/commands/inline.js +18 -8
- package/build/cjs/utils/clipboard.d.ts +14 -0
- package/build/cjs/utils/clipboard.js +36 -1
- package/build/cjs/version.js +1 -1
- package/build/esm/bundle/Editor.js +1 -0
- package/build/esm/bundle/config/markup.d.ts +41 -17
- package/build/esm/bundle/config/markup.js +411 -307
- package/build/esm/bundle/config/wysiwyg.d.ts +29 -18
- package/build/esm/bundle/config/wysiwyg.js +499 -284
- package/build/esm/bundle/sticky/sticky.css +1 -1
- package/build/esm/bundle/types.d.ts +2 -0
- package/build/esm/extensions/behavior/Clipboard/utils.d.ts +1 -0
- package/build/esm/extensions/behavior/Clipboard/utils.js +1 -0
- package/build/esm/extensions/markdown/CodeBlock/handle-paste.js +2 -14
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/const.d.ts +7 -0
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/const.js +7 -0
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/index.d.ts +1 -1
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/index.js +1 -1
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/schema.d.ts +1 -1
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/schema.js +7 -7
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/serializer.d.ts +1 -1
- package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/serializer.js +2 -2
- package/build/esm/extensions/yfm/Checkbox/const.d.ts +1 -1
- package/build/esm/extensions/yfm/Checkbox/const.js +1 -1
- package/build/esm/extensions/yfm/Checkbox/index.d.ts +2 -2
- package/build/esm/extensions/yfm/Checkbox/index.js +3 -38
- package/build/esm/extensions/yfm/Checkbox/nodeviews.d.ts +16 -0
- package/build/esm/extensions/yfm/Checkbox/nodeviews.js +52 -0
- package/build/esm/extensions/yfm/YfmFile/YfmFileSpecs/const.d.ts +12 -0
- package/build/esm/extensions/yfm/YfmFile/YfmFileSpecs/const.js +21 -2
- package/build/esm/extensions/yfm/YfmFile/YfmFileSpecs/index.d.ts +8 -1
- package/build/esm/extensions/yfm/YfmFile/YfmFileSpecs/index.js +29 -6
- package/build/esm/markup/codemirror/create.d.ts +1 -0
- package/build/esm/markup/codemirror/create.js +40 -3
- package/build/esm/markup/codemirror/html-to-markdown/converters.d.ts +111 -0
- package/build/esm/markup/codemirror/html-to-markdown/converters.js +210 -0
- package/build/esm/markup/codemirror/html-to-markdown/handlers.d.ts +104 -0
- package/build/esm/markup/codemirror/html-to-markdown/handlers.js +215 -0
- package/build/esm/markup/codemirror/html-to-markdown/helpers.d.ts +1 -0
- package/build/esm/markup/codemirror/html-to-markdown/helpers.js +17 -0
- package/build/esm/markup/commands/inline.js +18 -8
- package/build/esm/utils/clipboard.d.ts +14 -0
- package/build/esm/utils/clipboard.js +32 -0
- package/build/esm/version.js +1 -1
- package/build/styles.css +1 -1
- package/package.json +9 -7
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.insertFiles = exports.insertImages = exports.insertAnchor = exports.insertLink = void 0;
|
|
4
4
|
const autocomplete_1 = require("@codemirror/autocomplete");
|
|
5
|
+
const codemirror_1 = require("../codemirror");
|
|
5
6
|
const defaultLinkSnippet = (0, autocomplete_1.snippet)(`[#{2:link}](#{1:url} "#{3:title}")`);
|
|
6
7
|
const insertLink = ({ state, dispatch }) => {
|
|
7
8
|
const { from, to, empty } = state.selection.main;
|
|
@@ -47,16 +48,25 @@ function insertImages(images) {
|
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
exports.insertImages = insertImages;
|
|
51
|
+
const fileToCurlySyntax = (file) => {
|
|
52
|
+
const attrsStr = Object.entries(file)
|
|
53
|
+
.map(([key, value]) => `${key}="${value.replace('"', '')}"`)
|
|
54
|
+
.join(' ');
|
|
55
|
+
return `{% file ${attrsStr} %}`;
|
|
56
|
+
};
|
|
57
|
+
const fileToDirectiveSyntax = (file) => {
|
|
58
|
+
const { src, name, type } = file;
|
|
59
|
+
let markup = `:file[${name}](${src})`;
|
|
60
|
+
if (type)
|
|
61
|
+
markup += `{type="${type}"}`;
|
|
62
|
+
return markup;
|
|
63
|
+
};
|
|
50
64
|
const insertFiles = (files) => {
|
|
51
65
|
return ({ state, dispatch }) => {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
.join(' ');
|
|
57
|
-
return `{% file ${attrsStr} %}`;
|
|
58
|
-
})
|
|
59
|
-
.join(' ');
|
|
66
|
+
const serializer = state.facet(codemirror_1.DirectiveSyntaxFacet).shouldInsertDirectiveMarkup('yfmFile')
|
|
67
|
+
? fileToDirectiveSyntax
|
|
68
|
+
: fileToCurlySyntax;
|
|
69
|
+
const markup = files.map(serializer).join(' ');
|
|
60
70
|
const tr = state.changeByRange((range) => {
|
|
61
71
|
const changes = state.changes({ from: range.from, to: range.to, insert: markup });
|
|
62
72
|
return { changes, range: range.map(changes) };
|
|
@@ -3,6 +3,7 @@ export declare enum DataTransferType {
|
|
|
3
3
|
Text = "text/plain",
|
|
4
4
|
Html = "text/html",
|
|
5
5
|
Yfm = "text/yfm",
|
|
6
|
+
Rtf = "text/rtf",
|
|
6
7
|
UriList = "text/uri-list",
|
|
7
8
|
VSCodeData = "vscode-editor-data",
|
|
8
9
|
Files = "Files"
|
|
@@ -10,3 +11,16 @@ export declare enum DataTransferType {
|
|
|
10
11
|
export declare function isFilesOnly({ types }: DataTransfer): boolean;
|
|
11
12
|
export declare function isFilesFromHtml({ types }: DataTransfer): boolean;
|
|
12
13
|
export declare function isImageFile(file: File): boolean;
|
|
14
|
+
export declare function isVSCode(data: DataTransfer): boolean;
|
|
15
|
+
export declare type VSCodeData = {
|
|
16
|
+
version: number;
|
|
17
|
+
isFromEmptySelection: boolean;
|
|
18
|
+
multicursorText: null | string;
|
|
19
|
+
mode: string;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
};
|
|
22
|
+
export declare function tryParseVSCodeData(data: DataTransfer): VSCodeData | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if HTML conversion should be skipped based on clipboard contents.
|
|
25
|
+
*/
|
|
26
|
+
export declare function shouldSkipHtmlConversion(clipboardData: DataTransfer): boolean;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isImageFile = exports.isFilesFromHtml = exports.isFilesOnly = exports.DataTransferType = void 0;
|
|
3
|
+
exports.shouldSkipHtmlConversion = exports.tryParseVSCodeData = exports.isVSCode = exports.isImageFile = exports.isFilesFromHtml = exports.isFilesOnly = exports.DataTransferType = void 0;
|
|
4
4
|
/** Сontains all data formats known to us */
|
|
5
5
|
var DataTransferType;
|
|
6
6
|
(function (DataTransferType) {
|
|
7
7
|
DataTransferType["Text"] = "text/plain";
|
|
8
8
|
DataTransferType["Html"] = "text/html";
|
|
9
9
|
DataTransferType["Yfm"] = "text/yfm";
|
|
10
|
+
DataTransferType["Rtf"] = "text/rtf";
|
|
10
11
|
DataTransferType["UriList"] = "text/uri-list";
|
|
11
12
|
DataTransferType["VSCodeData"] = "vscode-editor-data";
|
|
12
13
|
DataTransferType["Files"] = "Files";
|
|
@@ -25,3 +26,37 @@ function isImageFile(file) {
|
|
|
25
26
|
return file.type.startsWith('image/');
|
|
26
27
|
}
|
|
27
28
|
exports.isImageFile = isImageFile;
|
|
29
|
+
function isVSCode(data) {
|
|
30
|
+
return data.types.includes(DataTransferType.VSCodeData);
|
|
31
|
+
}
|
|
32
|
+
exports.isVSCode = isVSCode;
|
|
33
|
+
function tryParseVSCodeData(data) {
|
|
34
|
+
try {
|
|
35
|
+
return JSON.parse(data.getData(DataTransferType.VSCodeData));
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
console.error(e);
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.tryParseVSCodeData = tryParseVSCodeData;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if HTML conversion should be skipped based on clipboard contents.
|
|
45
|
+
*/
|
|
46
|
+
function shouldSkipHtmlConversion(clipboardData) {
|
|
47
|
+
const hasHtml = clipboardData.types.includes(DataTransferType.Html);
|
|
48
|
+
// If there's no HTML content, skip conversion
|
|
49
|
+
if (!hasHtml)
|
|
50
|
+
return true;
|
|
51
|
+
// Check for standard HTML clipboard (text/plain + text/html)
|
|
52
|
+
if (clipboardData.types.length === 2)
|
|
53
|
+
return false;
|
|
54
|
+
// Check for WebStorm/Safari case (includes RTF)
|
|
55
|
+
if (clipboardData.types.length === 3) {
|
|
56
|
+
const rtf = clipboardData.getData(DataTransferType.Rtf);
|
|
57
|
+
return rtf.indexOf('\fmodern JetBrains') > 0;
|
|
58
|
+
}
|
|
59
|
+
// Skip conversion for any other cases
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
exports.shouldSkipHtmlConversion = shouldSkipHtmlConversion;
|
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 '14.
|
|
5
|
+
exports.VERSION = typeof '14.5.1' !== 'undefined' ? '14.5.1' : 'unknown';
|
|
@@ -168,6 +168,7 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
168
168
|
uploadHandler: this.fileUploadHandler,
|
|
169
169
|
parseInsertedUrlAsImage: this.parseInsertedUrlAsImage,
|
|
170
170
|
needImageDimensions: this.needToSetDimensionsForUploadedImages,
|
|
171
|
+
parseHtmlOnPaste: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").parseHtmlOnPaste,
|
|
171
172
|
enableNewImageSizeCalculation: this.enableNewImageSizeCalculation,
|
|
172
173
|
extensions: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").extensions,
|
|
173
174
|
disabledExtensions: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").disabledExtensions,
|
|
@@ -2,7 +2,7 @@ import { CodeEditor } from '../../markup/editor';
|
|
|
2
2
|
import { ToolbarData } from '../../toolbar/Toolbar';
|
|
3
3
|
import { ToolbarGroupData } from '../../toolbar/ToolbarGroup';
|
|
4
4
|
import { ToolbarListButtonData } from '../../toolbar/ToolbarListButton';
|
|
5
|
-
import { ToolbarButtonPopupData, ToolbarItemData, ToolbarListItemData, ToolbarReactComponentData, ToolbarSingleItemData } from '../../toolbar/types';
|
|
5
|
+
import { ToolbarButtonPopupData, ToolbarItemData, ToolbarListButtonItemData, ToolbarListItemData, ToolbarReactComponentData, ToolbarSingleItemData } from '../../toolbar/types';
|
|
6
6
|
import type { MarkdownEditorPreset } from '../types';
|
|
7
7
|
export declare type MToolbarData = ToolbarData<CodeEditor>;
|
|
8
8
|
export declare type MToolbarItemData = ToolbarItemData<CodeEditor>;
|
|
@@ -12,37 +12,61 @@ export declare type MToolbarReactComponentData = ToolbarReactComponentData<CodeE
|
|
|
12
12
|
export declare type MToolbarListButtonData = ToolbarListButtonData<CodeEditor>;
|
|
13
13
|
export declare type MToolbarListItemData = ToolbarListItemData<CodeEditor>;
|
|
14
14
|
export declare type MToolbarButtonPopupData = ToolbarButtonPopupData<CodeEditor>;
|
|
15
|
-
export declare const
|
|
16
|
-
|
|
15
|
+
export declare const mUndoItemData: MToolbarSingleItemData;
|
|
16
|
+
export declare const mRedoItemData: MToolbarSingleItemData;
|
|
17
17
|
export declare const mBoldItemData: MToolbarSingleItemData;
|
|
18
18
|
export declare const mItalicItemData: MToolbarSingleItemData;
|
|
19
19
|
export declare const mUnderlineItemData: MToolbarSingleItemData;
|
|
20
20
|
export declare const mStrikethroughItemData: MToolbarSingleItemData;
|
|
21
21
|
export declare const mMonospaceItemData: MToolbarSingleItemData;
|
|
22
22
|
export declare const mMarkedItemData: MToolbarSingleItemData;
|
|
23
|
-
export declare const mBiusGroupConfig: MToolbarGroupData;
|
|
24
|
-
export declare const mHeadingListConfig: MToolbarListButtonData;
|
|
25
|
-
export declare const mListsListConfig: MToolbarListButtonData;
|
|
26
23
|
export declare const mCheckboxButton: MToolbarSingleItemData;
|
|
27
|
-
export declare const
|
|
24
|
+
export declare const mCheckboxItemData: MToolbarSingleItemData;
|
|
28
25
|
export declare const mLinkButton: MToolbarSingleItemData;
|
|
29
|
-
export declare const
|
|
26
|
+
export declare const mLinkItemData: MToolbarSingleItemData;
|
|
30
27
|
export declare const mQuoteButton: MToolbarSingleItemData;
|
|
28
|
+
export declare const mQuoteItemData: MToolbarSingleItemData;
|
|
31
29
|
export declare const mCutButton: MToolbarSingleItemData;
|
|
30
|
+
export declare const mCutItemData: MToolbarSingleItemData;
|
|
31
|
+
export declare const mNoteButton: MToolbarSingleItemData;
|
|
32
|
+
export declare const mNoteItemData: MToolbarSingleItemData;
|
|
32
33
|
export declare const mTableButton: MToolbarSingleItemData;
|
|
33
|
-
export declare const
|
|
34
|
-
export declare const
|
|
35
|
-
export declare const mMathListConfig: MToolbarListButtonData;
|
|
36
|
-
export declare const mMathListItem: MToolbarListItemData;
|
|
37
|
-
export declare const mMermaidButton: MToolbarSingleItemData;
|
|
38
|
-
export declare const mYfmHtmlBlockButton: MToolbarSingleItemData;
|
|
34
|
+
export declare const mTableItemData: MToolbarSingleItemData;
|
|
35
|
+
export declare const mCodeItemData: ToolbarListButtonItemData<CodeEditor>;
|
|
39
36
|
export declare const mImagePopupData: MToolbarButtonPopupData;
|
|
37
|
+
export declare const mImageItemData: MToolbarButtonPopupData;
|
|
40
38
|
export declare const mFilePopupData: MToolbarButtonPopupData;
|
|
41
|
-
|
|
42
|
-
export declare const
|
|
39
|
+
export declare const mFileItemData: MToolbarButtonPopupData;
|
|
40
|
+
export declare const mTabsItemData: MToolbarSingleItemData;
|
|
41
|
+
export declare const mMathInlineItemData: ToolbarListButtonItemData<CodeEditor>;
|
|
42
|
+
export declare const mMathBlockItemData: ToolbarListButtonItemData<CodeEditor>;
|
|
43
|
+
export declare const mYfmHtmlBlockButton: MToolbarSingleItemData;
|
|
44
|
+
export declare const mYfmHtmlBlockItemData: MToolbarSingleItemData;
|
|
45
|
+
export declare const mMermaidButton: MToolbarSingleItemData;
|
|
46
|
+
export declare const mMermaidItemData: MToolbarSingleItemData;
|
|
47
|
+
export declare const mCodeblockItemData: MToolbarItemData;
|
|
48
|
+
export declare const mCodeBlockItemData: MToolbarItemData;
|
|
43
49
|
export declare const mHruleItemData: MToolbarSingleItemData;
|
|
44
50
|
export declare const mEmojiItemData: MToolbarSingleItemData;
|
|
45
|
-
export declare const
|
|
51
|
+
export declare const mMathListItem: MToolbarListItemData;
|
|
52
|
+
export declare const mHeading1ItemData: ToolbarListButtonItemData<CodeEditor>;
|
|
53
|
+
export declare const mHeading2ItemData: ToolbarListButtonItemData<CodeEditor>;
|
|
54
|
+
export declare const mHeading3ItemData: ToolbarListButtonItemData<CodeEditor>;
|
|
55
|
+
export declare const mHeading4ItemData: ToolbarListButtonItemData<CodeEditor>;
|
|
56
|
+
export declare const mHeading5ItemData: ToolbarListButtonItemData<CodeEditor>;
|
|
57
|
+
export declare const mHeading6ItemData: ToolbarListButtonItemData<CodeEditor>;
|
|
58
|
+
export declare const mBulletListItemData: ToolbarListButtonItemData<CodeEditor>;
|
|
59
|
+
export declare const mOrderedListItemData: ToolbarListButtonItemData<CodeEditor>;
|
|
60
|
+
export declare const mSinkListItemData: ToolbarListButtonItemData<CodeEditor>;
|
|
61
|
+
export declare const mLiftListItemData: ToolbarListButtonItemData<CodeEditor>;
|
|
62
|
+
export declare const mHeadingListConfig: MToolbarListButtonData;
|
|
63
|
+
export declare const mListsListConfig: MToolbarListButtonData;
|
|
64
|
+
export declare const mListMoveListConfig: MToolbarListButtonData;
|
|
65
|
+
export declare const mCodeListConfig: MToolbarListButtonData;
|
|
66
|
+
export declare const mMathListConfig: MToolbarListButtonData;
|
|
46
67
|
export declare const mHiddenData: MToolbarSingleItemData[];
|
|
68
|
+
export declare const mHistoryGroupConfig: MToolbarGroupData;
|
|
69
|
+
export declare const mBiusGroupConfig: MToolbarGroupData;
|
|
70
|
+
export declare const mToolbarConfig: MToolbarData;
|
|
47
71
|
export declare const mToolbarConfigByPreset: Record<MarkdownEditorPreset, MToolbarData>;
|
|
48
72
|
export declare const mHiddenDataByPreset: Record<MarkdownEditorPreset, MToolbarItemData[]>;
|