@gravity-ui/markdown-editor 13.2.0 → 13.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 +5 -2
- package/build/cjs/bundle/HorizontalDrag.d.ts +1 -0
- package/build/cjs/bundle/HorizontalDrag.js +2 -1
- package/build/cjs/bundle/config/action-names.d.ts +1 -1
- package/build/cjs/bundle/config/action-names.js +1 -0
- package/build/cjs/bundle/config/icons.d.ts +1 -1
- package/build/cjs/bundle/config/icons.js +1 -0
- package/build/cjs/bundle/config/markup.d.ts +1 -0
- package/build/cjs/bundle/config/markup.js +10 -1
- package/build/cjs/bundle/config/wysiwyg.d.ts +1 -0
- package/build/cjs/bundle/config/wysiwyg.js +12 -1
- package/build/cjs/bundle/wysiwyg-preset.js +2 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/NodeView.d.ts +23 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/NodeView.js +57 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/YfmHtmlBlock.css +66 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/YfmHtmlBlockView.d.ts +17 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/YfmHtmlBlockView.js +178 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/index.d.ts +1 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/index.js +4 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockSpecs/const.d.ts +15 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockSpecs/const.js +20 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockSpecs/index.d.ts +10 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockSpecs/index.js +43 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/actions.d.ts +2 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/actions.js +15 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/const.d.ts +2 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/const.js +6 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/index.d.ts +14 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/index.js +17 -0
- package/build/cjs/extensions/yfm/index.d.ts +1 -1
- package/build/cjs/extensions/yfm/index.js +1 -1
- package/build/cjs/i18n/common/en.json +6 -2
- package/build/cjs/i18n/common/index.d.ts +7 -3
- package/build/cjs/i18n/common/ru.json +6 -2
- package/build/cjs/i18n/menubar/en.json +37 -36
- package/build/cjs/i18n/menubar/index.d.ts +38 -37
- package/build/cjs/i18n/menubar/ru.json +37 -36
- package/build/cjs/icons/index.d.ts +1 -1
- package/build/cjs/icons/index.js +2 -1
- package/build/cjs/markup/codemirror/create.d.ts +2 -1
- package/build/cjs/markup/codemirror/create.js +5 -1
- package/build/cjs/markup/commands/blocks.d.ts +1 -0
- package/build/cjs/markup/commands/blocks.js +12 -1
- package/build/cjs/version.js +1 -1
- package/build/cjs/view/components/YfmHtml/{YfmHtml.d.ts → YfmStaticView.d.ts} +2 -2
- package/build/cjs/view/components/YfmHtml/{YfmHtml.js → YfmStaticView.js} +2 -2
- package/build/cjs/view/components/YfmHtml/index.d.ts +12 -1
- package/build/cjs/view/components/YfmHtml/index.js +4 -2
- package/build/cjs/view/hocs/withYfmHtml/index.d.ts +13 -0
- package/build/cjs/view/hocs/withYfmHtml/index.js +24 -0
- package/build/cjs/view/hocs/withYfmHtml/types.d.ts +3 -0
- package/build/cjs/view/hocs/withYfmHtml/types.js +2 -0
- package/build/cjs/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.d.ts +1 -0
- package/build/cjs/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.js +34 -0
- package/build/cjs/view/hocs/withYfmHtml/utils.d.ts +16 -0
- package/build/cjs/view/hocs/withYfmHtml/utils.js +26 -0
- package/build/esm/bundle/Editor.d.ts +2 -0
- package/build/esm/bundle/Editor.js +5 -2
- package/build/esm/bundle/HorizontalDrag.d.ts +1 -0
- package/build/esm/bundle/HorizontalDrag.js +2 -1
- package/build/esm/bundle/config/action-names.d.ts +1 -1
- package/build/esm/bundle/config/action-names.js +1 -0
- package/build/esm/bundle/config/icons.d.ts +1 -1
- package/build/esm/bundle/config/icons.js +2 -1
- package/build/esm/bundle/config/markup.d.ts +1 -0
- package/build/esm/bundle/config/markup.js +10 -1
- package/build/esm/bundle/config/wysiwyg.d.ts +1 -0
- package/build/esm/bundle/config/wysiwyg.js +11 -0
- package/build/esm/bundle/wysiwyg-preset.js +2 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/NodeView.d.ts +23 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/NodeView.js +52 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/YfmHtmlBlock.css +66 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/YfmHtmlBlockView.d.ts +18 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/YfmHtmlBlockView.js +173 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/index.d.ts +1 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/index.js +1 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockSpecs/const.d.ts +15 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockSpecs/const.js +17 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockSpecs/index.d.ts +10 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockSpecs/index.js +39 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/actions.d.ts +2 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/actions.js +12 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/const.d.ts +2 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/const.js +2 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/index.d.ts +14 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/index.js +13 -0
- package/build/esm/extensions/yfm/index.d.ts +1 -1
- package/build/esm/extensions/yfm/index.js +1 -1
- package/build/esm/i18n/common/en.json +6 -2
- package/build/esm/i18n/common/index.d.ts +7 -3
- package/build/esm/i18n/common/ru.json +6 -2
- package/build/esm/i18n/menubar/en.json +37 -36
- package/build/esm/i18n/menubar/index.d.ts +38 -37
- package/build/esm/i18n/menubar/ru.json +37 -36
- package/build/esm/icons/index.d.ts +1 -1
- package/build/esm/icons/index.js +1 -1
- package/build/esm/markup/codemirror/create.d.ts +2 -1
- package/build/esm/markup/codemirror/create.js +6 -2
- package/build/esm/markup/commands/blocks.d.ts +1 -0
- package/build/esm/markup/commands/blocks.js +10 -0
- package/build/esm/version.js +1 -1
- package/build/esm/view/components/YfmHtml/{YfmHtml.d.ts → YfmStaticView.d.ts} +2 -2
- package/build/esm/view/components/YfmHtml/{YfmHtml.js → YfmStaticView.js} +1 -1
- package/build/esm/view/components/YfmHtml/index.d.ts +12 -1
- package/build/esm/view/components/YfmHtml/index.js +6 -1
- package/build/esm/view/hocs/withYfmHtml/index.d.ts +13 -0
- package/build/esm/view/hocs/withYfmHtml/index.js +19 -0
- package/build/esm/view/hocs/withYfmHtml/types.d.ts +3 -0
- package/build/esm/view/hocs/withYfmHtml/types.js +1 -0
- package/build/esm/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.d.ts +1 -0
- package/build/esm/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.js +7 -0
- package/build/esm/view/hocs/withYfmHtml/utils.d.ts +16 -0
- package/build/esm/view/hocs/withYfmHtml/utils.js +22 -0
- package/build/styles.css +66 -0
- package/package.json +6 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withYfmHtmlBlock = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
const react_2 = require("@diplodoc/html-extension/react");
|
|
7
|
+
const useYfmHtmlBlockRuntime_1 = require("./useYfmHtmlBlockRuntime");
|
|
8
|
+
function withYfmHtmlBlock(opts) {
|
|
9
|
+
return (Component) => (0, react_1.forwardRef)(function WithYfmHtml(props, ref) {
|
|
10
|
+
const { meta, html, yfmHtmlBlockConfig } = props;
|
|
11
|
+
(0, useYfmHtmlBlockRuntime_1.useYfmHtmlBlockRuntime)(meta, opts.runtime);
|
|
12
|
+
const yfmHtmlBlock = (0, react_2.useDiplodocHtml)();
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
14
|
+
if (yfmHtmlBlock) {
|
|
15
|
+
if (yfmHtmlBlockConfig) {
|
|
16
|
+
yfmHtmlBlock.setConfig(yfmHtmlBlockConfig);
|
|
17
|
+
}
|
|
18
|
+
yfmHtmlBlock.reinitialize();
|
|
19
|
+
}
|
|
20
|
+
}, [yfmHtmlBlock, html, yfmHtmlBlockConfig]);
|
|
21
|
+
return react_1.default.createElement(Component, Object.assign({}, props, { ref: ref }));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.withYfmHtmlBlock = withYfmHtmlBlock;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.useYfmHtmlBlockRuntime = void 0;
|
|
27
|
+
/** @internal */
|
|
28
|
+
function useYfmHtmlBlockRuntime(meta, runtime = '_assets/html-extension.js') {
|
|
29
|
+
var _a;
|
|
30
|
+
if ((_a = meta === null || meta === void 0 ? void 0 : meta.script) === null || _a === void 0 ? void 0 : _a.includes(runtime)) {
|
|
31
|
+
Promise.resolve().then(() => __importStar(require(/* webpackChunkName: "yfm-html-runtime" */ '@diplodoc/html-extension/runtime')));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.useYfmHtmlBlockRuntime = useYfmHtmlBlockRuntime;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare const YfmHtmlBlockStyles: {
|
|
2
|
+
colorTextPrimary: string;
|
|
3
|
+
colorTextSecondary: string;
|
|
4
|
+
colorBackground: string;
|
|
5
|
+
colorBackgroundSecondary: string;
|
|
6
|
+
colorLink: string;
|
|
7
|
+
colorLinkHover: string;
|
|
8
|
+
colorLinkVisited: string;
|
|
9
|
+
font: string;
|
|
10
|
+
fontSize: string;
|
|
11
|
+
fontFamily: string;
|
|
12
|
+
lineHeight: string;
|
|
13
|
+
};
|
|
14
|
+
declare type Styles = Partial<Record<keyof typeof YfmHtmlBlockStyles, string>>;
|
|
15
|
+
export declare const getYfmHtmlBlockCssVariables: (styles: Styles) => Record<string, string>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getYfmHtmlBlockCssVariables = void 0;
|
|
4
|
+
const YfmHtmlBlockStyles = {
|
|
5
|
+
colorTextPrimary: '--yfm-html-color-text-primary',
|
|
6
|
+
colorTextSecondary: '--yfm-html-color-text-secondary',
|
|
7
|
+
colorBackground: '--yfm-html-color-background',
|
|
8
|
+
colorBackgroundSecondary: '--yfm-html-color-background-secondary',
|
|
9
|
+
colorLink: '--yfm-html-color-link',
|
|
10
|
+
colorLinkHover: '--yfm-html-color-link-hover',
|
|
11
|
+
colorLinkVisited: '--yfm-html-color-link-visited',
|
|
12
|
+
font: '--yfm-html-font',
|
|
13
|
+
fontSize: '--yfm-html-font-size',
|
|
14
|
+
fontFamily: '--yfm-html-font-family',
|
|
15
|
+
lineHeight: '--yfm-html-line-height', // Line height of the text
|
|
16
|
+
};
|
|
17
|
+
const getYfmHtmlBlockCssVariables = (styles) => {
|
|
18
|
+
const obj = {};
|
|
19
|
+
for (const key of Object.keys(styles)) {
|
|
20
|
+
if (YfmHtmlBlockStyles[key]) {
|
|
21
|
+
obj[YfmHtmlBlockStyles[key]] = styles[key];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
};
|
|
26
|
+
exports.getYfmHtmlBlockCssVariables = getYfmHtmlBlockCssVariables;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Extension as CodemirrorExtension } from '@codemirror/state';
|
|
2
3
|
import { CommonEditor, MarkupString } from '../common';
|
|
3
4
|
import { WysiwygEditorOptions } from '../core';
|
|
4
5
|
import { ReactRenderStorage } from '../extensions';
|
|
@@ -67,5 +68,6 @@ export declare type EditorOptions = Pick<WysiwygEditorOptions, 'allowHTML' | 'li
|
|
|
67
68
|
splitMode?: SplitMode;
|
|
68
69
|
renderPreview?: RenderPreview;
|
|
69
70
|
preset: EditorPreset;
|
|
71
|
+
extraMarkupExtensions?: CodemirrorExtension[];
|
|
70
72
|
};
|
|
71
73
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _EditorImpl_markup, _EditorImpl_editorMode, _EditorImpl_toolbarVisible, _EditorImpl_splitModeEnabled, _EditorImpl_splitMode, _EditorImpl_renderPreview, _EditorImpl_wysiwygEditor, _EditorImpl_markupEditor, _EditorImpl_preset, _EditorImpl_allowHTML, _EditorImpl_linkify, _EditorImpl_linkifyTlds, _EditorImpl_extensions, _EditorImpl_renderStorage, _EditorImpl_fileUploadHandler, _EditorImpl_needToSetDimensionsForUploadedImages, _EditorImpl_prepareRawMarkup;
|
|
1
|
+
var _EditorImpl_markup, _EditorImpl_editorMode, _EditorImpl_toolbarVisible, _EditorImpl_splitModeEnabled, _EditorImpl_splitMode, _EditorImpl_renderPreview, _EditorImpl_wysiwygEditor, _EditorImpl_markupEditor, _EditorImpl_extraMarkupExtensions, _EditorImpl_preset, _EditorImpl_allowHTML, _EditorImpl_linkify, _EditorImpl_linkifyTlds, _EditorImpl_extensions, _EditorImpl_renderStorage, _EditorImpl_fileUploadHandler, _EditorImpl_needToSetDimensionsForUploadedImages, _EditorImpl_prepareRawMarkup;
|
|
2
2
|
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
3
|
import { TextSelection } from 'prosemirror-state';
|
|
4
4
|
import { WysiwygEditor } from '../core';
|
|
@@ -20,6 +20,7 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
20
20
|
_EditorImpl_renderPreview.set(this, void 0);
|
|
21
21
|
_EditorImpl_wysiwygEditor.set(this, void 0);
|
|
22
22
|
_EditorImpl_markupEditor.set(this, void 0);
|
|
23
|
+
_EditorImpl_extraMarkupExtensions.set(this, void 0);
|
|
23
24
|
_EditorImpl_preset.set(this, void 0);
|
|
24
25
|
_EditorImpl_allowHTML.set(this, void 0);
|
|
25
26
|
_EditorImpl_linkify.set(this, void 0);
|
|
@@ -41,6 +42,7 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
41
42
|
__classPrivateFieldSet(this, _EditorImpl_linkifyTlds, opts.linkifyTlds, "f");
|
|
42
43
|
__classPrivateFieldSet(this, _EditorImpl_allowHTML, opts.allowHTML, "f");
|
|
43
44
|
__classPrivateFieldSet(this, _EditorImpl_extensions, opts.extensions, "f");
|
|
45
|
+
__classPrivateFieldSet(this, _EditorImpl_extraMarkupExtensions, opts.extraMarkupExtensions, "f");
|
|
44
46
|
__classPrivateFieldSet(this, _EditorImpl_renderStorage, opts.renderStorage, "f");
|
|
45
47
|
__classPrivateFieldSet(this, _EditorImpl_fileUploadHandler, opts.fileUploadHandler, "f");
|
|
46
48
|
__classPrivateFieldSet(this, _EditorImpl_needToSetDimensionsForUploadedImages, Boolean(opts.needToSetDimensionsForUploadedImages), "f");
|
|
@@ -149,6 +151,7 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
149
151
|
reactRenderer: __classPrivateFieldGet(this, _EditorImpl_renderStorage, "f"),
|
|
150
152
|
uploadHandler: this.fileUploadHandler,
|
|
151
153
|
needImgDimms: this.needToSetDimensionsForUploadedImages,
|
|
154
|
+
extraMarkupExtensions: __classPrivateFieldGet(this, _EditorImpl_extraMarkupExtensions, "f"),
|
|
152
155
|
})), "f");
|
|
153
156
|
}
|
|
154
157
|
return __classPrivateFieldGet(this, _EditorImpl_markupEditor, "f");
|
|
@@ -264,4 +267,4 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
264
267
|
return (serializedEditorMarkup === null || serializedEditorMarkup === void 0 ? void 0 : serializedEditorMarkup.trim()) !== wysiwygValue.trim();
|
|
265
268
|
}
|
|
266
269
|
}
|
|
267
|
-
_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_preset = new WeakMap(), _EditorImpl_allowHTML = new WeakMap(), _EditorImpl_linkify = new WeakMap(), _EditorImpl_linkifyTlds = new WeakMap(), _EditorImpl_extensions = new WeakMap(), _EditorImpl_renderStorage = new WeakMap(), _EditorImpl_fileUploadHandler = new WeakMap(), _EditorImpl_needToSetDimensionsForUploadedImages = new WeakMap(), _EditorImpl_prepareRawMarkup = new WeakMap();
|
|
270
|
+
_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_extraMarkupExtensions = new WeakMap(), _EditorImpl_preset = new WeakMap(), _EditorImpl_allowHTML = new WeakMap(), _EditorImpl_linkify = new WeakMap(), _EditorImpl_linkifyTlds = new WeakMap(), _EditorImpl_extensions = new WeakMap(), _EditorImpl_renderStorage = new WeakMap(), _EditorImpl_fileUploadHandler = new WeakMap(), _EditorImpl_needToSetDimensionsForUploadedImages = new WeakMap(), _EditorImpl_prepareRawMarkup = new WeakMap();
|
|
@@ -6,6 +6,7 @@ export declare type HorizontalDragProps = {
|
|
|
6
6
|
rightElRef: React.RefObject<HTMLDivElement>;
|
|
7
7
|
wrapperRef: React.RefObject<HTMLDivElement>;
|
|
8
8
|
editor: EditorInt;
|
|
9
|
+
onEndMove?: (right: HTMLDivElement | null, left: HTMLDivElement | null) => any;
|
|
9
10
|
};
|
|
10
11
|
declare const HorizontalDragWrapper: React.FC<HorizontalDragProps & {
|
|
11
12
|
isMounted: boolean;
|
|
@@ -44,7 +44,7 @@ const useColResize = ({ onStart, onMove, onEnd }) => {
|
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
|
-
const HorizontalDrag = ({ leftElRef, rightElRef, wrapperRef, editor, }) => {
|
|
47
|
+
const HorizontalDrag = ({ leftElRef, rightElRef, wrapperRef, editor, onEndMove, }) => {
|
|
48
48
|
var _a, _b, _c, _d;
|
|
49
49
|
const cm = editor.cm;
|
|
50
50
|
const [lCardWidth, lSetCardWidth] = useState(((_b = (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _b !== void 0 ? _b : 0) / 2);
|
|
@@ -96,6 +96,7 @@ const HorizontalDrag = ({ leftElRef, rightElRef, wrapperRef, editor, }) => {
|
|
|
96
96
|
cm.requestMeasure();
|
|
97
97
|
(_b = rightElRef.current) === null || _b === void 0 ? void 0 : _b.classList.remove(IN_RESIZE_CLASSNAME);
|
|
98
98
|
(_c = leftElRef.current) === null || _c === void 0 ? void 0 : _c.classList.remove(IN_RESIZE_CLASSNAME);
|
|
99
|
+
onEndMove === null || onEndMove === void 0 ? void 0 : onEndMove(rightElRef.current, leftElRef.current);
|
|
99
100
|
}, [calculateWidth, cm, leftElRef, rightElRef, updateWidth, wrapperRef]);
|
|
100
101
|
const { listeners } = useColResize({ onStart, onMove, onEnd });
|
|
101
102
|
return (React.createElement("div", Object.assign({ className: cnEditorComponent('resizer', { horizontal: true }) }, listeners),
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const namesObj: Record<"bold" | "link" | "italic" | "strike" | "underline" | "mark" | "quote" | "mono" | "paragraph" | "anchor" | "table" | "image" | "code_inline" | "code_block" | "file" | "checkbox" | "bulletList" | "orderedList" | "emoji" | "tabs" | "yfm_cut" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "yfm_note" | "undo" | "redo" | "math_inline" | "math_block" | "mermaid" | "liftListItem" | "sinkListItem" | "yfm_block" | "yfm_layout" | "horizontalrule", string>;
|
|
1
|
+
declare const namesObj: Record<"bold" | "link" | "italic" | "strike" | "underline" | "mark" | "quote" | "mono" | "paragraph" | "anchor" | "table" | "image" | "code_inline" | "code_block" | "file" | "checkbox" | "bulletList" | "orderedList" | "emoji" | "tabs" | "yfm_cut" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "yfm_note" | "undo" | "redo" | "math_inline" | "math_block" | "mermaid" | "liftListItem" | "sinkListItem" | "yfm_block" | "yfm_html_block" | "yfm_layout" | "horizontalrule", string>;
|
|
2
2
|
export declare const ActionName: Readonly<typeof namesObj>;
|
|
3
3
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ToolbarIconData } from '../../toolbar/types';
|
|
2
|
-
declare type Icon = 'undo' | 'redo' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'mono' | 'mark' | 'textColor' | 'text' | 'headline' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'bulletList' | 'orderedList' | 'sink' | 'lift' | 'cut' | 'note' | 'code' | 'codeBlock' | 'link' | 'image' | 'table' | 'quote' | 'checklist' | 'horizontalRule' | 'file' | 'functionInline' | 'functionBlock' | 'emoji' | 'tabs' | 'mermaid';
|
|
2
|
+
declare type Icon = 'undo' | 'redo' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'mono' | 'mark' | 'textColor' | 'text' | 'headline' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'bulletList' | 'orderedList' | 'sink' | 'lift' | 'cut' | 'note' | 'code' | 'codeBlock' | 'link' | 'image' | 'table' | 'quote' | 'checklist' | 'horizontalRule' | 'file' | 'functionInline' | 'functionBlock' | 'emoji' | 'tabs' | 'mermaid' | 'html';
|
|
3
3
|
declare type Icons = Record<Icon, ToolbarIconData>;
|
|
4
4
|
export declare const icons: Icons;
|
|
5
5
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BoldIcon, CheckListIcon, CodeBlockIcon, CodeInlineIcon, CutIcon, EmojiIcon, FileIcon, FunctionBlockIcon, FunctionInlineIcon, HRuleIcon, Heading1Icon, Heading2Icon, Heading3Icon, Heading4Icon, Heading5Icon, Heading6Icon, HeadingIcon, ImageIcon, ItalicIcon, LiftIcon, LinkIcon, ListBlIcon, ListOlIcon, MarkIcon, MermaidIcon, MonoIcon, NoteIcon, QuoteIcon, RedoIcon, SinkIcon, StrikethroughIcon, TableIcon, TabsIcon, TextColorIcon, TextIcon, UnderlineIcon, UndoIcon, } from '../../icons';
|
|
1
|
+
import { BoldIcon, CheckListIcon, CodeBlockIcon, CodeInlineIcon, CutIcon, EmojiIcon, FileIcon, FunctionBlockIcon, FunctionInlineIcon, HRuleIcon, Heading1Icon, Heading2Icon, Heading3Icon, Heading4Icon, Heading5Icon, Heading6Icon, HeadingIcon, HtmlBlockIcon, ImageIcon, ItalicIcon, LiftIcon, LinkIcon, ListBlIcon, ListOlIcon, MarkIcon, MermaidIcon, MonoIcon, NoteIcon, QuoteIcon, RedoIcon, SinkIcon, StrikethroughIcon, TableIcon, TabsIcon, TextColorIcon, TextIcon, UnderlineIcon, UndoIcon, } from '../../icons';
|
|
2
2
|
export const icons = {
|
|
3
3
|
undo: { data: UndoIcon },
|
|
4
4
|
redo: { data: RedoIcon },
|
|
@@ -30,6 +30,7 @@ export const icons = {
|
|
|
30
30
|
table: { data: TableIcon },
|
|
31
31
|
quote: { data: QuoteIcon },
|
|
32
32
|
checklist: { data: CheckListIcon },
|
|
33
|
+
html: { data: HtmlBlockIcon },
|
|
33
34
|
horizontalRule: { data: HRuleIcon },
|
|
34
35
|
file: { data: FileIcon },
|
|
35
36
|
functionInline: { data: FunctionInlineIcon },
|
|
@@ -35,6 +35,7 @@ export declare const mCodeListConfig: MToolbarListButtonData;
|
|
|
35
35
|
export declare const mMathListConfig: MToolbarListButtonData;
|
|
36
36
|
export declare const mMathListItem: MToolbarListItemData;
|
|
37
37
|
export declare const mMermaidButton: MToolbarSingleItemData;
|
|
38
|
+
export declare const mYfmHtmlBlockButton: MToolbarSingleItemData;
|
|
38
39
|
export declare const mImagePopupData: MToolbarButtonPopupData;
|
|
39
40
|
export declare const mFilePopupData: MToolbarButtonPopupData;
|
|
40
41
|
/** prepared markup toolbar config */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { i18n } from '../../i18n/menubar';
|
|
3
|
-
import { insertHRule, insertLink, insertMermaidDiagram, insertYfmTable, insertYfmTabs, liftListItem, redo, redoDepth, sinkListItem, toBulletList, toH1, toH2, toH3, toH4, toH5, toH6, toOrderedList, toggleBold, toggleItalic, toggleMarked, toggleMonospace, toggleStrikethrough, toggleUnderline, undo, undoDepth, wrapToBlockquote, wrapToCheckbox, wrapToCodeBlock, wrapToInlineCode, wrapToMathBlock, wrapToMathInline, wrapToYfmCut, wrapToYfmNote, } from '../../markup/commands';
|
|
3
|
+
import { insertHRule, insertLink, insertMermaidDiagram, insertYfmHtmlBlock, insertYfmTable, insertYfmTabs, liftListItem, redo, redoDepth, sinkListItem, toBulletList, toH1, toH2, toH3, toH4, toH5, toH6, toOrderedList, toggleBold, toggleItalic, toggleMarked, toggleMonospace, toggleStrikethrough, toggleUnderline, undo, undoDepth, wrapToBlockquote, wrapToCheckbox, wrapToCodeBlock, wrapToInlineCode, wrapToMathBlock, wrapToMathInline, wrapToYfmCut, wrapToYfmNote, } from '../../markup/commands';
|
|
4
4
|
import { Action as A, formatter as f } from '../../shortcuts';
|
|
5
5
|
import { ToolbarDataType, } from '../../toolbar/types';
|
|
6
6
|
import { MToolbarColors } from '../toolbar/markup/MToolbarColors';
|
|
@@ -356,6 +356,15 @@ export const mMermaidButton = {
|
|
|
356
356
|
isActive: isActiveFn,
|
|
357
357
|
isEnable: isEnableFn,
|
|
358
358
|
};
|
|
359
|
+
export const mYfmHtmlBlockButton = {
|
|
360
|
+
id: ActionName.yfm_html_block,
|
|
361
|
+
type: ToolbarDataType.SingleButton,
|
|
362
|
+
title: i18n.bind(null, 'html'),
|
|
363
|
+
icon: icons.html,
|
|
364
|
+
exec: (e) => insertYfmHtmlBlock(e.cm),
|
|
365
|
+
isActive: isActiveFn,
|
|
366
|
+
isEnable: isEnableFn,
|
|
367
|
+
};
|
|
359
368
|
export const mImagePopupData = {
|
|
360
369
|
id: 'image',
|
|
361
370
|
type: ToolbarDataType.ButtonPopup,
|
|
@@ -44,6 +44,7 @@ export declare const wTabsItemData: WToolbarSingleItemData;
|
|
|
44
44
|
export declare const wMathBlockItemData: WToolbarSingleItemData;
|
|
45
45
|
export declare const wMathListConfig: WToolbarListButtonData;
|
|
46
46
|
export declare const wMathListItem: WToolbarListItemData;
|
|
47
|
+
export declare const wYfmHtmlBlockItemData: WToolbarSingleItemData;
|
|
47
48
|
export declare const wCommandMenuConfig: WToolbarItemData[];
|
|
48
49
|
export declare const wHiddenData: WToolbarItemData[];
|
|
49
50
|
/** prepared wysiwyg toolbar config */
|
|
@@ -391,6 +391,15 @@ export const wMathListConfig = {
|
|
|
391
391
|
data: [wMathInlineItemData, wMathBlockItemData],
|
|
392
392
|
};
|
|
393
393
|
export const wMathListItem = Object.assign({ id: 'math', type: ToolbarDataType.ListButton }, wMathListConfig);
|
|
394
|
+
export const wYfmHtmlBlockItemData = {
|
|
395
|
+
id: ActionName.yfm_html_block,
|
|
396
|
+
type: ToolbarDataType.SingleButton,
|
|
397
|
+
title: i18n.bind(null, 'html'),
|
|
398
|
+
icon: icons.html,
|
|
399
|
+
exec: (e) => e.actions.createYfmHtmlBlock.run(),
|
|
400
|
+
isActive: (e) => e.actions.createYfmHtmlBlock.isActive(),
|
|
401
|
+
isEnable: (e) => e.actions.createYfmHtmlBlock.isEnable(),
|
|
402
|
+
};
|
|
394
403
|
export const wCommandMenuConfig = [
|
|
395
404
|
...wHeadingListConfig.data,
|
|
396
405
|
...wListsListConfig.data,
|
|
@@ -408,6 +417,7 @@ export const wCommandMenuConfig = [
|
|
|
408
417
|
// wMathInlineItemData,
|
|
409
418
|
// wMathBlockItemData,
|
|
410
419
|
wTabsItemData,
|
|
420
|
+
wYfmHtmlBlockItemData,
|
|
411
421
|
];
|
|
412
422
|
export const wHiddenData = wCommandMenuConfig;
|
|
413
423
|
/** prepared wysiwyg toolbar config */
|
|
@@ -543,6 +553,7 @@ export const wCommandMenuConfigByPreset = {
|
|
|
543
553
|
wHruleItemData,
|
|
544
554
|
wFileItemData,
|
|
545
555
|
wTabsItemData,
|
|
556
|
+
wYfmHtmlBlockItemData,
|
|
546
557
|
],
|
|
547
558
|
full: wCommandMenuConfig.slice(),
|
|
548
559
|
};
|
|
@@ -10,6 +10,7 @@ import { ZeroPreset } from '../presets/zero';
|
|
|
10
10
|
import { Action as A, formatter as f } from '../shortcuts';
|
|
11
11
|
import { wCommandMenuConfigByPreset, wSelectionMenuConfigByPreset } from './config/wysiwyg';
|
|
12
12
|
import { emojiDefs } from './emoji';
|
|
13
|
+
const DEFAULT_IGNORED_KEYS = ['Tab', 'Shift-Tab'];
|
|
13
14
|
export const BundlePreset = (builder, opts) => {
|
|
14
15
|
var _a, _b;
|
|
15
16
|
const dropCursor = {
|
|
@@ -63,6 +64,7 @@ export const BundlePreset = (builder, opts) => {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
const ignoreKeysList = (_b = (_a = opts.ignoreKeysList) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : [];
|
|
67
|
+
ignoreKeysList.push(...DEFAULT_IGNORED_KEYS);
|
|
66
68
|
for (const action of ignoreActions) {
|
|
67
69
|
const key = f.toPM(action);
|
|
68
70
|
if (key)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Node } from 'prosemirror-model';
|
|
2
|
+
import { EditorView, NodeView } from 'prosemirror-view';
|
|
3
|
+
import { YfmHtmlBlockOptions } from '../index';
|
|
4
|
+
export declare class WYfmHtmlBlockNodeView implements NodeView {
|
|
5
|
+
readonly dom: HTMLElement;
|
|
6
|
+
private node;
|
|
7
|
+
private readonly view;
|
|
8
|
+
private readonly getPos;
|
|
9
|
+
private readonly options;
|
|
10
|
+
private readonly renderItem;
|
|
11
|
+
constructor({ node, view, getPos, options, }: {
|
|
12
|
+
node: Node;
|
|
13
|
+
view: EditorView;
|
|
14
|
+
getPos: () => number | undefined;
|
|
15
|
+
options: YfmHtmlBlockOptions;
|
|
16
|
+
});
|
|
17
|
+
update(node: Node): boolean;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
ignoreMutation(): boolean;
|
|
20
|
+
stopEvent(e: Event): boolean;
|
|
21
|
+
private onChange;
|
|
22
|
+
private renderYfmHtmlBlock;
|
|
23
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import { getReactRendererFromState } from '../../../behavior';
|
|
4
|
+
import { YfmHtmlBlockConsts } from '../YfmHtmlBlockSpecs/const';
|
|
5
|
+
import { YfmHtmlBlockView } from './YfmHtmlBlockView';
|
|
6
|
+
export class WYfmHtmlBlockNodeView {
|
|
7
|
+
constructor({ node, view, getPos, options, }) {
|
|
8
|
+
this.options = {};
|
|
9
|
+
this.node = node;
|
|
10
|
+
this.dom = document.createElement('div');
|
|
11
|
+
this.dom.classList.add('yfm-html-block-container');
|
|
12
|
+
this.dom.contentEditable = 'false';
|
|
13
|
+
this.view = view;
|
|
14
|
+
this.getPos = getPos;
|
|
15
|
+
this.options = options;
|
|
16
|
+
this.renderItem = getReactRendererFromState(view.state).createItem('yfmHtmlBlock-view', this.renderYfmHtmlBlock.bind(this));
|
|
17
|
+
}
|
|
18
|
+
update(node) {
|
|
19
|
+
if (node.type !== this.node.type)
|
|
20
|
+
return false;
|
|
21
|
+
if (node.attrs[YfmHtmlBlockConsts.NodeAttrs.newCreated] !==
|
|
22
|
+
this.node.attrs[YfmHtmlBlockConsts.NodeAttrs.newCreated])
|
|
23
|
+
return false;
|
|
24
|
+
this.node = node;
|
|
25
|
+
this.renderItem.rerender();
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
destroy() {
|
|
29
|
+
this.renderItem.remove();
|
|
30
|
+
}
|
|
31
|
+
ignoreMutation() {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
stopEvent(e) {
|
|
35
|
+
const target = e.target;
|
|
36
|
+
if (typeof target.className === 'string' &&
|
|
37
|
+
target.className.includes('prosemirror-stop-event')) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
onChange(attrs) {
|
|
43
|
+
const pos = this.getPos();
|
|
44
|
+
if (pos === undefined)
|
|
45
|
+
return;
|
|
46
|
+
const tr = this.view.state.tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), attrs), []);
|
|
47
|
+
this.view.dispatch(tr);
|
|
48
|
+
}
|
|
49
|
+
renderYfmHtmlBlock() {
|
|
50
|
+
return createPortal(React.createElement(YfmHtmlBlockView, { useConfig: this.options.useConfig, view: this.view, onChange: this.onChange.bind(this), node: this.node, getPos: this.getPos }), this.dom);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
.g-md-yfm-html-block {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: flex;
|
|
4
|
+
justify-content: space-between;
|
|
5
|
+
margin-bottom: 15px;
|
|
6
|
+
padding-top: 28px;
|
|
7
|
+
border: 1px solid var(--g-color-line-generic);
|
|
8
|
+
border-radius: var(--g-border-radius-m);
|
|
9
|
+
}
|
|
10
|
+
.g-md-yfm-html-block_editing {
|
|
11
|
+
display: flex;
|
|
12
|
+
padding-top: 0;
|
|
13
|
+
border: 0;
|
|
14
|
+
}
|
|
15
|
+
.g-md-yfm-html-block__label {
|
|
16
|
+
position: absolute;
|
|
17
|
+
top: 8px;
|
|
18
|
+
left: 8px;
|
|
19
|
+
}
|
|
20
|
+
.g-md-yfm-html-block__menu {
|
|
21
|
+
position: absolute;
|
|
22
|
+
top: 0;
|
|
23
|
+
right: 0;
|
|
24
|
+
}
|
|
25
|
+
.g-md-yfm-html-block__preview {
|
|
26
|
+
flex: 1;
|
|
27
|
+
}
|
|
28
|
+
.g-md-yfm-html-block__error {
|
|
29
|
+
flex: 1;
|
|
30
|
+
font-family: var(--g-font-family-monospace);
|
|
31
|
+
color: var(--g-color-text-danger);
|
|
32
|
+
}
|
|
33
|
+
.g-md-yfm-html-block__editor {
|
|
34
|
+
flex: 1;
|
|
35
|
+
width: 50%;
|
|
36
|
+
white-space: nowrap;
|
|
37
|
+
caret-color: auto;
|
|
38
|
+
}
|
|
39
|
+
.g-md-yfm-html-block__editor .g-text-area__content {
|
|
40
|
+
font-size: 1em;
|
|
41
|
+
color: var(--yfm-color-hljs-subst);
|
|
42
|
+
border: 0;
|
|
43
|
+
border-radius: var(--g-border-radius-m);
|
|
44
|
+
background: var(--yfm-color-hljs-background);
|
|
45
|
+
font-feature-settings: normal;
|
|
46
|
+
}
|
|
47
|
+
.g-md-yfm-html-block__editor .g-text-area__control.g-md-YfmHtmlBlockHelper {
|
|
48
|
+
font-family: var(--yfm-font-family-monospace);
|
|
49
|
+
}
|
|
50
|
+
.g-md-yfm-html-block__editor-popover {
|
|
51
|
+
z-index: 1;
|
|
52
|
+
float: right;
|
|
53
|
+
}
|
|
54
|
+
.g-md-yfm-html-block__controls {
|
|
55
|
+
display: flex;
|
|
56
|
+
justify-content: end;
|
|
57
|
+
margin-top: 5px;
|
|
58
|
+
}
|
|
59
|
+
.g-md-yfm-html-block__content {
|
|
60
|
+
flex-grow: 1;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.g-root_theme_dark-hc .g-md-yfm-html-block_editing .g-text-area__content,
|
|
64
|
+
.g-root_theme_dark .g-md-yfm-html-block_editing .g-text-area__content {
|
|
65
|
+
color: var(--g-color-text-primary);
|
|
66
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IHTMLIFrameElementConfig } from '@diplodoc/html-extension/runtime';
|
|
3
|
+
import { Node } from 'prosemirror-model';
|
|
4
|
+
import { EditorView } from 'prosemirror-view';
|
|
5
|
+
import { YfmHtmlBlockConsts } from '../YfmHtmlBlockSpecs/const';
|
|
6
|
+
export declare const cnYfmHtmlBlock: import("@bem-react/classname").ClassNameFormatter;
|
|
7
|
+
export declare const cnHelper: import("@bem-react/classname").ClassNameFormatter;
|
|
8
|
+
import './YfmHtmlBlock.css';
|
|
9
|
+
export declare function generateID(): string;
|
|
10
|
+
export declare const YfmHtmlBlockView: React.FC<{
|
|
11
|
+
view: EditorView;
|
|
12
|
+
onChange: (attrs: {
|
|
13
|
+
[YfmHtmlBlockConsts.NodeAttrs.srcdoc]: string;
|
|
14
|
+
}) => void;
|
|
15
|
+
node: Node;
|
|
16
|
+
getPos: () => number | undefined;
|
|
17
|
+
useConfig?: () => IHTMLIFrameElementConfig | undefined;
|
|
18
|
+
}>;
|