@gravity-ui/markdown-editor 14.3.1 → 14.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/bundle/Editor.d.ts +2 -0
- package/build/cjs/bundle/Editor.js +8 -2
- package/build/cjs/bundle/MarkdownEditorView.js +1 -0
- package/build/cjs/bundle/SplitModeView.js +1 -0
- package/build/cjs/bundle/types.d.ts +22 -0
- package/build/cjs/bundle/useMarkdownEditor.js +6 -2
- package/build/cjs/bundle/wysiwyg-preset.d.ts +11 -2
- package/build/cjs/bundle/wysiwyg-preset.js +1 -0
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/const.d.ts +4 -0
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/const.js +6 -1
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/index.d.ts +8 -1
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/index.js +11 -5
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/parser.js +5 -1
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/schema.d.ts +1 -1
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/schema.js +8 -3
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/serializer.d.ts +3 -1
- package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/serializer.js +42 -24
- package/build/cjs/extensions/yfm/YfmFile/YfmFileSpecs/const.js +9 -9
- package/build/cjs/extensions/yfm/YfmFile/YfmFileSpecs/index.js +18 -20
- package/build/cjs/extensions/yfm/YfmFile/index.d.ts +1 -0
- package/build/cjs/extensions/yfm/YfmFile/index.js +1 -0
- package/build/cjs/index.d.ts +1 -1
- package/build/cjs/index.js +2 -1
- package/build/cjs/markup/codemirror/create.d.ts +7 -5
- package/build/cjs/markup/codemirror/create.js +3 -2
- package/build/cjs/markup/codemirror/directive-facet.d.ts +3 -0
- package/build/cjs/markup/codemirror/directive-facet.js +8 -0
- package/build/cjs/markup/codemirror/index.d.ts +1 -0
- package/build/cjs/markup/codemirror/index.js +3 -1
- package/build/cjs/markup/codemirror/yfm.d.ts +5 -0
- package/build/cjs/markup/codemirror/yfm.js +26 -4
- package/build/cjs/markup/commands/yfm.js +10 -1
- package/build/cjs/utils/directive.d.ts +28 -0
- package/build/cjs/utils/directive.js +55 -0
- package/build/cjs/utils/index.d.ts +1 -0
- package/build/cjs/version.js +1 -1
- package/build/esm/bundle/Editor.d.ts +2 -0
- package/build/esm/bundle/Editor.js +8 -2
- package/build/esm/bundle/MarkdownEditorView.js +1 -0
- package/build/esm/bundle/SplitModeView.js +1 -0
- package/build/esm/bundle/types.d.ts +22 -0
- package/build/esm/bundle/useMarkdownEditor.js +6 -2
- package/build/esm/bundle/wysiwyg-preset.d.ts +11 -2
- package/build/esm/bundle/wysiwyg-preset.js +1 -0
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/const.d.ts +4 -0
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/const.js +5 -0
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/index.d.ts +8 -1
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/index.js +8 -3
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/parser.js +6 -2
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/schema.d.ts +1 -1
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/schema.js +8 -3
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/serializer.d.ts +3 -1
- package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/serializer.js +41 -24
- package/build/esm/extensions/yfm/YfmFile/YfmFileSpecs/const.js +1 -1
- package/build/esm/extensions/yfm/YfmFile/YfmFileSpecs/index.js +4 -5
- package/build/esm/extensions/yfm/YfmFile/index.d.ts +1 -0
- package/build/esm/extensions/yfm/YfmFile/index.js +2 -1
- package/build/esm/index.d.ts +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/markup/codemirror/create.d.ts +7 -5
- package/build/esm/markup/codemirror/create.js +3 -2
- package/build/esm/markup/codemirror/directive-facet.d.ts +3 -0
- package/build/esm/markup/codemirror/directive-facet.js +5 -0
- package/build/esm/markup/codemirror/index.d.ts +1 -0
- package/build/esm/markup/codemirror/index.js +1 -0
- package/build/esm/markup/codemirror/yfm.d.ts +5 -0
- package/build/esm/markup/codemirror/yfm.js +25 -3
- package/build/esm/markup/commands/yfm.js +9 -1
- package/build/esm/utils/directive.d.ts +28 -0
- package/build/esm/utils/directive.js +51 -0
- package/build/esm/utils/index.d.ts +1 -0
- package/build/esm/version.js +1 -1
- package/package.json +5 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CommonEditor } from '../common';
|
|
2
2
|
import { ReactRenderStorage } from '../extensions';
|
|
3
3
|
import { type Receiver } from '../utils';
|
|
4
|
+
import type { DirectiveSyntaxContext } from '../utils/directive';
|
|
4
5
|
import type { MarkdownEditorMode as EditorMode, MarkdownEditorPreset as EditorPreset, MarkdownEditorOptions } from './types';
|
|
5
6
|
export declare type ToolbarActionData = {
|
|
6
7
|
editorMode: EditorMode;
|
|
@@ -41,5 +42,6 @@ export declare type ChangeEditorModeOptions = {
|
|
|
41
42
|
export declare type EditorOptions = Pick<MarkdownEditorOptions, 'md' | 'initial' | 'handlers' | 'experimental' | 'markupConfig' | 'wysiwygConfig'> & {
|
|
42
43
|
renderStorage: ReactRenderStorage;
|
|
43
44
|
preset: EditorPreset;
|
|
45
|
+
directiveSyntax: DirectiveSyntaxContext;
|
|
44
46
|
};
|
|
45
47
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _EditorImpl_markup, _EditorImpl_editorMode, _EditorImpl_toolbarVisible, _EditorImpl_splitModeEnabled, _EditorImpl_splitMode, _EditorImpl_renderPreview, _EditorImpl_wysiwygEditor, _EditorImpl_markupEditor, _EditorImpl_markupConfig, _EditorImpl_escapeConfig, _EditorImpl_mdOptions, _EditorImpl_preset, _EditorImpl_extensions, _EditorImpl_renderStorage, _EditorImpl_fileUploadHandler, _EditorImpl_parseInsertedUrlAsImage, _EditorImpl_needToSetDimensionsForUploadedImages, _EditorImpl_enableNewImageSizeCalculation, _EditorImpl_prepareRawMarkup, _EditorImpl_beforeEditorModeChange;
|
|
2
|
+
var _EditorImpl_markup, _EditorImpl_editorMode, _EditorImpl_toolbarVisible, _EditorImpl_splitModeEnabled, _EditorImpl_splitMode, _EditorImpl_renderPreview, _EditorImpl_wysiwygEditor, _EditorImpl_markupEditor, _EditorImpl_markupConfig, _EditorImpl_escapeConfig, _EditorImpl_mdOptions, _EditorImpl_preset, _EditorImpl_extensions, _EditorImpl_renderStorage, _EditorImpl_fileUploadHandler, _EditorImpl_parseInsertedUrlAsImage, _EditorImpl_needToSetDimensionsForUploadedImages, _EditorImpl_enableNewImageSizeCalculation, _EditorImpl_directiveSyntax, _EditorImpl_prepareRawMarkup, _EditorImpl_beforeEditorModeChange;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.EditorImpl = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
@@ -34,6 +34,7 @@ class EditorImpl extends utils_1.SafeEventEmitter {
|
|
|
34
34
|
_EditorImpl_parseInsertedUrlAsImage.set(this, void 0);
|
|
35
35
|
_EditorImpl_needToSetDimensionsForUploadedImages.set(this, void 0);
|
|
36
36
|
_EditorImpl_enableNewImageSizeCalculation.set(this, void 0);
|
|
37
|
+
_EditorImpl_directiveSyntax.set(this, void 0);
|
|
37
38
|
_EditorImpl_prepareRawMarkup.set(this, void 0);
|
|
38
39
|
_EditorImpl_beforeEditorModeChange.set(this, void 0);
|
|
39
40
|
this.getValue = () => this.currentEditor.getValue();
|
|
@@ -52,6 +53,7 @@ class EditorImpl extends utils_1.SafeEventEmitter {
|
|
|
52
53
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_fileUploadHandler, handlers.uploadFile, "f");
|
|
53
54
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_parseInsertedUrlAsImage, markupConfig.parseInsertedUrlAsImage, "f");
|
|
54
55
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_needToSetDimensionsForUploadedImages, Boolean(experimental.needToSetDimensionsForUploadedImages), "f");
|
|
56
|
+
tslib_1.__classPrivateFieldSet(this, _EditorImpl_directiveSyntax, opts.directiveSyntax, "f");
|
|
55
57
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_enableNewImageSizeCalculation, Boolean(experimental.enableNewImageSizeCalculation), "f");
|
|
56
58
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_prepareRawMarkup, experimental.prepareRawMarkup, "f");
|
|
57
59
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_escapeConfig, wysiwygConfig.escapeConfig, "f");
|
|
@@ -120,6 +122,9 @@ class EditorImpl extends utils_1.SafeEventEmitter {
|
|
|
120
122
|
get mdOptions() {
|
|
121
123
|
return tslib_1.__classPrivateFieldGet(this, _EditorImpl_mdOptions, "f");
|
|
122
124
|
}
|
|
125
|
+
get directiveSyntax() {
|
|
126
|
+
return tslib_1.__classPrivateFieldGet(this, _EditorImpl_directiveSyntax, "f");
|
|
127
|
+
}
|
|
123
128
|
get renderPreview() {
|
|
124
129
|
return tslib_1.__classPrivateFieldGet(this, _EditorImpl_renderPreview, "f");
|
|
125
130
|
}
|
|
@@ -172,6 +177,7 @@ class EditorImpl extends utils_1.SafeEventEmitter {
|
|
|
172
177
|
keymaps: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").keymaps,
|
|
173
178
|
yfmLangOptions: { languageData: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").languageData },
|
|
174
179
|
autocompletion: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").autocompletion,
|
|
180
|
+
directiveSyntax: this.directiveSyntax,
|
|
175
181
|
receiver: this,
|
|
176
182
|
})), "f");
|
|
177
183
|
}
|
|
@@ -312,7 +318,7 @@ class EditorImpl extends utils_1.SafeEventEmitter {
|
|
|
312
318
|
}
|
|
313
319
|
}
|
|
314
320
|
exports.EditorImpl = EditorImpl;
|
|
315
|
-
_EditorImpl_markup = new WeakMap(), _EditorImpl_editorMode = new WeakMap(), _EditorImpl_toolbarVisible = new WeakMap(), _EditorImpl_splitModeEnabled = new WeakMap(), _EditorImpl_splitMode = new WeakMap(), _EditorImpl_renderPreview = new WeakMap(), _EditorImpl_wysiwygEditor = new WeakMap(), _EditorImpl_markupEditor = new WeakMap(), _EditorImpl_markupConfig = new WeakMap(), _EditorImpl_escapeConfig = new WeakMap(), _EditorImpl_mdOptions = new WeakMap(), _EditorImpl_preset = new WeakMap(), _EditorImpl_extensions = new WeakMap(), _EditorImpl_renderStorage = new WeakMap(), _EditorImpl_fileUploadHandler = new WeakMap(), _EditorImpl_parseInsertedUrlAsImage = new WeakMap(), _EditorImpl_needToSetDimensionsForUploadedImages = new WeakMap(), _EditorImpl_enableNewImageSizeCalculation = new WeakMap(), _EditorImpl_prepareRawMarkup = new WeakMap(), _EditorImpl_beforeEditorModeChange = new WeakMap();
|
|
321
|
+
_EditorImpl_markup = new WeakMap(), _EditorImpl_editorMode = new WeakMap(), _EditorImpl_toolbarVisible = new WeakMap(), _EditorImpl_splitModeEnabled = new WeakMap(), _EditorImpl_splitMode = new WeakMap(), _EditorImpl_renderPreview = new WeakMap(), _EditorImpl_wysiwygEditor = new WeakMap(), _EditorImpl_markupEditor = new WeakMap(), _EditorImpl_markupConfig = new WeakMap(), _EditorImpl_escapeConfig = new WeakMap(), _EditorImpl_mdOptions = new WeakMap(), _EditorImpl_preset = new WeakMap(), _EditorImpl_extensions = new WeakMap(), _EditorImpl_renderStorage = new WeakMap(), _EditorImpl_fileUploadHandler = new WeakMap(), _EditorImpl_parseInsertedUrlAsImage = new WeakMap(), _EditorImpl_needToSetDimensionsForUploadedImages = new WeakMap(), _EditorImpl_enableNewImageSizeCalculation = new WeakMap(), _EditorImpl_directiveSyntax = new WeakMap(), _EditorImpl_prepareRawMarkup = new WeakMap(), _EditorImpl_beforeEditorModeChange = new WeakMap();
|
|
316
322
|
function getTopOffset(elem) {
|
|
317
323
|
const TOOLBAR_HEIGHT = 36; //px
|
|
318
324
|
const TOOLBAR_BOTTOM_OFFSET = 8; // px
|
|
@@ -123,6 +123,7 @@ exports.MarkdownEditorView = react_1.default.forwardRef((props, ref) => {
|
|
|
123
123
|
getValue: editor.getValue,
|
|
124
124
|
mode: 'preview',
|
|
125
125
|
md: editor.mdOptions,
|
|
126
|
+
directiveSyntax: editor.directiveSyntax,
|
|
126
127
|
})),
|
|
127
128
|
settings)) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
128
129
|
editorMode === 'wysiwyg' && (react_1.default.createElement(WysiwygEditorView_1.WysiwygEditorView, { editor: editor, autofocus: autofocus, settingsVisible: settingsVisible, toolbarConfig: wysiwygToolbarConfig, toolbarVisible: editor.toolbarVisible, hiddenActionsConfig: wysiwygHiddenActionsConfig, className: b('editor', { mode: editorMode }), toolbarClassName: b('toolbar'), stickyToolbar: stickyToolbar }, editor.toolbarVisible && settingsVisible && settings)),
|
|
@@ -3,6 +3,7 @@ import type { MarkupString } from '../common';
|
|
|
3
3
|
import type { EscapeConfig, Extension } from '../core';
|
|
4
4
|
import type { CreateCodemirrorParams, YfmLangOptions } from '../markup';
|
|
5
5
|
import type { FileUploadHandler } from '../utils';
|
|
6
|
+
import type { DirectiveSyntaxContext, DirectiveSyntaxOption } from '../utils/directive';
|
|
6
7
|
import type { ChangeEditorModeOptions } from './Editor';
|
|
7
8
|
import type { ExtensionsOptions as WysiwygPresetExtensionsOptions } from './wysiwyg-preset';
|
|
8
9
|
export type { Editor as MarkdownEditorInstance } from './Editor';
|
|
@@ -13,6 +14,7 @@ export declare type RenderPreviewParams = {
|
|
|
13
14
|
getValue: () => MarkupString;
|
|
14
15
|
mode: 'preview' | 'split';
|
|
15
16
|
md: Readonly<MarkdownEditorMdOptions>;
|
|
17
|
+
directiveSyntax: Pick<DirectiveSyntaxContext, 'option' | 'valueFor' | 'mdPluginValueFor'>;
|
|
16
18
|
};
|
|
17
19
|
export declare type RenderPreview = (params: RenderPreviewParams) => ReactNode;
|
|
18
20
|
export declare type ParseInsertedUrlAsImage = (text: string) => {
|
|
@@ -61,6 +63,26 @@ export declare type MarkdownEditorExperimentalOptions = {
|
|
|
61
63
|
*/
|
|
62
64
|
prepareRawMarkup?: (value: MarkupString) => MarkupString;
|
|
63
65
|
beforeEditorModeChange?: (options: Pick<ChangeEditorModeOptions, 'mode' | 'reason'>) => boolean | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Enables support of directive syntax for diplodoc (YFM) extensions.
|
|
68
|
+
*
|
|
69
|
+
* **Note:** This setting affects parsing of markdown markup and serializing to markdown markup.
|
|
70
|
+
* Be careful with it and use it in consistency with diplodoc/transform and diplodoc-extensions.
|
|
71
|
+
*
|
|
72
|
+
* Before enabling this option, make sure that appropriate versions of diplodoc/transform and diplodoc-extensions are installed.
|
|
73
|
+
*
|
|
74
|
+
* You can pass an object in `key:value` format to provide different behaviour for each extension individually.
|
|
75
|
+
*
|
|
76
|
+
* Values:
|
|
77
|
+
* - 'disabled' – directive syntax is disabled;
|
|
78
|
+
* - 'enabled' – directive syntax is enabled. Syntax of existing blocks is preserved. New blocks will be serialized using old syntax;
|
|
79
|
+
* - 'preserve' – directive syntax is enabled. Syntax of existing blocks is preserved. New blocks will be serialized using directive syntax;
|
|
80
|
+
* - 'overwrite' – existing blocks will be overwritten using directive syntax through serialization;
|
|
81
|
+
* - 'only' – old syntax is disabled, only directive syntax available. Blocks in old syntax will not be parsed.
|
|
82
|
+
*
|
|
83
|
+
* Default value is 'disabled'.
|
|
84
|
+
*/
|
|
85
|
+
directiveSyntax?: DirectiveSyntaxOption;
|
|
64
86
|
};
|
|
65
87
|
export declare type MarkdownEditorMarkupConfig = {
|
|
66
88
|
/**
|
|
@@ -4,6 +4,7 @@ exports.useMarkdownEditor = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const extensions_1 = require("../extensions");
|
|
6
6
|
const logger_1 = require("../logger");
|
|
7
|
+
const directive_1 = require("../utils/directive");
|
|
7
8
|
const Editor_1 = require("./Editor");
|
|
8
9
|
const wysiwyg_preset_1 = require("./wysiwyg-preset");
|
|
9
10
|
// [major] TODO: remove generic type
|
|
@@ -17,10 +18,12 @@ function useMarkdownEditor(props, deps = []) {
|
|
|
17
18
|
const uploadFile = (_c = handlers.uploadFile) !== null && _c !== void 0 ? _c : props.fileUploadHandler;
|
|
18
19
|
const needToSetDimensionsForUploadedImages = (_d = experimental.needToSetDimensionsForUploadedImages) !== null && _d !== void 0 ? _d : props.needToSetDimensionsForUploadedImages;
|
|
19
20
|
const enableNewImageSizeCalculation = experimental.enableNewImageSizeCalculation;
|
|
21
|
+
const directiveSyntax = new directive_1.DirectiveSyntaxContext(experimental.directiveSyntax);
|
|
20
22
|
const extensions = (builder) => {
|
|
21
23
|
var _a;
|
|
22
24
|
const extensionOptions = (_a = wysiwygConfig.extensionOptions) !== null && _a !== void 0 ? _a : props.extensionOptions;
|
|
23
|
-
builder.use(wysiwyg_preset_1.BundlePreset, Object.assign(Object.assign({}, extensionOptions), {
|
|
25
|
+
builder.use(wysiwyg_preset_1.BundlePreset, Object.assign(Object.assign({}, extensionOptions), { directiveSyntax,
|
|
26
|
+
preset, reactRenderer: renderStorage, onCancel: () => {
|
|
24
27
|
editor.emit('cancel', null);
|
|
25
28
|
return true;
|
|
26
29
|
}, onSubmit: () => {
|
|
@@ -36,7 +39,8 @@ function useMarkdownEditor(props, deps = []) {
|
|
|
36
39
|
}
|
|
37
40
|
};
|
|
38
41
|
return new Editor_1.EditorImpl(Object.assign(Object.assign({}, props), { preset,
|
|
39
|
-
renderStorage,
|
|
42
|
+
renderStorage,
|
|
43
|
+
directiveSyntax, md: Object.assign(Object.assign({}, md), { breaks, html: (_e = md.html) !== null && _e !== void 0 ? _e : props.allowHTML, linkify: (_f = md.linkify) !== null && _f !== void 0 ? _f : props.linkify, linkifyTlds: (_g = md.linkifyTlds) !== null && _g !== void 0 ? _g : props.linkifyTlds }), initial: Object.assign(Object.assign({}, initial), { markup: (_h = initial.markup) !== null && _h !== void 0 ? _h : props.initialMarkup, mode: (_j = initial.mode) !== null && _j !== void 0 ? _j : props.initialEditorMode, toolbarVisible: (_k = initial.toolbarVisible) !== null && _k !== void 0 ? _k : props.initialToolbarVisible, splitModeEnabled: (_l = initial.splitModeEnabled) !== null && _l !== void 0 ? _l : props.initialSplitModeEnabled }), handlers: Object.assign(Object.assign({}, handlers), { uploadFile }), experimental: Object.assign(Object.assign({}, experimental), { needToSetDimensionsForUploadedImages,
|
|
40
44
|
enableNewImageSizeCalculation, prepareRawMarkup: (_m = experimental.prepareRawMarkup) !== null && _m !== void 0 ? _m : props.prepareRawMarkup, beforeEditorModeChange: (_o = experimental.beforeEditorModeChange) !== null && _o !== void 0 ? _o : props.experimental_beforeEditorModeChange }), markupConfig: Object.assign(Object.assign({}, markupConfig), { splitMode: (_p = markupConfig.splitMode) !== null && _p !== void 0 ? _p : props.splitMode, renderPreview: (_q = markupConfig.renderPreview) !== null && _q !== void 0 ? _q : props.renderPreview, extensions: (_r = markupConfig.extensions) !== null && _r !== void 0 ? _r : props.extraMarkupExtensions }), wysiwygConfig: Object.assign(Object.assign({}, wysiwygConfig), { extensions, escapeConfig: (_s = wysiwygConfig.escapeConfig) !== null && _s !== void 0 ? _s : props.escapeConfig }) }));
|
|
41
45
|
}, deps);
|
|
42
46
|
(0, react_1.useLayoutEffect)(() => {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ExtensionAuto } from '../core';
|
|
1
|
+
import type { ExtensionAuto } from '../core';
|
|
2
2
|
import { BehaviorPresetOptions } from '../extensions/behavior';
|
|
3
3
|
import { EditorModeKeymapOptions } from '../extensions/behavior/EditorModeKeymap';
|
|
4
4
|
import { FullPresetOptions } from '../presets/full';
|
|
5
|
+
import type { DirectiveSyntaxContext } from '../utils/directive';
|
|
5
6
|
import type { FileUploadHandler } from '../utils/upload';
|
|
6
|
-
import { MarkdownEditorPreset } from './types';
|
|
7
|
+
import type { MarkdownEditorPreset } from './types';
|
|
7
8
|
export declare type ExtensionsOptions = BehaviorPresetOptions & FullPresetOptions;
|
|
8
9
|
export declare type BundlePresetOptions = ExtensionsOptions & EditorModeKeymapOptions & {
|
|
9
10
|
preset: MarkdownEditorPreset;
|
|
@@ -16,5 +17,13 @@ export declare type BundlePresetOptions = ExtensionsOptions & EditorModeKeymapOp
|
|
|
16
17
|
*/
|
|
17
18
|
needToSetDimensionsForUploadedImages?: boolean;
|
|
18
19
|
enableNewImageSizeCalculation?: boolean;
|
|
20
|
+
directiveSyntax: DirectiveSyntaxContext;
|
|
19
21
|
};
|
|
22
|
+
declare global {
|
|
23
|
+
namespace WysiwygEditor {
|
|
24
|
+
interface Context {
|
|
25
|
+
directiveSyntax: DirectiveSyntaxContext;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
20
29
|
export declare const BundlePreset: ExtensionAuto<BundlePresetOptions>;
|
|
@@ -16,6 +16,7 @@ const emoji_1 = require("./emoji");
|
|
|
16
16
|
const DEFAULT_IGNORED_KEYS = ['Tab', 'Shift-Tab'];
|
|
17
17
|
const BundlePreset = (builder, opts) => {
|
|
18
18
|
var _a, _b, _c;
|
|
19
|
+
builder.context.set('directiveSyntax', opts.directiveSyntax);
|
|
19
20
|
const dropCursor = {
|
|
20
21
|
color: 'var(--g-color-line-brand)',
|
|
21
22
|
width: 2,
|
|
@@ -3,6 +3,10 @@ export declare enum CutNode {
|
|
|
3
3
|
CutTitle = "yfm_cut_title",
|
|
4
4
|
CutContent = "yfm_cut_content"
|
|
5
5
|
}
|
|
6
|
+
export declare enum CutAttr {
|
|
7
|
+
Class = "class",
|
|
8
|
+
Markup = "data-markup"
|
|
9
|
+
}
|
|
6
10
|
export declare const cutType: (schema: import("prosemirror-model").Schema<any, any>) => import("prosemirror-model").NodeType;
|
|
7
11
|
export declare const cutTitleType: (schema: import("prosemirror-model").Schema<any, any>) => import("prosemirror-model").NodeType;
|
|
8
12
|
export declare const cutContentType: (schema: import("prosemirror-model").Schema<any, any>) => import("prosemirror-model").NodeType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cutContentType = exports.cutTitleType = exports.cutType = exports.CutNode = void 0;
|
|
3
|
+
exports.cutContentType = exports.cutTitleType = exports.cutType = exports.CutAttr = exports.CutNode = void 0;
|
|
4
4
|
const schema_1 = require("../../../../utils/schema");
|
|
5
5
|
var CutNode;
|
|
6
6
|
(function (CutNode) {
|
|
@@ -8,6 +8,11 @@ var CutNode;
|
|
|
8
8
|
CutNode["CutTitle"] = "yfm_cut_title";
|
|
9
9
|
CutNode["CutContent"] = "yfm_cut_content";
|
|
10
10
|
})(CutNode = exports.CutNode || (exports.CutNode = {}));
|
|
11
|
+
var CutAttr;
|
|
12
|
+
(function (CutAttr) {
|
|
13
|
+
CutAttr["Class"] = "class";
|
|
14
|
+
CutAttr["Markup"] = "data-markup";
|
|
15
|
+
})(CutAttr = exports.CutAttr || (exports.CutAttr = {}));
|
|
11
16
|
exports.cutType = (0, schema_1.nodeTypeFactory)(CutNode.Cut);
|
|
12
17
|
exports.cutTitleType = (0, schema_1.nodeTypeFactory)(CutNode.CutTitle);
|
|
13
18
|
exports.cutContentType = (0, schema_1.nodeTypeFactory)(CutNode.CutContent);
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { NodeSpec } from 'prosemirror-model';
|
|
2
2
|
import type { ExtensionAuto, ExtensionNodeSpec } from '../../../../core';
|
|
3
|
-
export { CutNode, cutType, cutTitleType, cutContentType } from './const';
|
|
3
|
+
export { CutAttr, CutNode, cutType, cutTitleType, cutContentType } from './const';
|
|
4
|
+
declare global {
|
|
5
|
+
namespace MarkdownEditor {
|
|
6
|
+
interface DirectiveSyntaxAdditionalSupportedExtensions {
|
|
7
|
+
yfmCut: true;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
4
11
|
export declare type YfmCutSpecsOptions = {
|
|
5
12
|
cutView?: ExtensionNodeSpec['view'];
|
|
6
13
|
cutTitleView?: ExtensionNodeSpec['view'];
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.YfmCutSpecs = exports.cutContentType = exports.cutTitleType = exports.cutType = exports.CutNode = void 0;
|
|
3
|
+
exports.YfmCutSpecs = exports.cutContentType = exports.cutTitleType = exports.cutType = exports.CutNode = exports.CutAttr = void 0;
|
|
4
4
|
const cut_extension_1 = require("@diplodoc/cut-extension");
|
|
5
5
|
const const_1 = require("./const");
|
|
6
6
|
const parser_1 = require("./parser");
|
|
7
7
|
const schema_1 = require("./schema");
|
|
8
8
|
const serializer_1 = require("./serializer");
|
|
9
9
|
var const_2 = require("./const");
|
|
10
|
+
Object.defineProperty(exports, "CutAttr", { enumerable: true, get: function () { return const_2.CutAttr; } });
|
|
10
11
|
Object.defineProperty(exports, "CutNode", { enumerable: true, get: function () { return const_2.CutNode; } });
|
|
11
12
|
Object.defineProperty(exports, "cutType", { enumerable: true, get: function () { return const_2.cutType; } });
|
|
12
13
|
Object.defineProperty(exports, "cutTitleType", { enumerable: true, get: function () { return const_2.cutTitleType; } });
|
|
13
14
|
Object.defineProperty(exports, "cutContentType", { enumerable: true, get: function () { return const_2.cutContentType; } });
|
|
14
15
|
const YfmCutSpecs = (builder, opts) => {
|
|
15
16
|
const schemaSpecs = (0, schema_1.getSchemaSpecs)(opts, builder.context.get('placeholder'));
|
|
17
|
+
const directiveSyntax = builder.context.get('directiveSyntax');
|
|
18
|
+
const serializerTokens = (0, serializer_1.getSerializerTokens)({ directiveSyntax });
|
|
16
19
|
builder
|
|
17
|
-
.configureMd((md) => md.use((0, cut_extension_1.transform)({
|
|
20
|
+
.configureMd((md) => md.use((0, cut_extension_1.transform)({
|
|
21
|
+
bundle: false,
|
|
22
|
+
directiveSyntax: directiveSyntax === null || directiveSyntax === void 0 ? void 0 : directiveSyntax.mdPluginValueFor('yfmCut'),
|
|
23
|
+
})))
|
|
18
24
|
.addNode(const_1.CutNode.Cut, () => ({
|
|
19
25
|
spec: schemaSpecs[const_1.CutNode.Cut],
|
|
20
|
-
toMd:
|
|
26
|
+
toMd: serializerTokens[const_1.CutNode.Cut],
|
|
21
27
|
fromMd: {
|
|
22
28
|
tokenSpec: parser_1.parserTokens[const_1.CutNode.Cut],
|
|
23
29
|
},
|
|
@@ -25,7 +31,7 @@ const YfmCutSpecs = (builder, opts) => {
|
|
|
25
31
|
}))
|
|
26
32
|
.addNode(const_1.CutNode.CutTitle, () => ({
|
|
27
33
|
spec: schemaSpecs[const_1.CutNode.CutTitle],
|
|
28
|
-
toMd:
|
|
34
|
+
toMd: serializerTokens[const_1.CutNode.CutTitle],
|
|
29
35
|
fromMd: {
|
|
30
36
|
tokenSpec: parser_1.parserTokens[const_1.CutNode.CutTitle],
|
|
31
37
|
},
|
|
@@ -33,7 +39,7 @@ const YfmCutSpecs = (builder, opts) => {
|
|
|
33
39
|
}))
|
|
34
40
|
.addNode(const_1.CutNode.CutContent, () => ({
|
|
35
41
|
spec: schemaSpecs[const_1.CutNode.CutContent],
|
|
36
|
-
toMd:
|
|
42
|
+
toMd: serializerTokens[const_1.CutNode.CutContent],
|
|
37
43
|
fromMd: {
|
|
38
44
|
tokenSpec: parser_1.parserTokens[const_1.CutNode.CutContent],
|
|
39
45
|
},
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parserTokens = void 0;
|
|
4
4
|
const const_1 = require("./const");
|
|
5
|
-
const getAttrs = (tok) =>
|
|
5
|
+
const getAttrs = (tok) => {
|
|
6
|
+
const nodeAttrs = tok.attrs ? Object.fromEntries(tok.attrs) : {};
|
|
7
|
+
nodeAttrs[const_1.CutAttr.Markup] = tok.markup;
|
|
8
|
+
return nodeAttrs;
|
|
9
|
+
};
|
|
6
10
|
exports.parserTokens = {
|
|
7
11
|
[const_1.CutNode.Cut]: { name: const_1.CutNode.Cut, type: 'block', getAttrs },
|
|
8
12
|
[const_1.CutNode.CutTitle]: { name: const_1.CutNode.CutTitle, type: 'block' },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NodeSpec } from 'prosemirror-model';
|
|
2
2
|
import type { PlaceholderOptions } from '../../../../utils/placeholder';
|
|
3
|
-
import { CutNode } from '
|
|
3
|
+
import { CutNode } from './const';
|
|
4
4
|
import type { YfmCutSpecsOptions } from './index';
|
|
5
5
|
export declare const getSchemaSpecs: (opts?: YfmCutSpecsOptions, placeholder?: PlaceholderOptions) => Record<CutNode, NodeSpec>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSchemaSpecs = void 0;
|
|
4
|
-
const const_1 = require("
|
|
4
|
+
const const_1 = require("./const");
|
|
5
5
|
const DEFAULT_PLACEHOLDERS = {
|
|
6
6
|
Title: 'Cut title',
|
|
7
7
|
Content: 'Cut content',
|
|
@@ -10,10 +10,15 @@ const getSchemaSpecs = (opts, placeholder) => {
|
|
|
10
10
|
var _a, _b, _c, _d;
|
|
11
11
|
return ({
|
|
12
12
|
[const_1.CutNode.Cut]: {
|
|
13
|
-
attrs: { class: { default: 'yfm-cut' } },
|
|
13
|
+
attrs: { class: { default: 'yfm-cut' }, [const_1.CutAttr.Markup]: { default: null } },
|
|
14
14
|
content: `${const_1.CutNode.CutTitle} ${const_1.CutNode.CutContent}`,
|
|
15
15
|
group: 'block yfm-cut',
|
|
16
|
-
parseDOM: [
|
|
16
|
+
parseDOM: [
|
|
17
|
+
{
|
|
18
|
+
tag: '.yfm-cut',
|
|
19
|
+
getAttrs: (node) => ({ [const_1.CutAttr.Markup]: node.getAttribute(const_1.CutAttr.Markup) }),
|
|
20
|
+
},
|
|
21
|
+
],
|
|
17
22
|
toDOM(node) {
|
|
18
23
|
return ['div', node.attrs, 0];
|
|
19
24
|
},
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { SerializerNodeToken } from '../../../../core';
|
|
2
2
|
import { CutNode } from './const';
|
|
3
|
-
export declare
|
|
3
|
+
export declare function getSerializerTokens({ directiveSyntax, }: {
|
|
4
|
+
directiveSyntax?: WysiwygEditor.Context['directiveSyntax'];
|
|
5
|
+
}): Record<CutNode, SerializerNodeToken>;
|
|
@@ -1,29 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getSerializerTokens = void 0;
|
|
4
4
|
const nodes_1 = require("../../../../utils/nodes");
|
|
5
5
|
const placeholder_1 = require("../../../../utils/placeholder");
|
|
6
6
|
const const_1 = require("./const");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
7
|
+
function getSerializerTokens({ directiveSyntax, }) {
|
|
8
|
+
const isDirectiveCut = (node) => {
|
|
9
|
+
return directiveSyntax === null || directiveSyntax === void 0 ? void 0 : directiveSyntax.shouldSerializeToDirective('yfmCut', node.attrs[const_1.CutAttr.Markup]);
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
[const_1.CutNode.Cut]: (state, node) => {
|
|
13
|
+
state.renderContent(node);
|
|
14
|
+
state.write(isDirectiveCut(node) ? ':::' : '{% endcut %}');
|
|
15
|
+
state.closeBlock(node);
|
|
16
|
+
},
|
|
17
|
+
[const_1.CutNode.CutTitle]: (state, node, parent) => {
|
|
18
|
+
if (isDirectiveCut(parent)) {
|
|
19
|
+
state.write(':::cut [');
|
|
20
|
+
state.renderInline(node);
|
|
21
|
+
state.write(']');
|
|
22
|
+
state.ensureNewLine();
|
|
23
|
+
state.closeBlock();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
state.write('{% cut "');
|
|
27
|
+
if (node.nodeSize > 2)
|
|
28
|
+
state.renderInline(node);
|
|
29
|
+
else
|
|
30
|
+
state.write((0, placeholder_1.getPlaceholderContent)(node));
|
|
31
|
+
state.write('" %}\n');
|
|
32
|
+
state.write('\n');
|
|
33
|
+
state.closeBlock();
|
|
34
|
+
},
|
|
35
|
+
[const_1.CutNode.CutContent]: (state, node, parent) => {
|
|
36
|
+
if (isDirectiveCut(parent)) {
|
|
37
|
+
state.renderContent(node);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!(0, nodes_1.isNodeEmpty)(node))
|
|
41
|
+
state.renderInline(node);
|
|
42
|
+
else
|
|
43
|
+
state.write((0, placeholder_1.getPlaceholderContent)(node) + '\n\n');
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
exports.getSerializerTokens = getSerializerTokens;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LINK_TO_FILE_ATTRS_MAP = exports.fileNodeAttrsSpec = exports.REQUIRED_ATTRS = exports.KNOWN_ATTRS = exports.yfmFileNodeName = void 0;
|
|
4
|
-
const
|
|
5
|
-
exports.yfmFileNodeName =
|
|
6
|
-
exports.KNOWN_ATTRS =
|
|
7
|
-
if (attrName in
|
|
8
|
-
return
|
|
4
|
+
const file_extension_1 = require("@diplodoc/file-extension");
|
|
5
|
+
exports.yfmFileNodeName = file_extension_1.FILE_TOKEN;
|
|
6
|
+
exports.KNOWN_ATTRS = file_extension_1.FILE_KNOWN_ATTRS.map((attrName) => {
|
|
7
|
+
if (attrName in file_extension_1.FILE_TO_LINK_ATTRS_MAP)
|
|
8
|
+
return file_extension_1.FILE_TO_LINK_ATTRS_MAP[attrName];
|
|
9
9
|
return attrName;
|
|
10
10
|
});
|
|
11
|
-
exports.REQUIRED_ATTRS =
|
|
12
|
-
if (attrName in
|
|
13
|
-
return
|
|
11
|
+
exports.REQUIRED_ATTRS = file_extension_1.FILE_REQUIRED_ATTRS.map((attrName) => {
|
|
12
|
+
if (attrName in file_extension_1.FILE_TO_LINK_ATTRS_MAP)
|
|
13
|
+
return file_extension_1.FILE_TO_LINK_ATTRS_MAP[attrName];
|
|
14
14
|
return attrName;
|
|
15
15
|
});
|
|
16
16
|
exports.fileNodeAttrsSpec = {};
|
|
@@ -21,6 +21,6 @@ for (const attrName of exports.KNOWN_ATTRS) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
exports.LINK_TO_FILE_ATTRS_MAP = {};
|
|
24
|
-
for (const [key, value] of Object.entries(
|
|
24
|
+
for (const [key, value] of Object.entries(file_extension_1.FILE_TO_LINK_ATTRS_MAP)) {
|
|
25
25
|
exports.LINK_TO_FILE_ATTRS_MAP[value] = key;
|
|
26
26
|
}
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.YfmFileSpecs = exports.fileType = exports.yfmFileNodeName = void 0;
|
|
4
|
-
const
|
|
5
|
-
const file_1 = tslib_1.__importDefault(require("@diplodoc/transform/lib/plugins/file"));
|
|
6
|
-
const const_1 = require("@diplodoc/transform/lib/plugins/file/const");
|
|
4
|
+
const file_extension_1 = require("@diplodoc/file-extension");
|
|
7
5
|
const schema_1 = require("../../../../utils/schema");
|
|
8
|
-
const
|
|
9
|
-
var
|
|
10
|
-
Object.defineProperty(exports, "yfmFileNodeName", { enumerable: true, get: function () { return
|
|
11
|
-
exports.fileType = (0, schema_1.nodeTypeFactory)(
|
|
6
|
+
const const_1 = require("./const");
|
|
7
|
+
var const_2 = require("./const");
|
|
8
|
+
Object.defineProperty(exports, "yfmFileNodeName", { enumerable: true, get: function () { return const_2.yfmFileNodeName; } });
|
|
9
|
+
exports.fileType = (0, schema_1.nodeTypeFactory)(const_1.yfmFileNodeName);
|
|
12
10
|
const YfmFileSpecs = (builder) => {
|
|
13
|
-
builder.configureMd((md) => md.use(
|
|
14
|
-
builder.addNode(
|
|
11
|
+
builder.configureMd((md) => md.use((0, file_extension_1.transform)({ bundle: false })));
|
|
12
|
+
builder.addNode(const_1.yfmFileNodeName, () => ({
|
|
15
13
|
spec: {
|
|
16
14
|
group: 'inline',
|
|
17
15
|
inline: true,
|
|
18
|
-
attrs:
|
|
16
|
+
attrs: const_1.fileNodeAttrsSpec,
|
|
19
17
|
parseDOM: [
|
|
20
18
|
{
|
|
21
|
-
tag: `a[class="${
|
|
19
|
+
tag: `a[class="${file_extension_1.FileClassName.Link}"]`,
|
|
22
20
|
getAttrs(p) {
|
|
23
21
|
const elem = p;
|
|
24
22
|
const attrs = {};
|
|
25
|
-
for (const name of
|
|
23
|
+
for (const name of const_1.KNOWN_ATTRS) {
|
|
26
24
|
const value = elem.getAttribute(name);
|
|
27
25
|
if (value) {
|
|
28
26
|
attrs[name] = value;
|
|
@@ -36,22 +34,22 @@ const YfmFileSpecs = (builder) => {
|
|
|
36
34
|
toDOM(node) {
|
|
37
35
|
const a = document.createElement('a');
|
|
38
36
|
a.contentEditable = 'false';
|
|
39
|
-
a.classList.add(
|
|
37
|
+
a.classList.add(file_extension_1.FileClassName.Link);
|
|
40
38
|
for (const [key, value] of Object.entries(node.attrs)) {
|
|
41
39
|
if (value)
|
|
42
40
|
a.setAttribute(key, value);
|
|
43
41
|
}
|
|
44
42
|
const span = document.createElement('span');
|
|
45
|
-
span.classList.add(
|
|
43
|
+
span.classList.add(file_extension_1.FileClassName.Icon);
|
|
46
44
|
a.appendChild(span);
|
|
47
|
-
a.append(node.attrs[
|
|
45
|
+
a.append(node.attrs[file_extension_1.FileHtmlAttr.Download]);
|
|
48
46
|
return a;
|
|
49
47
|
},
|
|
50
48
|
},
|
|
51
49
|
fromMd: {
|
|
52
|
-
tokenName:
|
|
50
|
+
tokenName: const_1.yfmFileNodeName,
|
|
53
51
|
tokenSpec: {
|
|
54
|
-
name:
|
|
52
|
+
name: const_1.yfmFileNodeName,
|
|
55
53
|
type: 'node',
|
|
56
54
|
getAttrs: (tok) => {
|
|
57
55
|
var _a;
|
|
@@ -63,15 +61,15 @@ const YfmFileSpecs = (builder) => {
|
|
|
63
61
|
const attrsStr = Object.entries(node.attrs)
|
|
64
62
|
.reduce((arr, [key, value]) => {
|
|
65
63
|
if (value) {
|
|
66
|
-
if (key in
|
|
67
|
-
key =
|
|
64
|
+
if (key in const_1.LINK_TO_FILE_ATTRS_MAP) {
|
|
65
|
+
key = const_1.LINK_TO_FILE_ATTRS_MAP[key];
|
|
68
66
|
}
|
|
69
67
|
arr.push(`${key}="${value.replace(/"/g, '')}"`);
|
|
70
68
|
}
|
|
71
69
|
return arr;
|
|
72
70
|
}, [])
|
|
73
71
|
.join(' ');
|
|
74
|
-
state.write(`${
|
|
72
|
+
state.write(`${file_extension_1.FILE_MARKUP_PREFIX}${attrsStr} %}`);
|
|
75
73
|
},
|
|
76
74
|
}));
|
|
77
75
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ExtensionAuto } from '../../../core';
|
|
2
2
|
import { FileUploadHandler } from '../../../utils/upload';
|
|
3
|
+
import '@diplodoc/file-extension/runtime/styles.css';
|
|
3
4
|
export declare type YfmFileOptions = {
|
|
4
5
|
fileUploadHandler?: FileUploadHandler;
|
|
5
6
|
needToSetDimensionsForUploadedImages?: boolean;
|
|
@@ -4,6 +4,7 @@ exports.YfmFile = void 0;
|
|
|
4
4
|
const YfmFilePaste_1 = require("./YfmFilePaste");
|
|
5
5
|
const YfmFileSpecs_1 = require("./YfmFileSpecs");
|
|
6
6
|
const YfmFileWidget_1 = require("./YfmFileWidget");
|
|
7
|
+
require("@diplodoc/file-extension/runtime/styles.css");
|
|
7
8
|
const YfmFile = (builder, opts = {}) => {
|
|
8
9
|
builder.use(YfmFileSpecs_1.YfmFileSpecs, opts);
|
|
9
10
|
builder.use(YfmFileWidget_1.YfmFileWidget, opts);
|
package/build/cjs/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export * from './forms';
|
|
|
11
11
|
export * from './view';
|
|
12
12
|
export * from './utils';
|
|
13
13
|
export * from './bundle';
|
|
14
|
-
export { ReactRendererFacet, getImageDimensions } from './markup';
|
|
14
|
+
export { DirectiveSyntaxFacet, ReactRendererFacet, getImageDimensions } from './markup';
|
|
15
15
|
export * as MarkupCommands from './markup/commands';
|
|
16
16
|
export * as MarkupHelpers from './markup/commands/helpers';
|
|
17
17
|
export { Lang, configure } from './configure';
|
package/build/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializeForClipboard = exports.getLastChildOfNode = exports.getChildrenOfNode = exports.findSelectedNodeOfType = exports.get$Cursor = exports.isWholeSelection = exports.isNodeSelection = exports.isTextSelection = exports.getPlaceholderContent = exports.isSameNodeType = exports.markTypeFactory = exports.nodeTypeFactory = exports.isSelectableNode = exports.isCodeBlock = exports.isNodeEmpty = exports.findFirstTextblockChild = exports.isMarkActive = exports.findMark = exports.inlineNodeInputRule = exports.nodeInputRule = exports.markInputRule = exports.isMac = exports.configure = exports.Lang = exports.MarkupHelpers = exports.MarkupCommands = exports.getImageDimensions = exports.ReactRendererFacet = void 0;
|
|
3
|
+
exports.serializeForClipboard = exports.getLastChildOfNode = exports.getChildrenOfNode = exports.findSelectedNodeOfType = exports.get$Cursor = exports.isWholeSelection = exports.isNodeSelection = exports.isTextSelection = exports.getPlaceholderContent = exports.isSameNodeType = exports.markTypeFactory = exports.nodeTypeFactory = exports.isSelectableNode = exports.isCodeBlock = exports.isNodeEmpty = exports.findFirstTextblockChild = exports.isMarkActive = exports.findMark = exports.inlineNodeInputRule = exports.nodeInputRule = exports.markInputRule = exports.isMac = exports.configure = exports.Lang = exports.MarkupHelpers = exports.MarkupCommands = exports.getImageDimensions = exports.ReactRendererFacet = exports.DirectiveSyntaxFacet = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./common"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./core"), exports);
|
|
@@ -16,6 +16,7 @@ tslib_1.__exportStar(require("./view"), exports);
|
|
|
16
16
|
tslib_1.__exportStar(require("./utils"), exports);
|
|
17
17
|
tslib_1.__exportStar(require("./bundle"), exports);
|
|
18
18
|
var markup_1 = require("./markup");
|
|
19
|
+
Object.defineProperty(exports, "DirectiveSyntaxFacet", { enumerable: true, get: function () { return markup_1.DirectiveSyntaxFacet; } });
|
|
19
20
|
Object.defineProperty(exports, "ReactRendererFacet", { enumerable: true, get: function () { return markup_1.ReactRendererFacet; } });
|
|
20
21
|
Object.defineProperty(exports, "getImageDimensions", { enumerable: true, get: function () { return markup_1.getImageDimensions; } });
|
|
21
22
|
exports.MarkupCommands = tslib_1.__importStar(require("./markup/commands"));
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { autocompletion } from '@codemirror/autocomplete';
|
|
2
2
|
import type { Extension, StateCommand } from '@codemirror/state';
|
|
3
|
-
import { EditorView, EditorViewConfig, KeyBinding, placeholder } from '@codemirror/view';
|
|
3
|
+
import { EditorView, type EditorViewConfig, KeyBinding, placeholder } from '@codemirror/view';
|
|
4
4
|
import type { ParseInsertedUrlAsImage } from '../../bundle';
|
|
5
|
-
import { EventMap } from '../../bundle/Editor';
|
|
6
|
-
import { ReactRenderStorage } from '../../extensions';
|
|
7
|
-
import { Receiver } from '../../utils';
|
|
8
|
-
import {
|
|
5
|
+
import type { EventMap } from '../../bundle/Editor';
|
|
6
|
+
import type { ReactRenderStorage } from '../../extensions';
|
|
7
|
+
import type { Receiver } from '../../utils';
|
|
8
|
+
import type { DirectiveSyntaxContext } from '../../utils/directive';
|
|
9
|
+
import { type FileUploadHandler } from './files-upload-facet';
|
|
9
10
|
import { type YfmLangOptions } from './yfm';
|
|
10
11
|
export type { YfmLangOptions };
|
|
11
12
|
declare type Autocompletion = Parameters<typeof autocompletion>[0];
|
|
@@ -30,6 +31,7 @@ export declare type CreateCodemirrorParams = {
|
|
|
30
31
|
receiver?: Receiver<EventMap>;
|
|
31
32
|
yfmLangOptions?: YfmLangOptions;
|
|
32
33
|
autocompletion?: Autocompletion;
|
|
34
|
+
directiveSyntax: DirectiveSyntaxContext;
|
|
33
35
|
};
|
|
34
36
|
export declare function createCodemirror(params: CreateCodemirrorParams): EditorView;
|
|
35
37
|
export declare function withLogger(action: string, command: StateCommand): StateCommand;
|