@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
|
@@ -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,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_preset, _EditorImpl_allowHTML, _EditorImpl_linkify, _EditorImpl_linkifyTlds, _EditorImpl_extensions, _EditorImpl_renderStorage, _EditorImpl_fileUploadHandler, _EditorImpl_needToSetDimensionsForUploadedImages, _EditorImpl_prepareRawMarkup;
|
|
2
|
+
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;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.EditorImpl = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
@@ -23,6 +23,7 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
23
23
|
_EditorImpl_renderPreview.set(this, void 0);
|
|
24
24
|
_EditorImpl_wysiwygEditor.set(this, void 0);
|
|
25
25
|
_EditorImpl_markupEditor.set(this, void 0);
|
|
26
|
+
_EditorImpl_extraMarkupExtensions.set(this, void 0);
|
|
26
27
|
_EditorImpl_preset.set(this, void 0);
|
|
27
28
|
_EditorImpl_allowHTML.set(this, void 0);
|
|
28
29
|
_EditorImpl_linkify.set(this, void 0);
|
|
@@ -44,6 +45,7 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
44
45
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_linkifyTlds, opts.linkifyTlds, "f");
|
|
45
46
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_allowHTML, opts.allowHTML, "f");
|
|
46
47
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_extensions, opts.extensions, "f");
|
|
48
|
+
tslib_1.__classPrivateFieldSet(this, _EditorImpl_extraMarkupExtensions, opts.extraMarkupExtensions, "f");
|
|
47
49
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_renderStorage, opts.renderStorage, "f");
|
|
48
50
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_fileUploadHandler, opts.fileUploadHandler, "f");
|
|
49
51
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_needToSetDimensionsForUploadedImages, Boolean(opts.needToSetDimensionsForUploadedImages), "f");
|
|
@@ -152,6 +154,7 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
152
154
|
reactRenderer: tslib_1.__classPrivateFieldGet(this, _EditorImpl_renderStorage, "f"),
|
|
153
155
|
uploadHandler: this.fileUploadHandler,
|
|
154
156
|
needImgDimms: this.needToSetDimensionsForUploadedImages,
|
|
157
|
+
extraMarkupExtensions: tslib_1.__classPrivateFieldGet(this, _EditorImpl_extraMarkupExtensions, "f"),
|
|
155
158
|
})), "f");
|
|
156
159
|
}
|
|
157
160
|
return tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupEditor, "f");
|
|
@@ -268,4 +271,4 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
268
271
|
}
|
|
269
272
|
}
|
|
270
273
|
exports.EditorImpl = EditorImpl;
|
|
271
|
-
_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();
|
|
274
|
+
_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;
|
|
@@ -48,7 +48,7 @@ const useColResize = ({ onStart, onMove, onEnd }) => {
|
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
|
-
const HorizontalDrag = ({ leftElRef, rightElRef, wrapperRef, editor, }) => {
|
|
51
|
+
const HorizontalDrag = ({ leftElRef, rightElRef, wrapperRef, editor, onEndMove, }) => {
|
|
52
52
|
var _a, _b, _c, _d;
|
|
53
53
|
const cm = editor.cm;
|
|
54
54
|
const [lCardWidth, lSetCardWidth] = (0, react_1.useState)(((_b = (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _b !== void 0 ? _b : 0) / 2);
|
|
@@ -100,6 +100,7 @@ const HorizontalDrag = ({ leftElRef, rightElRef, wrapperRef, editor, }) => {
|
|
|
100
100
|
cm.requestMeasure();
|
|
101
101
|
(_b = rightElRef.current) === null || _b === void 0 ? void 0 : _b.classList.remove(exports.IN_RESIZE_CLASSNAME);
|
|
102
102
|
(_c = leftElRef.current) === null || _c === void 0 ? void 0 : _c.classList.remove(exports.IN_RESIZE_CLASSNAME);
|
|
103
|
+
onEndMove === null || onEndMove === void 0 ? void 0 : onEndMove(rightElRef.current, leftElRef.current);
|
|
103
104
|
}, [calculateWidth, cm, leftElRef, rightElRef, updateWidth, wrapperRef]);
|
|
104
105
|
const { listeners } = useColResize({ onStart, onMove, onEnd });
|
|
105
106
|
return (react_1.default.createElement("div", Object.assign({ className: (0, MarkdownEditorView_1.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 {};
|
|
@@ -33,6 +33,7 @@ exports.icons = {
|
|
|
33
33
|
table: { data: icons_1.TableIcon },
|
|
34
34
|
quote: { data: icons_1.QuoteIcon },
|
|
35
35
|
checklist: { data: icons_1.CheckListIcon },
|
|
36
|
+
html: { data: icons_1.HtmlBlockIcon },
|
|
36
37
|
horizontalRule: { data: icons_1.HRuleIcon },
|
|
37
38
|
file: { data: icons_1.FileIcon },
|
|
38
39
|
functionInline: { data: icons_1.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
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mHiddenDataByPreset = exports.mToolbarConfigByPreset = exports.mHiddenData = exports.mTabsItemData = exports.mHruleItemData = exports.mToolbarConfig = exports.mFilePopupData = exports.mImagePopupData = exports.mMermaidButton = exports.mMathListItem = exports.mMathListConfig = exports.mCodeListConfig = exports.mCodeblockItemData = exports.mTableButton = exports.mCutButton = exports.mQuoteButton = exports.mNoteButton = exports.mLinkButton = exports.mListMoveListConfig = exports.mCheckboxButton = exports.mListsListConfig = exports.mHeadingListConfig = exports.mBiusGroupConfig = exports.mMarkedItemData = exports.mMonospaceItemData = exports.mStrikethroughItemData = exports.mUnderlineItemData = exports.mItalicItemData = exports.mBoldItemData = exports.mHistoryGroupConfig = void 0;
|
|
3
|
+
exports.mHiddenDataByPreset = exports.mToolbarConfigByPreset = exports.mHiddenData = exports.mTabsItemData = exports.mHruleItemData = exports.mToolbarConfig = exports.mFilePopupData = exports.mImagePopupData = exports.mYfmHtmlBlockButton = exports.mMermaidButton = exports.mMathListItem = exports.mMathListConfig = exports.mCodeListConfig = exports.mCodeblockItemData = exports.mTableButton = exports.mCutButton = exports.mQuoteButton = exports.mNoteButton = exports.mLinkButton = exports.mListMoveListConfig = exports.mCheckboxButton = exports.mListsListConfig = exports.mHeadingListConfig = exports.mBiusGroupConfig = exports.mMarkedItemData = exports.mMonospaceItemData = exports.mStrikethroughItemData = exports.mUnderlineItemData = exports.mItalicItemData = exports.mBoldItemData = exports.mHistoryGroupConfig = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const menubar_1 = require("../../i18n/menubar");
|
|
@@ -360,6 +360,15 @@ exports.mMermaidButton = {
|
|
|
360
360
|
isActive: isActiveFn,
|
|
361
361
|
isEnable: isEnableFn,
|
|
362
362
|
};
|
|
363
|
+
exports.mYfmHtmlBlockButton = {
|
|
364
|
+
id: action_names_1.ActionName.yfm_html_block,
|
|
365
|
+
type: types_1.ToolbarDataType.SingleButton,
|
|
366
|
+
title: menubar_1.i18n.bind(null, 'html'),
|
|
367
|
+
icon: icons_1.icons.html,
|
|
368
|
+
exec: (e) => (0, commands_1.insertYfmHtmlBlock)(e.cm),
|
|
369
|
+
isActive: isActiveFn,
|
|
370
|
+
isEnable: isEnableFn,
|
|
371
|
+
};
|
|
363
372
|
exports.mImagePopupData = {
|
|
364
373
|
id: 'image',
|
|
365
374
|
type: types_1.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 */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wSelectionMenuConfigByPreset = exports.wHiddenDataByPreset = exports.wCommandMenuConfigByPreset = exports.wToolbarConfigByPreset = exports.wMermaidItemData = exports.wSelectionMenuConfig = exports.wToolbarConfig = exports.wHiddenData = exports.wCommandMenuConfig = exports.wMathListItem = exports.wMathListConfig = exports.wMathBlockItemData = exports.wTabsItemData = exports.wMathInlineItemData = exports.wFileItemData = exports.wEmojiItemData = exports.wHruleItemData = exports.wImageItemData = exports.wCodeListConfig = exports.wCodeBlockItemData = exports.wCodeItemData = exports.wTableItemData = exports.wNoteItemData = exports.wListMoveListConfig = exports.wCutItemData = exports.wQuoteItemData = exports.wLinkItemData = exports.wCheckboxItemData = exports.wListsListConfig = exports.wHeadingListConfig = exports.wTextItemData = exports.wBiusGroupConfig = exports.wMarkedItemData = exports.wMonospaceItemData = exports.wStrikethroughItemData = exports.wUnderlineItemData = exports.wItalicItemData = exports.wBoldItemData = exports.wHistoryGroupConfig = void 0;
|
|
3
|
+
exports.wSelectionMenuConfigByPreset = exports.wHiddenDataByPreset = exports.wCommandMenuConfigByPreset = exports.wToolbarConfigByPreset = exports.wMermaidItemData = exports.wSelectionMenuConfig = exports.wToolbarConfig = exports.wHiddenData = exports.wCommandMenuConfig = exports.wYfmHtmlBlockItemData = exports.wMathListItem = exports.wMathListConfig = exports.wMathBlockItemData = exports.wTabsItemData = exports.wMathInlineItemData = exports.wFileItemData = exports.wEmojiItemData = exports.wHruleItemData = exports.wImageItemData = exports.wCodeListConfig = exports.wCodeBlockItemData = exports.wCodeItemData = exports.wTableItemData = exports.wNoteItemData = exports.wListMoveListConfig = exports.wCutItemData = exports.wQuoteItemData = exports.wLinkItemData = exports.wCheckboxItemData = exports.wListsListConfig = exports.wHeadingListConfig = exports.wTextItemData = exports.wBiusGroupConfig = exports.wMarkedItemData = exports.wMonospaceItemData = exports.wStrikethroughItemData = exports.wUnderlineItemData = exports.wItalicItemData = exports.wBoldItemData = exports.wHistoryGroupConfig = void 0;
|
|
4
4
|
const extensions_1 = require("../../extensions");
|
|
5
5
|
const hints_1 = require("../../i18n/hints");
|
|
6
6
|
const menubar_1 = require("../../i18n/menubar");
|
|
@@ -394,6 +394,15 @@ exports.wMathListConfig = {
|
|
|
394
394
|
data: [exports.wMathInlineItemData, exports.wMathBlockItemData],
|
|
395
395
|
};
|
|
396
396
|
exports.wMathListItem = Object.assign({ id: 'math', type: types_1.ToolbarDataType.ListButton }, exports.wMathListConfig);
|
|
397
|
+
exports.wYfmHtmlBlockItemData = {
|
|
398
|
+
id: action_names_1.ActionName.yfm_html_block,
|
|
399
|
+
type: types_1.ToolbarDataType.SingleButton,
|
|
400
|
+
title: menubar_1.i18n.bind(null, 'html'),
|
|
401
|
+
icon: icons_1.icons.html,
|
|
402
|
+
exec: (e) => e.actions.createYfmHtmlBlock.run(),
|
|
403
|
+
isActive: (e) => e.actions.createYfmHtmlBlock.isActive(),
|
|
404
|
+
isEnable: (e) => e.actions.createYfmHtmlBlock.isEnable(),
|
|
405
|
+
};
|
|
397
406
|
exports.wCommandMenuConfig = [
|
|
398
407
|
...exports.wHeadingListConfig.data,
|
|
399
408
|
...exports.wListsListConfig.data,
|
|
@@ -411,6 +420,7 @@ exports.wCommandMenuConfig = [
|
|
|
411
420
|
// wMathInlineItemData,
|
|
412
421
|
// wMathBlockItemData,
|
|
413
422
|
exports.wTabsItemData,
|
|
423
|
+
exports.wYfmHtmlBlockItemData,
|
|
414
424
|
];
|
|
415
425
|
exports.wHiddenData = exports.wCommandMenuConfig;
|
|
416
426
|
/** prepared wysiwyg toolbar config */
|
|
@@ -546,6 +556,7 @@ exports.wCommandMenuConfigByPreset = {
|
|
|
546
556
|
exports.wHruleItemData,
|
|
547
557
|
exports.wFileItemData,
|
|
548
558
|
exports.wTabsItemData,
|
|
559
|
+
exports.wYfmHtmlBlockItemData,
|
|
549
560
|
],
|
|
550
561
|
full: exports.wCommandMenuConfig.slice(),
|
|
551
562
|
};
|
|
@@ -13,6 +13,7 @@ const zero_1 = require("../presets/zero");
|
|
|
13
13
|
const shortcuts_1 = require("../shortcuts");
|
|
14
14
|
const wysiwyg_1 = require("./config/wysiwyg");
|
|
15
15
|
const emoji_1 = require("./emoji");
|
|
16
|
+
const DEFAULT_IGNORED_KEYS = ['Tab', 'Shift-Tab'];
|
|
16
17
|
const BundlePreset = (builder, opts) => {
|
|
17
18
|
var _a, _b;
|
|
18
19
|
const dropCursor = {
|
|
@@ -66,6 +67,7 @@ const BundlePreset = (builder, opts) => {
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
const ignoreKeysList = (_b = (_a = opts.ignoreKeysList) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : [];
|
|
70
|
+
ignoreKeysList.push(...DEFAULT_IGNORED_KEYS);
|
|
69
71
|
for (const action of ignoreActions) {
|
|
70
72
|
const key = shortcuts_1.formatter.toPM(action);
|
|
71
73
|
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,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WYfmHtmlBlockNodeView = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const react_dom_1 = require("react-dom");
|
|
7
|
+
const behavior_1 = require("../../../behavior");
|
|
8
|
+
const const_1 = require("../YfmHtmlBlockSpecs/const");
|
|
9
|
+
const YfmHtmlBlockView_1 = require("./YfmHtmlBlockView");
|
|
10
|
+
class WYfmHtmlBlockNodeView {
|
|
11
|
+
constructor({ node, view, getPos, options, }) {
|
|
12
|
+
this.options = {};
|
|
13
|
+
this.node = node;
|
|
14
|
+
this.dom = document.createElement('div');
|
|
15
|
+
this.dom.classList.add('yfm-html-block-container');
|
|
16
|
+
this.dom.contentEditable = 'false';
|
|
17
|
+
this.view = view;
|
|
18
|
+
this.getPos = getPos;
|
|
19
|
+
this.options = options;
|
|
20
|
+
this.renderItem = (0, behavior_1.getReactRendererFromState)(view.state).createItem('yfmHtmlBlock-view', this.renderYfmHtmlBlock.bind(this));
|
|
21
|
+
}
|
|
22
|
+
update(node) {
|
|
23
|
+
if (node.type !== this.node.type)
|
|
24
|
+
return false;
|
|
25
|
+
if (node.attrs[const_1.YfmHtmlBlockConsts.NodeAttrs.newCreated] !==
|
|
26
|
+
this.node.attrs[const_1.YfmHtmlBlockConsts.NodeAttrs.newCreated])
|
|
27
|
+
return false;
|
|
28
|
+
this.node = node;
|
|
29
|
+
this.renderItem.rerender();
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
destroy() {
|
|
33
|
+
this.renderItem.remove();
|
|
34
|
+
}
|
|
35
|
+
ignoreMutation() {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
stopEvent(e) {
|
|
39
|
+
const target = e.target;
|
|
40
|
+
if (typeof target.className === 'string' &&
|
|
41
|
+
target.className.includes('prosemirror-stop-event')) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
onChange(attrs) {
|
|
47
|
+
const pos = this.getPos();
|
|
48
|
+
if (pos === undefined)
|
|
49
|
+
return;
|
|
50
|
+
const tr = this.view.state.tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), attrs), []);
|
|
51
|
+
this.view.dispatch(tr);
|
|
52
|
+
}
|
|
53
|
+
renderYfmHtmlBlock() {
|
|
54
|
+
return (0, react_dom_1.createPortal)(react_1.default.createElement(YfmHtmlBlockView_1.YfmHtmlBlockView, { useConfig: this.options.useConfig, view: this.view, onChange: this.onChange.bind(this), node: this.node, getPos: this.getPos }), this.dom);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.WYfmHtmlBlockNodeView = WYfmHtmlBlockNodeView;
|
|
@@ -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,17 @@
|
|
|
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
|
+
export declare function generateID(): string;
|
|
9
|
+
export declare const YfmHtmlBlockView: React.FC<{
|
|
10
|
+
view: EditorView;
|
|
11
|
+
onChange: (attrs: {
|
|
12
|
+
[YfmHtmlBlockConsts.NodeAttrs.srcdoc]: string;
|
|
13
|
+
}) => void;
|
|
14
|
+
node: Node;
|
|
15
|
+
getPos: () => number | undefined;
|
|
16
|
+
useConfig?: () => IHTMLIFrameElementConfig | undefined;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.YfmHtmlBlockView = exports.generateID = exports.cnHelper = exports.cnYfmHtmlBlock = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
const icons_1 = require("@gravity-ui/icons");
|
|
7
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
8
|
+
const debounce_1 = tslib_1.__importDefault(require("lodash/debounce"));
|
|
9
|
+
const classname_1 = require("../../../../classname");
|
|
10
|
+
const TextInput_1 = require("../../../../forms/TextInput");
|
|
11
|
+
const common_1 = require("../../../../i18n/common");
|
|
12
|
+
const hooks_1 = require("../../../../react-utils/hooks");
|
|
13
|
+
const remove_node_1 = require("../../../../utils/remove-node");
|
|
14
|
+
const const_1 = require("../YfmHtmlBlockSpecs/const");
|
|
15
|
+
exports.cnYfmHtmlBlock = (0, classname_1.cn)('yfm-html-block');
|
|
16
|
+
exports.cnHelper = (0, classname_1.cn)('yfm-html-block-helper');
|
|
17
|
+
const b = exports.cnYfmHtmlBlock;
|
|
18
|
+
function generateID() {
|
|
19
|
+
return Math.random().toString(36).substr(2, 8);
|
|
20
|
+
}
|
|
21
|
+
exports.generateID = generateID;
|
|
22
|
+
const DEFAULT_PADDING = 20;
|
|
23
|
+
const DEFAULT_DELAY = 100;
|
|
24
|
+
const YfmHtmlBlockPreview = ({ html, onСlick, config }) => {
|
|
25
|
+
var _a, _b, _c, _d, _e, _f;
|
|
26
|
+
const ref = (0, react_1.useRef)(null);
|
|
27
|
+
const styles = (0, react_1.useRef)({});
|
|
28
|
+
const classNames = (0, react_1.useRef)([]);
|
|
29
|
+
const resizeConfig = (0, react_1.useRef)({});
|
|
30
|
+
const [height, setHeight] = (0, react_1.useState)('100%');
|
|
31
|
+
(0, react_1.useEffect)(() => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
resizeConfig.current = {
|
|
34
|
+
padding: (_a = config === null || config === void 0 ? void 0 : config.resizePadding) !== null && _a !== void 0 ? _a : DEFAULT_PADDING,
|
|
35
|
+
delay: (_b = config === null || config === void 0 ? void 0 : config.resizeDelay) !== null && _b !== void 0 ? _b : DEFAULT_DELAY,
|
|
36
|
+
};
|
|
37
|
+
setStyles(config === null || config === void 0 ? void 0 : config.styles);
|
|
38
|
+
setClassNames(config === null || config === void 0 ? void 0 : config.classNames);
|
|
39
|
+
}, [config, (_c = (_b = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.contentWindow) === null || _b === void 0 ? void 0 : _b.document) === null || _c === void 0 ? void 0 : _c.body]);
|
|
40
|
+
const handleLoadIFrame = () => {
|
|
41
|
+
var _a;
|
|
42
|
+
const contentWindow = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.contentWindow;
|
|
43
|
+
handleResizeIFrame();
|
|
44
|
+
if (contentWindow) {
|
|
45
|
+
const frameDocument = contentWindow.document;
|
|
46
|
+
frameDocument.addEventListener('dblclick', () => {
|
|
47
|
+
onСlick();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const handleResizeIFrame = () => {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
if (ref.current) {
|
|
54
|
+
const contentWindow = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.contentWindow;
|
|
55
|
+
if (contentWindow) {
|
|
56
|
+
const body = contentWindow.document.body;
|
|
57
|
+
if (body) {
|
|
58
|
+
const height = body.scrollHeight +
|
|
59
|
+
(((_b = resizeConfig.current) === null || _b === void 0 ? void 0 : _b.padding) || DEFAULT_PADDING) +
|
|
60
|
+
'px';
|
|
61
|
+
setHeight(height);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const setClassNames = (newClassNames) => {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
const body = (_b = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.contentWindow) === null || _b === void 0 ? void 0 : _b.document.body;
|
|
69
|
+
if (body && newClassNames) {
|
|
70
|
+
const previousClassNames = classNames.current;
|
|
71
|
+
// remove all classes that were in previousClassNames but are not in classNames
|
|
72
|
+
previousClassNames.forEach((className) => {
|
|
73
|
+
if (!newClassNames.includes(className)) {
|
|
74
|
+
body.classList.remove(className);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
// add classes that are in classNames
|
|
78
|
+
newClassNames.forEach((className) => {
|
|
79
|
+
if (!body.classList.contains(className)) {
|
|
80
|
+
body.classList.add(className);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
classNames.current = newClassNames;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const setStyles = (newStyles) => {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
const body = (_b = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.contentWindow) === null || _b === void 0 ? void 0 : _b.document.body;
|
|
89
|
+
if (body && newStyles) {
|
|
90
|
+
const previousStyles = styles.current;
|
|
91
|
+
// remove all styles that are in previousStyles but not in styles
|
|
92
|
+
Object.keys(previousStyles).forEach((property) => {
|
|
93
|
+
if (!Object.prototype.hasOwnProperty.call(newStyles, property)) {
|
|
94
|
+
body.style.removeProperty(property);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
// sdd or update styles that are in styles
|
|
98
|
+
Object.keys(newStyles).forEach((property) => {
|
|
99
|
+
body.style.setProperty(property, newStyles[property]);
|
|
100
|
+
});
|
|
101
|
+
// update current styles to the new styles
|
|
102
|
+
styles.current = newStyles;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
(0, react_1.useEffect)(() => {
|
|
106
|
+
var _a;
|
|
107
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.addEventListener('load', handleLoadIFrame);
|
|
108
|
+
return () => {
|
|
109
|
+
var _a;
|
|
110
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('load', handleLoadIFrame);
|
|
111
|
+
};
|
|
112
|
+
}, [html]);
|
|
113
|
+
(0, react_1.useEffect)(() => {
|
|
114
|
+
var _a, _b;
|
|
115
|
+
if (ref.current) {
|
|
116
|
+
const resizeObserver = new window.ResizeObserver((0, debounce_1.default)(handleResizeIFrame, (_b = (_a = resizeConfig.current) === null || _a === void 0 ? void 0 : _a.delay) !== null && _b !== void 0 ? _b : DEFAULT_DELAY));
|
|
117
|
+
resizeObserver.observe(ref.current);
|
|
118
|
+
}
|
|
119
|
+
}, [(_f = (_e = (_d = ref.current) === null || _d === void 0 ? void 0 : _d.contentWindow) === null || _e === void 0 ? void 0 : _e.document) === null || _f === void 0 ? void 0 : _f.body]);
|
|
120
|
+
return (react_1.default.createElement("iframe", { style: {
|
|
121
|
+
height,
|
|
122
|
+
}, ref: ref, title: generateID(), frameBorder: 0, className: b('content'), srcDoc: html }));
|
|
123
|
+
};
|
|
124
|
+
const CodeEditMode = ({ initialText, onSave, onCancel }) => {
|
|
125
|
+
const [text, setText] = (0, react_1.useState)(initialText || '\n');
|
|
126
|
+
return (react_1.default.createElement("div", { className: b({ editing: true }) },
|
|
127
|
+
react_1.default.createElement("div", { className: b('editor') },
|
|
128
|
+
react_1.default.createElement(TextInput_1.TextAreaFixed, { controlProps: {
|
|
129
|
+
className: (0, exports.cnHelper)({ 'prosemirror-stop-event': true }),
|
|
130
|
+
}, value: text, onUpdate: (v) => {
|
|
131
|
+
setText(v);
|
|
132
|
+
}, autoFocus: true }),
|
|
133
|
+
react_1.default.createElement("div", { className: b('controls') },
|
|
134
|
+
react_1.default.createElement("div", null,
|
|
135
|
+
react_1.default.createElement(uikit_1.Button, { onClick: onCancel, view: 'flat' },
|
|
136
|
+
react_1.default.createElement("span", { className: (0, exports.cnHelper)({ 'prosemirror-stop-event': true }) }, (0, common_1.i18n)('cancel'))),
|
|
137
|
+
react_1.default.createElement(uikit_1.Button, { onClick: () => onSave(text), view: 'action' },
|
|
138
|
+
react_1.default.createElement("span", { className: (0, exports.cnHelper)({ 'prosemirror-stop-event': true }) }, (0, common_1.i18n)('save'))))))));
|
|
139
|
+
};
|
|
140
|
+
const YfmHtmlBlockView = ({ onChange, node, getPos, view, useConfig }) => {
|
|
141
|
+
const [editing, setEditing, unsetEditing, toggleEditing] = (0, hooks_1.useBooleanState)(Boolean(node.attrs[const_1.YfmHtmlBlockConsts.NodeAttrs.newCreated]));
|
|
142
|
+
const config = useConfig === null || useConfig === void 0 ? void 0 : useConfig();
|
|
143
|
+
const [menuOpen, , , toggleMenuOpen] = (0, hooks_1.useBooleanState)(false);
|
|
144
|
+
const buttonRef = (0, react_1.useRef)(null);
|
|
145
|
+
const handleClick = () => {
|
|
146
|
+
setEditing();
|
|
147
|
+
};
|
|
148
|
+
if (editing) {
|
|
149
|
+
return (react_1.default.createElement(CodeEditMode, { initialText: node.attrs[const_1.YfmHtmlBlockConsts.NodeAttrs.srcdoc], onCancel: unsetEditing, onSave: (v) => {
|
|
150
|
+
onChange({ [const_1.YfmHtmlBlockConsts.NodeAttrs.srcdoc]: v });
|
|
151
|
+
unsetEditing();
|
|
152
|
+
} }));
|
|
153
|
+
}
|
|
154
|
+
return (react_1.default.createElement("div", { className: b(), onDoubleClick: setEditing },
|
|
155
|
+
react_1.default.createElement(uikit_1.Label, { className: b('label'), icon: react_1.default.createElement(uikit_1.Icon, { size: 16, data: icons_1.Eye }) }, (0, common_1.i18n)('preview')),
|
|
156
|
+
react_1.default.createElement(YfmHtmlBlockPreview, { html: node.attrs[const_1.YfmHtmlBlockConsts.NodeAttrs.srcdoc], "on\u0421lick": handleClick, config: config }),
|
|
157
|
+
react_1.default.createElement("div", { className: b('menu') },
|
|
158
|
+
react_1.default.createElement(uikit_1.Button, { onClick: toggleMenuOpen, ref: buttonRef, size: 's', className: (0, exports.cnHelper)({ 'prosemirror-stop-event': true }) },
|
|
159
|
+
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Ellipsis, className: (0, exports.cnHelper)({ 'prosemirror-stop-event': true }) })),
|
|
160
|
+
react_1.default.createElement(uikit_1.Popup, { anchorRef: buttonRef, open: menuOpen, onClose: toggleMenuOpen, placement: ['bottom-end'] },
|
|
161
|
+
react_1.default.createElement(uikit_1.Menu, null,
|
|
162
|
+
react_1.default.createElement(uikit_1.Menu.Item, { onClick: () => {
|
|
163
|
+
toggleEditing();
|
|
164
|
+
toggleMenuOpen();
|
|
165
|
+
} }, (0, common_1.i18n)('edit')),
|
|
166
|
+
react_1.default.createElement(uikit_1.Menu.Item, { onClick: () => {
|
|
167
|
+
const pos = getPos();
|
|
168
|
+
if (pos === undefined)
|
|
169
|
+
return;
|
|
170
|
+
(0, remove_node_1.removeNode)({
|
|
171
|
+
node,
|
|
172
|
+
pos,
|
|
173
|
+
tr: view.state.tr,
|
|
174
|
+
dispatch: view.dispatch,
|
|
175
|
+
});
|
|
176
|
+
} }, (0, common_1.i18n)('remove')))))));
|
|
177
|
+
};
|
|
178
|
+
exports.YfmHtmlBlockView = YfmHtmlBlockView;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NodeView';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare enum YfmHtmlBlockAttrs {
|
|
2
|
+
class = "class",
|
|
3
|
+
frameborder = "frameborder",
|
|
4
|
+
newCreated = "newCreated",
|
|
5
|
+
srcdoc = "srcdoc",
|
|
6
|
+
style = "style"
|
|
7
|
+
}
|
|
8
|
+
export declare const yfmHtmlBlockNodeName = "yfm_html_block";
|
|
9
|
+
export declare const yfmHtmlBlockNodeType: (schema: import("prosemirror-model").Schema<any, any>) => import("prosemirror-model").NodeType;
|
|
10
|
+
export declare const YfmHtmlBlockAction = "createYfmHtmlBlock";
|
|
11
|
+
export declare const YfmHtmlBlockConsts: {
|
|
12
|
+
readonly NodeName: "yfm_html_block";
|
|
13
|
+
readonly NodeAttrs: typeof YfmHtmlBlockAttrs;
|
|
14
|
+
readonly nodeType: (schema: import("prosemirror-model").Schema<any, any>) => import("prosemirror-model").NodeType;
|
|
15
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.YfmHtmlBlockConsts = exports.YfmHtmlBlockAction = exports.yfmHtmlBlockNodeType = exports.yfmHtmlBlockNodeName = exports.YfmHtmlBlockAttrs = void 0;
|
|
4
|
+
const schema_1 = require("../../../../utils/schema");
|
|
5
|
+
var YfmHtmlBlockAttrs;
|
|
6
|
+
(function (YfmHtmlBlockAttrs) {
|
|
7
|
+
YfmHtmlBlockAttrs["class"] = "class";
|
|
8
|
+
YfmHtmlBlockAttrs["frameborder"] = "frameborder";
|
|
9
|
+
YfmHtmlBlockAttrs["newCreated"] = "newCreated";
|
|
10
|
+
YfmHtmlBlockAttrs["srcdoc"] = "srcdoc";
|
|
11
|
+
YfmHtmlBlockAttrs["style"] = "style";
|
|
12
|
+
})(YfmHtmlBlockAttrs = exports.YfmHtmlBlockAttrs || (exports.YfmHtmlBlockAttrs = {}));
|
|
13
|
+
exports.yfmHtmlBlockNodeName = 'yfm_html_block';
|
|
14
|
+
exports.yfmHtmlBlockNodeType = (0, schema_1.nodeTypeFactory)(exports.yfmHtmlBlockNodeName);
|
|
15
|
+
exports.YfmHtmlBlockAction = 'createYfmHtmlBlock';
|
|
16
|
+
exports.YfmHtmlBlockConsts = {
|
|
17
|
+
NodeName: exports.yfmHtmlBlockNodeName,
|
|
18
|
+
NodeAttrs: YfmHtmlBlockAttrs,
|
|
19
|
+
nodeType: exports.yfmHtmlBlockNodeType,
|
|
20
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ExtensionNodeSpec } from '../../../../core';
|
|
2
|
+
export { yfmHtmlBlockNodeName } from './const';
|
|
3
|
+
export declare type YfmHtmlBlockSpecsOptions = {
|
|
4
|
+
nodeView?: ExtensionNodeSpec['view'];
|
|
5
|
+
};
|
|
6
|
+
export declare const YfmHtmlBlockSpecs: import("../../../../core").ExtensionWithOptions<YfmHtmlBlockSpecsOptions> & {
|
|
7
|
+
readonly NodeName: "yfm_html_block";
|
|
8
|
+
readonly NodeAttrs: typeof import("./const").YfmHtmlBlockAttrs;
|
|
9
|
+
readonly nodeType: (schema: import("prosemirror-model").Schema<any, any>) => import("prosemirror-model").NodeType;
|
|
10
|
+
};
|