@gravity-ui/markdown-editor 15.8.1 → 15.9.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/extensions/behavior/SelectionContext/index.d.ts +12 -0
- package/build/cjs/extensions/behavior/SelectionContext/index.js +5 -4
- package/build/cjs/extensions/behavior/SelectionContext/index.js.map +1 -1
- package/build/cjs/extensions/behavior/SelectionContext/tooltip.d.ts +11 -5
- package/build/cjs/extensions/behavior/SelectionContext/tooltip.js +30 -32
- package/build/cjs/extensions/behavior/SelectionContext/tooltip.js.map +1 -1
- package/build/cjs/extensions/markdown/Superscript/SuperscriptSpecs/index.js +2 -2
- package/build/cjs/extensions/markdown/Superscript/SuperscriptSpecs/index.js.map +1 -1
- package/build/cjs/extensions/yfm/ImgSize/ImgSizeSpecs/index.js +2 -2
- package/build/cjs/extensions/yfm/ImgSize/ImgSizeSpecs/index.js.map +1 -1
- package/build/cjs/extensions/yfm/Monospace/MonospaceSpecs/index.js +2 -2
- package/build/cjs/extensions/yfm/Monospace/MonospaceSpecs/index.js.map +1 -1
- package/build/cjs/extensions/yfm/Video/VideoSpecs/index.js +2 -3
- package/build/cjs/extensions/yfm/Video/VideoSpecs/index.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/index.js +2 -2
- package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/index.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/YfmTableSpecs/index.js +2 -2
- package/build/cjs/extensions/yfm/YfmTable/YfmTableSpecs/index.js.map +1 -1
- package/build/cjs/version.js +1 -1
- package/build/cjs/version.js.map +1 -1
- package/build/esm/extensions/behavior/SelectionContext/index.d.ts +12 -0
- package/build/esm/extensions/behavior/SelectionContext/index.js +5 -4
- package/build/esm/extensions/behavior/SelectionContext/index.js.map +1 -1
- package/build/esm/extensions/behavior/SelectionContext/tooltip.d.ts +11 -5
- package/build/esm/extensions/behavior/SelectionContext/tooltip.js +30 -32
- package/build/esm/extensions/behavior/SelectionContext/tooltip.js.map +1 -1
- package/build/esm/extensions/markdown/Superscript/SuperscriptSpecs/index.js +1 -1
- package/build/esm/extensions/markdown/Superscript/SuperscriptSpecs/index.js.map +1 -1
- package/build/esm/extensions/yfm/ImgSize/ImgSizeSpecs/index.js +1 -1
- package/build/esm/extensions/yfm/ImgSize/ImgSizeSpecs/index.js.map +1 -1
- package/build/esm/extensions/yfm/Monospace/MonospaceSpecs/index.js +1 -1
- package/build/esm/extensions/yfm/Monospace/MonospaceSpecs/index.js.map +1 -1
- package/build/esm/extensions/yfm/Video/VideoSpecs/index.js +1 -1
- package/build/esm/extensions/yfm/Video/VideoSpecs/index.js.map +1 -1
- package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/index.js +1 -1
- package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/index.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/YfmTableSpecs/index.js +1 -1
- package/build/esm/extensions/yfm/YfmTable/YfmTableSpecs/index.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/package.json +2 -1
|
@@ -3,5 +3,17 @@ import { type ContextConfig } from "./tooltip.js";
|
|
|
3
3
|
export type { ContextConfig as SelectionContextConfig, ContextGroupItemData as SelectionContextItemData, } from "./tooltip.js";
|
|
4
4
|
export type SelectionContextOptions = {
|
|
5
5
|
config?: ContextConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Placement of context popup
|
|
8
|
+
*
|
|
9
|
+
* @default 'bottom'
|
|
10
|
+
*/
|
|
11
|
+
placement?: 'top' | 'bottom';
|
|
12
|
+
/**
|
|
13
|
+
* Prevents context popup from overflowing
|
|
14
|
+
*
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
flip?: boolean;
|
|
6
18
|
};
|
|
7
19
|
export declare const SelectionContext: ExtensionAuto<SelectionContextOptions>;
|
|
@@ -5,9 +5,10 @@ const prosemirror_keymap_1 = require("prosemirror-keymap");
|
|
|
5
5
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
6
6
|
const nodes_1 = require("../../../utils/nodes.js");
|
|
7
7
|
const tooltip_1 = require("./tooltip.js");
|
|
8
|
-
const SelectionContext = (builder,
|
|
8
|
+
const SelectionContext = (builder, opts) => {
|
|
9
|
+
const { config } = opts;
|
|
9
10
|
if (Array.isArray(config) && config.length > 0) {
|
|
10
|
-
builder.addPlugin(({ actions }) => new prosemirror_state_1.Plugin(new SelectionTooltip(actions, config, builder.logger)));
|
|
11
|
+
builder.addPlugin(({ actions }) => new prosemirror_state_1.Plugin(new SelectionTooltip(actions, config, builder.logger, opts)));
|
|
11
12
|
}
|
|
12
13
|
};
|
|
13
14
|
exports.SelectionContext = SelectionContext;
|
|
@@ -16,8 +17,8 @@ class SelectionTooltip {
|
|
|
16
17
|
tooltip;
|
|
17
18
|
hideTimeoutRef = null;
|
|
18
19
|
_isMousePressed = false;
|
|
19
|
-
constructor(actions, menuConfig, logger) {
|
|
20
|
-
this.tooltip = new tooltip_1.TooltipView(actions, menuConfig, logger);
|
|
20
|
+
constructor(actions, menuConfig, logger, options) {
|
|
21
|
+
this.tooltip = new tooltip_1.TooltipView(actions, menuConfig, logger, options);
|
|
21
22
|
}
|
|
22
23
|
get props() {
|
|
23
24
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/SelectionContext/index.ts"],"names":[],"mappings":";;;AAAA,2DAAkD;AAClD,yDAM2B;AAK3B,mDAAiD;AAEjD,0CAA0D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/SelectionContext/index.ts"],"names":[],"mappings":";;;AAAA,2DAAkD;AAClD,yDAM2B;AAK3B,mDAAiD;AAEjD,0CAA0D;AAuBnD,MAAM,gBAAgB,GAA2C,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;IACtF,MAAM,EAAC,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C,cAAc,KAAK,IAAI,EAAE,CAAC;YAC/B,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAClC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC/B,CAAC;IACL,CAAC;CACJ","sourcesContent":["import {keydownHandler} from 'prosemirror-keymap';\nimport {\n AllSelection,\n type EditorState,\n Plugin,\n type PluginSpec,\n TextSelection,\n} from 'prosemirror-state';\nimport type {EditorProps, EditorView} from 'prosemirror-view';\n\nimport type {ActionStorage, ExtensionAuto} from '../../../core';\nimport type {Logger2} from '../../../logger';\nimport {isCodeBlock} from '../../../utils/nodes';\n\nimport {type ContextConfig, TooltipView} from './tooltip';\n\nexport type {\n ContextConfig as SelectionContextConfig,\n ContextGroupItemData as SelectionContextItemData,\n} from './tooltip';\n\nexport type SelectionContextOptions = {\n config?: ContextConfig;\n /**\n * Placement of context popup\n *\n * @default 'bottom'\n */\n placement?: 'top' | 'bottom';\n /**\n * Prevents context popup from overflowing\n *\n * @default false\n */\n flip?: boolean;\n};\n\nexport const SelectionContext: ExtensionAuto<SelectionContextOptions> = (builder, opts) => {\n const {config} = opts;\n if (Array.isArray(config) && config.length > 0) {\n builder.addPlugin(\n ({actions}) => new Plugin(new SelectionTooltip(actions, config, builder.logger, opts)),\n );\n }\n};\n\ntype TinyState = Pick<EditorState, 'doc' | 'selection'>;\n\nclass SelectionTooltip implements PluginSpec<unknown> {\n private destroyed = false;\n\n private tooltip: TooltipView;\n private hideTimeoutRef: ReturnType<typeof setTimeout> | null = null;\n\n private _isMousePressed = false;\n\n constructor(\n actions: ActionStorage,\n menuConfig: ContextConfig,\n logger: Logger2.ILogger,\n options: SelectionContextOptions,\n ) {\n this.tooltip = new TooltipView(actions, menuConfig, logger, options);\n }\n\n get props(): EditorProps {\n return {\n // same as keymap({})\n handleKeyDown: keydownHandler({\n // hide context menu when Esc was pressed\n Escape: (_state, _dispatch, view) => {\n if (this.tooltip.isTooltipOpen) {\n this.tooltip.hide(view!);\n return true;\n }\n return false;\n },\n }),\n handleDOMEvents: {\n mousedown: (view) => {\n const startState: TinyState = {\n doc: view.state.doc,\n selection: view.state.selection,\n };\n this._isMousePressed = true;\n this.cancelTooltipHiding();\n this.tooltip.hide(view);\n\n const onMouseUp = () => {\n if (this.destroyed) return;\n this._isMousePressed = false;\n this.update(view, startState);\n };\n\n document.addEventListener('mouseup', onMouseUp, {once: true});\n },\n },\n };\n }\n\n view(view: EditorView) {\n this.update(view);\n return {\n update: this.update.bind(this),\n destroy: () => {\n this.destroyed = true;\n this.cancelTooltipHiding();\n this.tooltip.destroy();\n },\n };\n }\n\n private update(view: EditorView, prevState?: TinyState) {\n if (this._isMousePressed) return;\n\n this.cancelTooltipHiding();\n\n // Don't show tooltip if editor not mounted to the DOM\n // or when view is out of focus\n if (!view.dom.parentNode || !view.hasFocus()) {\n this.tooltip.hide(view);\n return;\n }\n\n const {state} = view;\n // Don't do anything if the document/selection didn't change\n if (prevState && prevState.doc.eq(state.doc) && prevState.selection.eq(state.selection))\n return;\n\n const {selection} = state;\n // Hide the tooltip if the selection is empty\n if (\n selection.empty ||\n !(selection instanceof TextSelection || selection instanceof AllSelection)\n ) {\n this.tooltip.hide(view);\n return;\n }\n\n // Hide the tooltip when one side of selection inside codeblock\n if (isCodeBlock(selection.$from.parent) || isCodeBlock(selection.$to.parent)) {\n this.tooltip.hide(view);\n return;\n }\n\n this.tooltip.show(view, {\n onOpenChange: (_open, _event, reason) => {\n if (reason !== 'escape-key') this.scheduleTooltipHiding(view);\n },\n });\n }\n\n private scheduleTooltipHiding(view: EditorView) {\n this.hideTimeoutRef = setTimeout(() => {\n // hide tooltip if view is out of focus after 30 ms\n if (!view.hasFocus()) {\n this.tooltip.hide(view);\n }\n }, 30);\n }\n\n private cancelTooltipHiding() {\n if (this.hideTimeoutRef !== null) {\n clearTimeout(this.hideTimeoutRef);\n this.hideTimeoutRef = null;\n }\n }\n}\n"]}
|
|
@@ -11,15 +11,22 @@ export type ContextGroupItemData = (ToolbarGroupItemData<ActionStorage> & {
|
|
|
11
11
|
});
|
|
12
12
|
export type ContextGroupData = ContextGroupItemData[];
|
|
13
13
|
export type ContextConfig = ContextGroupData[];
|
|
14
|
+
export type TooltipViewParams = {
|
|
15
|
+
/** @default 'bottom' */
|
|
16
|
+
placement?: 'top' | 'bottom';
|
|
17
|
+
/** @default false */
|
|
18
|
+
flip?: boolean;
|
|
19
|
+
};
|
|
14
20
|
export declare class TooltipView {
|
|
15
21
|
#private;
|
|
16
|
-
private logger;
|
|
17
|
-
private actions;
|
|
18
|
-
private menuConfig;
|
|
22
|
+
private readonly logger;
|
|
23
|
+
private readonly actions;
|
|
24
|
+
private readonly menuConfig;
|
|
25
|
+
private readonly placement;
|
|
19
26
|
private view;
|
|
20
27
|
private baseProps;
|
|
21
28
|
private _tooltipRenderItem;
|
|
22
|
-
constructor(actions: ActionStorage, menuConfig: ContextConfig, logger: Logger2.ILogger);
|
|
29
|
+
constructor(actions: ActionStorage, menuConfig: ContextConfig, logger: Logger2.ILogger, params: TooltipViewParams);
|
|
23
30
|
get isTooltipOpen(): boolean;
|
|
24
31
|
show(view: EditorView, popupProps?: PopupProps): void;
|
|
25
32
|
hide(view: EditorView): void;
|
|
@@ -29,5 +36,4 @@ export declare class TooltipView {
|
|
|
29
36
|
private renderPopup;
|
|
30
37
|
private get tooltipRenderItem();
|
|
31
38
|
private calcPosition;
|
|
32
|
-
private get popupTextOffset();
|
|
33
39
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TooltipView = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("@floating-ui/react"); // eslint-disable-line import/no-extraneous-dependencies
|
|
6
5
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
7
6
|
const lodash_1 = require("../../../lodash.js");
|
|
8
7
|
const logger_1 = require("../../../logger.js");
|
|
@@ -19,13 +18,16 @@ class TooltipView {
|
|
|
19
18
|
logger;
|
|
20
19
|
actions;
|
|
21
20
|
menuConfig;
|
|
21
|
+
placement;
|
|
22
22
|
view;
|
|
23
23
|
baseProps = { show: false, poppupProps: {} };
|
|
24
24
|
_tooltipRenderItem = null;
|
|
25
|
-
constructor(actions, menuConfig, logger) {
|
|
25
|
+
constructor(actions, menuConfig, logger, params) {
|
|
26
26
|
this.logger = logger;
|
|
27
27
|
this.actions = actions;
|
|
28
28
|
this.menuConfig = menuConfig;
|
|
29
|
+
const { flip, placement = 'bottom' } = params;
|
|
30
|
+
this.placement = flip ? placement : [placement];
|
|
29
31
|
}
|
|
30
32
|
get isTooltipOpen() {
|
|
31
33
|
return this.#isTooltipOpen;
|
|
@@ -91,39 +93,35 @@ class TooltipView {
|
|
|
91
93
|
return this._tooltipRenderItem;
|
|
92
94
|
}
|
|
93
95
|
calcPosition(view) {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
const virtualElem = {
|
|
97
|
+
getBoundingClientRect() {
|
|
98
|
+
// These are in screen coordinates
|
|
99
|
+
const start = view.coordsAtPos(view.state.selection.from);
|
|
100
|
+
const end = view.coordsAtPos(view.state.selection.to);
|
|
101
|
+
// Find a center-ish x position from the selection endpoints (when
|
|
102
|
+
// crossing lines, end may be more to the left)
|
|
103
|
+
const yCenter = Math.max((start.left + end.left) / 2, start.left + 3);
|
|
104
|
+
const top = start.top;
|
|
105
|
+
const left = yCenter - 1;
|
|
106
|
+
const width = 2;
|
|
107
|
+
const height = end.bottom - start.top;
|
|
108
|
+
return {
|
|
109
|
+
top,
|
|
110
|
+
left,
|
|
111
|
+
right: left + width,
|
|
112
|
+
bottom: top + height,
|
|
113
|
+
y: top,
|
|
114
|
+
x: left,
|
|
115
|
+
height,
|
|
116
|
+
width,
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
};
|
|
107
120
|
return {
|
|
108
|
-
placement:
|
|
109
|
-
anchorElement:
|
|
110
|
-
// override floating middlewares
|
|
111
|
-
floatingMiddlewares: [
|
|
112
|
-
(0, react_1.offset)({
|
|
113
|
-
mainAxis: bottomOffset,
|
|
114
|
-
crossAxis: leftOffset,
|
|
115
|
-
}),
|
|
116
|
-
(0, react_1.shift)({
|
|
117
|
-
mainAxis: true,
|
|
118
|
-
crossAxis: false,
|
|
119
|
-
padding: 4,
|
|
120
|
-
}),
|
|
121
|
-
],
|
|
121
|
+
placement: this.placement,
|
|
122
|
+
anchorElement: virtualElem,
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
|
-
get popupTextOffset() {
|
|
125
|
-
return 4; // 4px offset from text selection
|
|
126
|
-
}
|
|
127
125
|
}
|
|
128
126
|
exports.TooltipView = TooltipView;
|
|
129
127
|
//# sourceMappingURL=tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/SelectionContext/tooltip.tsx"],"names":[],"mappings":";;;;AAAA,8CAAiD,CAAC,wDAAwD;AAC1G,6CAAyD;AAKzD,+CAA2C;AAC3C,+CAA2D;AAC3D,yEAAuE;AACvE,uDAAyC;AAOzC,6DAA8E;AAQ9E,MAAM,gBAAgB,GAAoC,CAAC,EACvD,IAAI,EACJ,WAAW,EACX,GAAG,YAAY,EAClB,EAAE,EAAE;IACD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,CACH,uBAAC,aAAK,IAAC,IAAI,WAAK,WAAW,EAAE,KAAK,EAAE,EAAC,OAAO,EAAE,SAAS,EAAC,YACpD,uBAAC,iBAAO,OAAK,YAAY,GAAI,GACzB,CACX,CAAC;AACN,CAAC,CAAC;AAaF,MAAa,WAAW;IACpB,cAAc,GAAG,KAAK,CAAC;IAEf,MAAM,CAAkB;IACx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H,SAAS,EAAE,QAAQ;YACnB,aAAa,EAAE,OAAO;YACtB,gCAAgC;YAChC,mBAAmB,EAAE;gBACjB,IAAA,cAAM,EAAC;oBACH,QAAQ,EAAE,YAAY;oBACtB,SAAS,EAAE,UAAU;iBACxB,CAAC;gBACF,IAAA,aAAK,EAAC;oBACF,QAAQ,EAAE,IAAI;oBACd,SAAS,EAAE,KAAK;oBAChB,OAAO,EAAE,CAAC;iBACb,CAAC;aACL;SACJ,CAAC;IACN,CAAC;IAED,IAAY,eAAe;QACvB,OAAO,CAAC,CAAC,CAAC,iCAAiC;IAC/C,CAAC;CACJ;AAtID,kCAsIC","sourcesContent":["import {offset, shift} from '@floating-ui/react'; // eslint-disable-line import/no-extraneous-dependencies\nimport {Popup, type PopupProps} from '@gravity-ui/uikit';\nimport type {EditorState} from 'prosemirror-state';\nimport type {EditorView} from 'prosemirror-view';\n\nimport type {ActionStorage} from '../../../core';\nimport {isFunction} from '../../../lodash';\nimport {type Logger2, globalLogger} from '../../../logger';\nimport {ErrorLoggerBoundary} from '../../../react-utils/ErrorBoundary';\nimport {Toolbar} from '../../../toolbar';\nimport type {\n ToolbarButtonPopupData,\n ToolbarGroupItemData,\n ToolbarProps,\n ToolbarSingleItemData,\n} from '../../../toolbar';\nimport {type RendererItem, getReactRendererFromState} from '../ReactRenderer';\n\ntype SelectionTooltipBaseProps = {\n show?: boolean;\n poppupProps: PopupProps;\n};\ntype SelectionTooltipProps = SelectionTooltipBaseProps & ToolbarProps<ActionStorage>;\n\nconst SelectionTooltip: React.FC<SelectionTooltipProps> = ({\n show,\n poppupProps,\n ...toolbarProps\n}) => {\n if (!show) return null;\n return (\n <Popup open {...poppupProps} style={{padding: '4px 8px'}}>\n <Toolbar {...toolbarProps} />\n </Popup>\n );\n};\n\nexport type ContextGroupItemData =\n | (ToolbarGroupItemData<ActionStorage> & {\n condition?: (state: EditorState) => void;\n })\n | ((ToolbarSingleItemData<ActionStorage> | ToolbarButtonPopupData<ActionStorage>) & {\n condition?: 'enabled';\n });\n\nexport type ContextGroupData = ContextGroupItemData[];\nexport type ContextConfig = ContextGroupData[];\n\nexport class TooltipView {\n #isTooltipOpen = false;\n\n private logger: Logger2.ILogger;\n private actions: ActionStorage;\n private menuConfig: ContextConfig;\n\n private view!: EditorView;\n private baseProps: SelectionTooltipBaseProps = {show: false, poppupProps: {}};\n private _tooltipRenderItem: RendererItem | null = null;\n\n constructor(actions: ActionStorage, menuConfig: ContextConfig, logger: Logger2.ILogger) {\n this.logger = logger;\n this.actions = actions;\n this.menuConfig = menuConfig;\n }\n\n get isTooltipOpen(): boolean {\n return this.#isTooltipOpen;\n }\n\n show(view: EditorView, popupProps?: PopupProps) {\n this.view = view;\n this.#isTooltipOpen = true;\n this.baseProps = {\n show: true,\n poppupProps: {\n ...popupProps,\n ...this.calcPosition(view),\n },\n };\n this.renderPopup();\n }\n\n hide(view: EditorView) {\n this.view = view;\n this.#isTooltipOpen = false;\n this.baseProps = {show: false, poppupProps: {}};\n this.renderPopup();\n }\n\n destroy() {\n this._tooltipRenderItem?.remove();\n this._tooltipRenderItem = null;\n }\n\n private getSelectionTooltipProps(): SelectionTooltipProps {\n return {\n ...this.baseProps,\n focus: () => this.view.focus(),\n data: this.getFilteredConfig(),\n editor: this.actions,\n onClick: (id) => {\n globalLogger.action({mode: 'wysiwyg', source: 'context-menu', action: id});\n this.logger.action({source: 'context-menu', action: id});\n },\n };\n }\n\n private getFilteredConfig(): ContextConfig {\n return this.baseProps.show\n ? this.menuConfig\n .map((groupData) =>\n groupData.filter((item) => {\n const {condition} = item;\n if (condition === 'enabled') {\n return item.isEnable(this.actions);\n }\n if (isFunction(condition)) {\n return condition(this.view.state);\n }\n return true;\n }),\n )\n .filter((groupData) => Boolean(groupData.length))\n : [];\n }\n\n private renderPopup() {\n this.tooltipRenderItem.rerender();\n }\n\n private get tooltipRenderItem() {\n if (!this._tooltipRenderItem) {\n const reactRenderer = getReactRendererFromState(this.view.state);\n this._tooltipRenderItem = reactRenderer.createItem('selection_context', () => (\n <ErrorLoggerBoundary>\n <SelectionTooltip {...this.getSelectionTooltipProps()} />\n </ErrorLoggerBoundary>\n ));\n }\n return this._tooltipRenderItem;\n }\n\n private calcPosition(view: EditorView): PopupProps {\n const viewDom = view.dom as Element;\n // The box in which the tooltip is positioned, to use as base\n const viewBox = viewDom.getBoundingClientRect();\n\n const viewWidth = viewBox.right - viewBox.left;\n const viewHalfWidth = viewWidth / 2;\n\n // These are in screen coordinates\n const start = view.coordsAtPos(view.state.selection.from);\n const end = view.coordsAtPos(view.state.selection.to);\n\n // Find a center-ish x position from the selection endpoints (when\n // crossing lines, end may be more to the left)\n const left = Math.max((start.left + end.left) / 2, start.left + 3);\n\n const leftOffset = left - (viewBox.left + viewHalfWidth);\n const bottomOffset = -(viewBox.bottom - end.bottom) + this.popupTextOffset;\n\n return {\n placement: 'bottom',\n anchorElement: viewDom,\n // override floating middlewares\n floatingMiddlewares: [\n offset({\n mainAxis: bottomOffset,\n crossAxis: leftOffset,\n }),\n shift({\n mainAxis: true,\n crossAxis: false,\n padding: 4,\n }),\n ],\n };\n }\n\n private get popupTextOffset() {\n return 4; // 4px offset from text selection\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tooltip.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/SelectionContext/tooltip.tsx"],"names":[],"mappings":";;;;AACA,6CAA8E;AAK9E,+CAA2C;AAC3C,+CAA2D;AAC3D,yEAAuE;AACvE,uDAAyC;AAOzC,6DAA8E;AAQ9E,MAAM,gBAAgB,GAAoC,CAAC,EACvD,IAAI,EACJ,WAAW,EACX,GAAG,YAAY,EAClB,EAAE,EAAE;IACD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,CACH,uBAAC,aAAK,IAAC,IAAI,WAAK,WAAW,EAAE,KAAK,EAAE,EAAC,OAAO,EAAE,SAAS,EAAC,YACpD,uBAAC,iBAAO,OAAK,YAAY,GAAI,GACzB,CACX,CAAC;AACN,C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GAAG,CAAC,CAAC;gBAChB,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC;gBAEtC,OAAO;oBACH,GAAG;oBACH,IAAI;oBACJ,KAAK,EAAE,IAAI,GAAG,KAAK;oBACnB,MAAM,EAAE,GAAG,GAAG,MAAM;oBACpB,CAAC,EAAE,GAAG;oBACN,CAAC,EAAE,IAAI;oBACP,MAAM;oBACN,KAAK;iBACR,CAAC;YACN,CAAC;SACJ,CAAC;QAEF,OAAO;YACH,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,aAAa,EAAE,WAAW;SAC7B,CAAC;IACN,CAAC;CACJ;AAxID,kCAwIC","sourcesContent":["import type {VirtualElement} from '@floating-ui/react'; // eslint-disable-line import/no-extraneous-dependencies\nimport {Popup, type PopupPlacement, type PopupProps} from '@gravity-ui/uikit';\nimport type {EditorState} from 'prosemirror-state';\nimport type {EditorView} from 'prosemirror-view';\n\nimport type {ActionStorage} from '../../../core';\nimport {isFunction} from '../../../lodash';\nimport {type Logger2, globalLogger} from '../../../logger';\nimport {ErrorLoggerBoundary} from '../../../react-utils/ErrorBoundary';\nimport {Toolbar} from '../../../toolbar';\nimport type {\n ToolbarButtonPopupData,\n ToolbarGroupItemData,\n ToolbarProps,\n ToolbarSingleItemData,\n} from '../../../toolbar';\nimport {type RendererItem, getReactRendererFromState} from '../ReactRenderer';\n\ntype SelectionTooltipBaseProps = {\n show?: boolean;\n poppupProps: PopupProps;\n};\ntype SelectionTooltipProps = SelectionTooltipBaseProps & ToolbarProps<ActionStorage>;\n\nconst SelectionTooltip: React.FC<SelectionTooltipProps> = ({\n show,\n poppupProps,\n ...toolbarProps\n}) => {\n if (!show) return null;\n return (\n <Popup open {...poppupProps} style={{padding: '4px 8px'}}>\n <Toolbar {...toolbarProps} />\n </Popup>\n );\n};\n\nexport type ContextGroupItemData =\n | (ToolbarGroupItemData<ActionStorage> & {\n condition?: (state: EditorState) => void;\n })\n | ((ToolbarSingleItemData<ActionStorage> | ToolbarButtonPopupData<ActionStorage>) & {\n condition?: 'enabled';\n });\n\nexport type ContextGroupData = ContextGroupItemData[];\nexport type ContextConfig = ContextGroupData[];\n\nexport type TooltipViewParams = {\n /** @default 'bottom' */\n placement?: 'top' | 'bottom';\n /** @default false */\n flip?: boolean;\n};\n\nexport class TooltipView {\n #isTooltipOpen = false;\n\n private readonly logger: Logger2.ILogger;\n private readonly actions: ActionStorage;\n private readonly menuConfig: ContextConfig;\n private readonly placement: PopupPlacement;\n\n private view!: EditorView;\n private baseProps: SelectionTooltipBaseProps = {show: false, poppupProps: {}};\n private _tooltipRenderItem: RendererItem | null = null;\n\n constructor(\n actions: ActionStorage,\n menuConfig: ContextConfig,\n logger: Logger2.ILogger,\n params: TooltipViewParams,\n ) {\n this.logger = logger;\n this.actions = actions;\n this.menuConfig = menuConfig;\n\n const {flip, placement = 'bottom'} = params;\n this.placement = flip ? placement : [placement];\n }\n\n get isTooltipOpen(): boolean {\n return this.#isTooltipOpen;\n }\n\n show(view: EditorView, popupProps?: PopupProps) {\n this.view = view;\n this.#isTooltipOpen = true;\n this.baseProps = {\n show: true,\n poppupProps: {\n ...popupProps,\n ...this.calcPosition(view),\n },\n };\n this.renderPopup();\n }\n\n hide(view: EditorView) {\n this.view = view;\n this.#isTooltipOpen = false;\n this.baseProps = {show: false, poppupProps: {}};\n this.renderPopup();\n }\n\n destroy() {\n this._tooltipRenderItem?.remove();\n this._tooltipRenderItem = null;\n }\n\n private getSelectionTooltipProps(): SelectionTooltipProps {\n return {\n ...this.baseProps,\n focus: () => this.view.focus(),\n data: this.getFilteredConfig(),\n editor: this.actions,\n onClick: (id) => {\n globalLogger.action({mode: 'wysiwyg', source: 'context-menu', action: id});\n this.logger.action({source: 'context-menu', action: id});\n },\n };\n }\n\n private getFilteredConfig(): ContextConfig {\n return this.baseProps.show\n ? this.menuConfig\n .map((groupData) =>\n groupData.filter((item) => {\n const {condition} = item;\n if (condition === 'enabled') {\n return item.isEnable(this.actions);\n }\n if (isFunction(condition)) {\n return condition(this.view.state);\n }\n return true;\n }),\n )\n .filter((groupData) => Boolean(groupData.length))\n : [];\n }\n\n private renderPopup() {\n this.tooltipRenderItem.rerender();\n }\n\n private get tooltipRenderItem() {\n if (!this._tooltipRenderItem) {\n const reactRenderer = getReactRendererFromState(this.view.state);\n this._tooltipRenderItem = reactRenderer.createItem('selection_context', () => (\n <ErrorLoggerBoundary>\n <SelectionTooltip {...this.getSelectionTooltipProps()} />\n </ErrorLoggerBoundary>\n ));\n }\n return this._tooltipRenderItem;\n }\n\n private calcPosition(view: EditorView): PopupProps {\n const virtualElem: VirtualElement = {\n getBoundingClientRect() {\n // These are in screen coordinates\n const start = view.coordsAtPos(view.state.selection.from);\n const end = view.coordsAtPos(view.state.selection.to);\n // Find a center-ish x position from the selection endpoints (when\n // crossing lines, end may be more to the left)\n const yCenter = Math.max((start.left + end.left) / 2, start.left + 3);\n\n const top = start.top;\n const left = yCenter - 1;\n const width = 2;\n const height = end.bottom - start.top;\n\n return {\n top,\n left,\n right: left + width,\n bottom: top + height,\n y: top,\n x: left,\n height,\n width,\n };\n },\n };\n\n return {\n placement: this.placement,\n anchorElement: virtualElem,\n };\n }\n}\n"]}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SuperscriptSpecs = exports.superscriptType = exports.superscriptMarkName = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const log_js_1 =
|
|
5
|
+
const log_js_1 = require("@diplodoc/transform/lib/log.js");
|
|
6
6
|
const sup_js_1 = tslib_1.__importDefault(require("@diplodoc/transform/lib/plugins/sup.js"));
|
|
7
7
|
const schema_1 = require("../../../../utils/schema.js");
|
|
8
8
|
exports.superscriptMarkName = 'sup';
|
|
9
9
|
exports.superscriptType = (0, schema_1.markTypeFactory)(exports.superscriptMarkName);
|
|
10
10
|
const SuperscriptSpecs = (builder) => {
|
|
11
11
|
builder
|
|
12
|
-
.configureMd((md) => md.use(sup_js_1.default, { log: log_js_1.
|
|
12
|
+
.configureMd((md) => md.use(sup_js_1.default, { log: log_js_1.log }))
|
|
13
13
|
.addMark(exports.superscriptMarkName, () => ({
|
|
14
14
|
spec: {
|
|
15
15
|
excludes: '_',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/markdown/Superscript/SuperscriptSpecs/index.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/markdown/Superscript/SuperscriptSpecs/index.ts"],"names":[],"mappings":";;;;AAAA,2DAAmD;AACnD,4FAAyD;AAGzD,wDAAyD;AAE5C,QAAA,mBAAmB,GAAG,KAAK,CAAC;AAC5B,QAAA,eAAe,GAAG,IAAA,wBAAe,EAAC,2BAAmB,CAAC,CAAC;AAE7D,MAAM,gBAAgB,GAAkB,CAAC,OAAO,EAAE,EAAE;IACvD,OAAO;SACF,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,gBAAG,EAAE,EAAC,GAAG,EAAH,YAAG,EAAC,CAAC,CAAC;SACvC,OAAO,CAAC,2BAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;QACjC,IAAI,EAAE;YACF,QAAQ,EAAE,GAAG;YACb,QAAQ,EAAE,CAAC,EAAC,GAAG,EAAE,KAAK,EAAC,CAAC;YACxB,KAAK;gBACD,OAAO,CAAC,KAAK,CAAC,CAAC;YACnB,CAAC;SACJ;QACD,IAAI,EAAE;YACF,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;gBACZ,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAC9B,OAAO,GAAG,CAAC;YACf,CAAC;YACD,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACb,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC;gBAC/B,OAAO,GAAG,CAAC;YACf,CAAC;YACD,OAAO,EAAE,IAAI;YACb,wBAAwB,EAAE,IAAI;SACjC;QACD,MAAM,EAAE,EAAC,SAAS,EAAE,EAAC,IAAI,EAAE,2BAAmB,EAAE,IAAI,EAAE,MAAM,EAAC,EAAC;KACjE,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC;AAzBW,QAAA,gBAAgB,oBAyB3B","sourcesContent":["import {log} from '@diplodoc/transform/lib/log.js';\nimport sup from '@diplodoc/transform/lib/plugins/sup.js';\n\nimport type {ExtensionAuto} from '../../../../core';\nimport {markTypeFactory} from '../../../../utils/schema';\n\nexport const superscriptMarkName = 'sup';\nexport const superscriptType = markTypeFactory(superscriptMarkName);\n\nexport const SuperscriptSpecs: ExtensionAuto = (builder) => {\n builder\n .configureMd((md) => md.use(sup, {log}))\n .addMark(superscriptMarkName, () => ({\n spec: {\n excludes: '_',\n parseDOM: [{tag: 'sup'}],\n toDOM() {\n return ['sup'];\n },\n },\n toMd: {\n open: (state) => {\n state.escapeWhitespace = true;\n return '^';\n },\n close: (state) => {\n state.escapeWhitespace = false;\n return '^';\n },\n mixable: true,\n expelEnclosingWhitespace: true,\n },\n fromMd: {tokenSpec: {name: superscriptMarkName, type: 'mark'}},\n }));\n};\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ImgSizeSpecs = exports.ImgSizeAttr = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const log_js_1 =
|
|
5
|
+
const log_js_1 = require("@diplodoc/transform/lib/log.js");
|
|
6
6
|
const index_js_1 = tslib_1.__importDefault(require("@diplodoc/transform/lib/plugins/imsize/index.js"));
|
|
7
7
|
const is_number_1 = tslib_1.__importDefault(require("is-number"));
|
|
8
8
|
const const_1 = require("../../../markdown/Image/const.js");
|
|
@@ -10,7 +10,7 @@ const const_2 = require("./const.js");
|
|
|
10
10
|
Object.defineProperty(exports, "ImgSizeAttr", { enumerable: true, get: function () { return const_2.ImgSizeAttr; } });
|
|
11
11
|
const ImgSizeSpecs = (builder, opts) => {
|
|
12
12
|
const placeholderContent = builder.context.get('placeholder')?.imgSize;
|
|
13
|
-
builder.configureMd((md) => md.use(index_js_1.default, { log: log_js_1.
|
|
13
|
+
builder.configureMd((md) => md.use(index_js_1.default, { log: log_js_1.log, enableInlineStyling: true }));
|
|
14
14
|
builder.addNode(const_1.imageNodeName, () => ({
|
|
15
15
|
spec: {
|
|
16
16
|
inline: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/ImgSize/ImgSizeSpecs/index.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/ImgSize/ImgSizeSpecs/index.ts"],"names":[],"mappings":";;;;AAAA,2DAAmD;AACnD,uGAAqE;AACrE,kEAAiC;AAIjC,4DAA4D;AAE5D,sCAAoC;AAW5B,4FAXA,mBAAW,OAWA;AASZ,MAAM,YAAY,GAAuC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;IAC9E,MAAM,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IAEvE,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,kBAAM,EAAE,EAAC,GAAG,EAAH,YAAG,EAAE,mBAAmB,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;IAC9E,OAAO,CAAC,OAAO,CAAC,qBAAa,EAAE,GAAG,EAAE,CAAC,CAAC;QAClC,IAAI,EAAE;YACF,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE;gBACH,CAAC,mBAAW,CAAC,GAAG,CAAC,EAAE,EAAE;gBACrB,CAAC,mBAAW,CAAC,GAAG,CAAC,EAAE,EAAC,O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,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnC,CAAC;YAED,MAAM,IAAI,IAAI,CAAC;YAEf,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnC,CAAC;YAED,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBACd,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7C,CAAC;YAED,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;YACzB,MAAM,IAAI,GAAG,CAAC;YAEd,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;KACJ,CAAC,CAAC,CAAC;AACR,CAAC,CAAC;AAhFW,QAAA,YAAY,gBAgFvB;AAEF,SAAS,OAAO,CAAC,EAAC,KAAK,EAAE,MAAM,EAAwB;IACnD,IAAI,KAAK,IAAI,MAAM,EAAE,CAAC;QAClB,OAAO,KAAK,KAAK,IAAI,EAAE,IAAI,MAAM,IAAI,EAAE,EAAE,CAAC;IAC9C,CAAC;IAED,OAAO,EAAE,CAAC;AACd,CAAC","sourcesContent":["import {log} from '@diplodoc/transform/lib/log.js';\nimport imsize from '@diplodoc/transform/lib/plugins/imsize/index.js';\nimport isNumber from 'is-number';\nimport type {NodeSpec} from 'prosemirror-model';\n\nimport type {ExtensionAuto} from '../../../../core';\nimport {imageNodeName} from '../../../markdown/Image/const';\n\nimport {ImgSizeAttr} from './const';\n\ntype ImsizeTypedAttributes = {\n [ImgSizeAttr.Src]: string;\n [ImgSizeAttr.Title]: string | null;\n [ImgSizeAttr.Alt]: string | null;\n [ImgSizeAttr.Width]: string | null;\n [ImgSizeAttr.Height]: string | null;\n [ImgSizeAttr.Loading]: string | null;\n};\n\nexport {ImgSizeAttr};\n\nexport type ImgSizeSpecsOptions = {\n /**\n * @deprecated: use placeholder option in BehaviorPreset instead.\n */\n placeholder?: NodeSpec['placeholder'];\n};\n\nexport const ImgSizeSpecs: ExtensionAuto<ImgSizeSpecsOptions> = (builder, opts) => {\n const placeholderContent = builder.context.get('placeholder')?.imgSize;\n\n builder.configureMd((md) => md.use(imsize, {log, enableInlineStyling: true}));\n builder.addNode(imageNodeName, () => ({\n spec: {\n inline: true,\n attrs: {\n [ImgSizeAttr.Src]: {},\n [ImgSizeAttr.Alt]: {default: null},\n [ImgSizeAttr.Title]: {default: null},\n [ImgSizeAttr.Height]: {default: null},\n [ImgSizeAttr.Width]: {default: null},\n [ImgSizeAttr.Loading]: {default: null},\n },\n placeholder: placeholderContent ? {content: placeholderContent} : opts.placeholder,\n group: 'inline',\n draggable: true,\n parseDOM: [\n {\n tag: 'img[src]',\n getAttrs(dom) {\n const height = (dom as Element).getAttribute(ImgSizeAttr.Height);\n const width = (dom as Element).getAttribute(ImgSizeAttr.Width);\n\n return {\n [ImgSizeAttr.Src]: (dom as Element).getAttribute(ImgSizeAttr.Src),\n [ImgSizeAttr.Alt]: (dom as Element).getAttribute(ImgSizeAttr.Alt),\n [ImgSizeAttr.Title]: (dom as Element).getAttribute(ImgSizeAttr.Title),\n [ImgSizeAttr.Loading]: (dom as Element).getAttribute(\n ImgSizeAttr.Loading,\n ),\n [ImgSizeAttr.Height]: isNumber(height) ? height : null,\n [ImgSizeAttr.Width]: isNumber(width) ? height : null,\n };\n },\n },\n ],\n toDOM(node) {\n return ['img', node.attrs];\n },\n },\n fromMd: {\n tokenSpec: {\n name: imageNodeName,\n type: 'node',\n getAttrs: (tok): ImsizeTypedAttributes => ({\n [ImgSizeAttr.Src]: tok.attrGet(ImgSizeAttr.Src)!,\n [ImgSizeAttr.Title]: tok.attrGet(ImgSizeAttr.Title),\n [ImgSizeAttr.Height]: tok.attrGet(ImgSizeAttr.Height),\n [ImgSizeAttr.Width]: tok.attrGet(ImgSizeAttr.Width),\n [ImgSizeAttr.Loading]: tok.attrGet(ImgSizeAttr.Loading),\n [ImgSizeAttr.Alt]: tok.children?.[0]?.content || null,\n }),\n },\n },\n toMd: (state, node) => {\n const attrs = node.attrs as ImsizeTypedAttributes;\n let result = ' {\n result += state.esc(attrs.src);\n }\n\n if (attrs.title) {\n result += ` ${state.quote(attrs.title)}`;\n }\n\n result += getSize(attrs);\n result += ')';\n\n state.write(result);\n },\n }));\n};\n\nfunction getSize({width, height}: ImsizeTypedAttributes): string {\n if (width || height) {\n return ` =${width || ''}x${height || ''}`;\n }\n\n return '';\n}\n"]}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MonospaceSpecs = exports.monospaceType = exports.monospaceMarkName = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const log_js_1 =
|
|
5
|
+
const log_js_1 = require("@diplodoc/transform/lib/log.js");
|
|
6
6
|
const monospace_js_1 = tslib_1.__importDefault(require("@diplodoc/transform/lib/plugins/monospace.js"));
|
|
7
7
|
const schema_1 = require("../../../../utils/schema.js");
|
|
8
8
|
exports.monospaceMarkName = 'monospace';
|
|
9
9
|
exports.monospaceType = (0, schema_1.markTypeFactory)(exports.monospaceMarkName);
|
|
10
10
|
const MonospaceSpecs = (builder) => {
|
|
11
11
|
builder
|
|
12
|
-
.configureMd((md) => md.use(monospace_js_1.default, { log: log_js_1.
|
|
12
|
+
.configureMd((md) => md.use(monospace_js_1.default, { log: log_js_1.log }))
|
|
13
13
|
.addMark(exports.monospaceMarkName, () => ({
|
|
14
14
|
spec: {
|
|
15
15
|
parseDOM: [{ tag: 'samp' }],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/Monospace/MonospaceSpecs/index.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/Monospace/MonospaceSpecs/index.ts"],"names":[],"mappings":";;;;AAAA,2DAAmD;AACnD,wGAAqE;AAGrE,wDAAyD;AAE5C,QAAA,iBAAiB,GAAG,WAAW,CAAC;AAChC,QAAA,aAAa,GAAG,IAAA,wBAAe,EAAC,yBAAiB,CAAC,CAAC;AAEzD,MAAM,cAAc,GAAkB,CAAC,OAAO,EAAE,EAAE;IACrD,OAAO;SACF,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,sBAAS,EAAE,EAAC,GAAG,EAAH,YAAG,EAAC,CAAC,CAAC;SAC7C,OAAO,CAAC,yBAAiB,EAAE,GAAG,EAAE,CAAC,CAAC;QAC/B,IAAI,EAAE;YACF,QAAQ,EAAE,CAAC,EAAC,GAAG,EAAE,MAAM,EAAC,CAAC;YACzB,KAAK;gBACD,OAAO,CAAC,MAAM,CAAC,CAAC;YACpB,CAAC;SACJ;QACD,MAAM,EAAE;YACJ,SAAS,EAAE;gBACP,IAAI,EAAE,yBAAiB;gBACvB,IAAI,EAAE,MAAM;aACf;SACJ;QACD,IAAI,EAAE;YACF,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,IAAI;YACb,wBAAwB,EAAE,IAAI;SACjC;KACJ,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC;AAvBW,QAAA,cAAc,kBAuBzB","sourcesContent":["import {log} from '@diplodoc/transform/lib/log.js';\nimport yfmPlugin from '@diplodoc/transform/lib/plugins/monospace.js';\n\nimport type {ExtensionAuto} from '../../../../core';\nimport {markTypeFactory} from '../../../../utils/schema';\n\nexport const monospaceMarkName = 'monospace';\nexport const monospaceType = markTypeFactory(monospaceMarkName);\n\nexport const MonospaceSpecs: ExtensionAuto = (builder) => {\n builder\n .configureMd((md) => md.use(yfmPlugin, {log}))\n .addMark(monospaceMarkName, () => ({\n spec: {\n parseDOM: [{tag: 'samp'}],\n toDOM() {\n return ['samp'];\n },\n },\n fromMd: {\n tokenSpec: {\n name: monospaceMarkName,\n type: 'mark',\n },\n },\n toMd: {\n open: '##',\n close: '##',\n mixable: true,\n expelEnclosingWhitespace: true,\n },\n }));\n};\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VideoSpecs = exports.videoType = exports.videoNodeName = void 0;
|
|
4
|
-
const
|
|
5
|
-
const log_js_1 = tslib_1.__importDefault(require("@diplodoc/transform/lib/log.js"));
|
|
4
|
+
const log_js_1 = require("@diplodoc/transform/lib/log.js");
|
|
6
5
|
const const_1 = require("./const.js");
|
|
7
6
|
const md_video_1 = require("./md-video.js");
|
|
8
7
|
const utils_1 = require("./utils.js");
|
|
@@ -18,7 +17,7 @@ Object.defineProperty(exports, "videoNodeName", { enumerable: true, get: functio
|
|
|
18
17
|
var utils_2 = require("./utils.js");
|
|
19
18
|
Object.defineProperty(exports, "videoType", { enumerable: true, get: function () { return utils_2.videoType; } });
|
|
20
19
|
const VideoSpecs = (builder, opts) => {
|
|
21
|
-
const options = { ...md_video_1.defaults, ...opts, log: log_js_1.
|
|
20
|
+
const options = { ...md_video_1.defaults, ...opts, log: log_js_1.log };
|
|
22
21
|
builder.configureMd((md) => md.use(md_video_1.videoPlugin, options));
|
|
23
22
|
builder.addNode(const_1.videoNodeName, () => ({
|
|
24
23
|
spec: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/Video/VideoSpecs/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/Video/VideoSpecs/index.ts"],"names":[],"mappings":";;;AAAA,2DAAmD;AAInD,sCAAiD;AACjD,4CAMoB;AACpB,sCAA8D;AAE9D,+BAA+B;AAC/B,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC;IACnD,uBAAY,CAAC,OAAO;IACpB,uBAAY,CAAC,KAAK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AE,OAAO;gCAC5B,CAAC,iBAAS,CAAC,OAAO,CAAC,EAAE,OAAO;6BAC/B;yBACJ;qBACJ,CAAC;gBACN,CAAC;gBAED,OAAO,IAAA,sBAAc,EAAC,IAAI,CAAC,CAAC;YAChC,CAAC;SACJ;QACD,MAAM,EAAE;YACJ,SAAS,EAAE;gBACP,IAAI,EAAE,qBAAa;gBACnB,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;oBAChB,CAAC,iBAAS,CAAC,OAAO,CAAC,EAAG,GAAkB,CAAC,OAAO;oBAChD,CAAC,iBAAS,CAAC,OAAO,CAAC,EAAG,GAAkB,CAAC,OAAO;iBACnD,CAAC;aACL;SACJ;QACD,IAAI,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAClB,KAAK,CAAC,KAAK,CAAC,IAAA,6BAAqB,EAAC,IAAI,CAAC,CAAC,CAAC;QAC7C,CAAC;KACJ,CAAC,CAAC,CAAC;AACR,CAAC,CAAC;AAnFW,QAAA,UAAU,cAmFrB","sourcesContent":["import {log} from '@diplodoc/transform/lib/log.js';\n\nimport type {ExtensionAuto} from '../../../../core';\n\nimport {VideoAttr, videoNodeName} from './const';\nimport {\n type VideoPluginOptions,\n VideoService,\n type VideoToken,\n defaults,\n videoPlugin,\n} from './md-video';\nimport {createViewStub, serializeNodeToString} from './utils';\n\n// we don't support osf service\nconst availableServices: ReadonlySet<string> = new Set([\n VideoService.YouTube,\n VideoService.Vimeo,\n VideoService.Vine,\n VideoService.Prezi,\n]);\n\nexport {videoNodeName} from './const';\nexport {videoType} from './utils';\n\nexport type VideoSpecsOptions = VideoPluginOptions & {};\n\nexport const VideoSpecs: ExtensionAuto<VideoSpecsOptions> = (builder, opts) => {\n const options = {...defaults, ...opts, log};\n\n builder.configureMd((md) => md.use(videoPlugin, options));\n builder.addNode(videoNodeName, () => ({\n spec: {\n inline: true,\n atom: true,\n group: 'inline',\n attrs: {[VideoAttr.Service]: {}, [VideoAttr.VideoID]: {}},\n parseDOM: [\n {\n tag: `span[${VideoAttr.Service}][${VideoAttr.VideoID}]`,\n getAttrs(dom) {\n const domElem = dom as HTMLElement;\n return {\n [VideoAttr.Service]: domElem.getAttribute(VideoAttr.Service),\n [VideoAttr.VideoID]: domElem.getAttribute(VideoAttr.VideoID),\n };\n },\n },\n {\n tag: `iframe[${VideoAttr.Service}][${VideoAttr.VideoID}]`,\n getAttrs(dom) {\n const domElem = dom as HTMLElement;\n return {\n [VideoAttr.Service]: domElem.getAttribute(VideoAttr.Service),\n [VideoAttr.VideoID]: domElem.getAttribute(VideoAttr.VideoID),\n };\n },\n priority: 100,\n },\n ],\n toDOM(node) {\n const service = node.attrs[VideoAttr.Service];\n const videoId = node.attrs[VideoAttr.VideoID];\n\n if (availableServices.has(service) || !videoId) {\n let src = '';\n if (typeof options.videoUrl === 'function') {\n src = options.videoUrl(service, videoId, options);\n }\n return [\n 'div',\n {\n class: 'embed-responsive embed-responsive-16by9',\n },\n [\n 'iframe',\n {\n class: `embed-responsive-item ${service}-player`,\n type: 'text/html',\n width: String(options[service as VideoService].width),\n height: String(options[service as VideoService].height),\n src: src,\n frameborder: '0',\n webkitallowfullscreen: '',\n mozallowfullscreen: '',\n allowfullscreen: '',\n [VideoAttr.Service]: service,\n [VideoAttr.VideoID]: videoId,\n },\n ],\n ];\n }\n\n return createViewStub(node);\n },\n },\n fromMd: {\n tokenSpec: {\n name: videoNodeName,\n type: 'node',\n getAttrs: (tok) => ({\n [VideoAttr.Service]: (tok as VideoToken).service,\n [VideoAttr.VideoID]: (tok as VideoToken).videoID,\n }),\n },\n },\n toMd: (state, node) => {\n state.write(serializeNodeToString(node));\n },\n }));\n};\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.YfmNoteSpecs = exports.noteTitleType = exports.noteType = exports.YfmNoteNode = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const log_js_1 =
|
|
5
|
+
const log_js_1 = require("@diplodoc/transform/lib/log.js");
|
|
6
6
|
const index_js_1 = tslib_1.__importDefault(require("@diplodoc/transform/lib/plugins/notes/index.js"));
|
|
7
7
|
const const_1 = require("./const.js");
|
|
8
8
|
const parser_1 = require("./parser.js");
|
|
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "noteTitleType", { enumerable: true, get: functio
|
|
|
16
16
|
const YfmNoteSpecs = (builder, opts) => {
|
|
17
17
|
const schemaSpecs = (0, schema_1.getSchemaSpecs)(opts, builder.context.get('placeholder'));
|
|
18
18
|
builder
|
|
19
|
-
.configureMd((md) => md.use(index_js_1.default, { log: log_js_1.
|
|
19
|
+
.configureMd((md) => md.use(index_js_1.default, { log: log_js_1.log }))
|
|
20
20
|
.addNode(const_1.NoteNode.Note, () => ({
|
|
21
21
|
spec: schemaSpecs[const_1.NoteNode.Note],
|
|
22
22
|
toMd: serializer_1.serializerTokens[const_1.NoteNode.Note],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/index.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/index.ts"],"names":[],"mappings":";;;;AAAA,2DAAmD;AACnD,sGAAuE;AAKvE,sCAAiC;AACjC,wCAAsC;AACtC,wCAAwC;AACxC,gDAA8C;AAE9C,oCAAgD;AAAxC,oGAAA,QAAQ,OAAe;AAC/B,oCAAgD;AAAxC,iGAAA,QAAQ,OAAA;AAAE,sGAAA,aAAa,OAAA;AASxB,MAAM,YAAY,GAAuC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;IAC9E,MAAM,WAAW,GAAG,IAAA,uBAAc,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;IAE7E,OAAO;SACF,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,kBAAS,EAAE,EAAC,GAAG,EAAH,YAAG,EAAC,CAAC,CAAC;SAC7C,OAAO,CAAC,gBAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;QAC3B,IAAI,EAAE,WAAW,CAAC,gBAAQ,CAAC,IAAI,CAAC;QAChC,IAAI,EAAE,6BAAgB,CAAC,gBAAQ,CAAC,IAAI,CAAC;QACrC,MAAM,EAAE;YACJ,SAAS,EAAE,qBAAY,CAAC,gBAAQ,CAAC,IAAI,CAAC;SACzC;KACJ,CAAC,CAAC;SACF,OAAO,CAAC,gBAAQ,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;QAChC,IAAI,EAAE,WAAW,CAAC,gBAAQ,CAAC,SAAS,CAAC;QACrC,IAAI,EAAE,6BAAgB,CAAC,gBAAQ,CAAC,SAAS,CAAC;QAC1C,MAAM,EAAE;YACJ,SAAS,EAAE,qBAAY,CAAC,gBAAQ,CAAC,SAAS,CAAC;SAC9C;KACJ,CAAC,CAAC;SACF,OAAO,CAAC,gBAAQ,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;QAClC,IAAI,EAAE,WAAW,CAAC,gBAAQ,CAAC,WAAW,CAAC;QACvC,IAAI,EAAE,6BAAgB,CAAC,gBAAQ,CAAC,WAAW,CAAC;QAC5C,MAAM,EAAE;YACJ,SAAS,EAAE,qBAAY,CAAC,gBAAQ,CAAC,WAAW,CAAC;SAChD;KACJ,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC;AA1BW,QAAA,YAAY,gBA0BvB","sourcesContent":["import {log} from '@diplodoc/transform/lib/log.js';\nimport yfmPlugin from '@diplodoc/transform/lib/plugins/notes/index.js';\nimport type {NodeSpec} from 'prosemirror-model';\n\nimport type {ExtensionAuto} from '../../../../core';\n\nimport {NoteNode} from './const';\nimport {parserTokens} from './parser';\nimport {getSchemaSpecs} from './schema';\nimport {serializerTokens} from './serializer';\n\nexport {NoteNode as YfmNoteNode} from './const';\nexport {noteType, noteTitleType} from './utils';\n\nexport type YfmNoteSpecsOptions = {\n /**\n * @deprecated: use placeholder option in BehaviorPreset instead.\n */\n yfmNoteTitlePlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];\n};\n\nexport const YfmNoteSpecs: ExtensionAuto<YfmNoteSpecsOptions> = (builder, opts) => {\n const schemaSpecs = getSchemaSpecs(opts, builder.context.get('placeholder'));\n\n builder\n .configureMd((md) => md.use(yfmPlugin, {log}))\n .addNode(NoteNode.Note, () => ({\n spec: schemaSpecs[NoteNode.Note],\n toMd: serializerTokens[NoteNode.Note],\n fromMd: {\n tokenSpec: parserTokens[NoteNode.Note],\n },\n }))\n .addNode(NoteNode.NoteTitle, () => ({\n spec: schemaSpecs[NoteNode.NoteTitle],\n toMd: serializerTokens[NoteNode.NoteTitle],\n fromMd: {\n tokenSpec: parserTokens[NoteNode.NoteTitle],\n },\n }))\n .addNode(NoteNode.NoteContent, () => ({\n spec: schemaSpecs[NoteNode.NoteContent],\n toMd: serializerTokens[NoteNode.NoteContent],\n fromMd: {\n tokenSpec: parserTokens[NoteNode.NoteContent],\n },\n }));\n};\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.YfmTableSpecs = exports.yfmTableCellType = exports.yfmTableRowType = exports.yfmTableBodyType = exports.yfmTableType = exports.YfmTableNode = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const log_js_1 =
|
|
5
|
+
const log_js_1 = require("@diplodoc/transform/lib/log.js");
|
|
6
6
|
const index_js_1 = tslib_1.__importDefault(require("@diplodoc/transform/lib/plugins/table/index.js"));
|
|
7
7
|
const const_1 = require("./const.js");
|
|
8
8
|
const parser_1 = require("./parser.js");
|
|
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "yfmTableCellType", { enumerable: true, get: func
|
|
|
18
18
|
const YfmTableSpecs = (builder, options) => {
|
|
19
19
|
const schemaSpecs = (0, schema_1.getSchemaSpecs)(options, builder.context.get('placeholder'));
|
|
20
20
|
builder
|
|
21
|
-
.configureMd((md) => md.use(index_js_1.default, { log: log_js_1.
|
|
21
|
+
.configureMd((md) => md.use(index_js_1.default, { log: log_js_1.log }))
|
|
22
22
|
.addNode(const_1.YfmTableNode.Table, () => ({
|
|
23
23
|
spec: schemaSpecs[const_1.YfmTableNode.Table],
|
|
24
24
|
toMd: serializer_1.serializerTokens[const_1.YfmTableNode.Table],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmTable/YfmTableSpecs/index.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmTable/YfmTableSpecs/index.ts"],"names":[],"mappings":";;;;AAAA,2DAAmD;AACnD,sGAAsE;AAItE,sCAAqC;AACrC,wCAAsC;AACtC,wCAAoE;AACpE,gDAA8C;AAE9C,oCAAqC;AAA7B,qGAAA,YAAY,OAAA;AACpB,oCAA0F;AAAlF,qGAAA,YAAY,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAAE,wGAAA,eAAe,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAIlE,MAAM,aAAa,GAA+C,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;IAC1F,MAAM,WAAW,GAAG,IAAA,uBAAc,EAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;IAEhF,OAAO;SACF,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,kBAAQ,EAAE,EAAC,GAAG,EAAH,YAAG,EAAC,CAAC,CAAC;SAC5C,OAAO,CAAC,oBAAY,CAAC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ensionWithOptions} from '../../../../core';\n\nimport {YfmTableNode} from './const';\nimport {parserTokens} from './parser';\nimport {type YfmTableSchemaOptions, getSchemaSpecs} from './schema';\nimport {serializerTokens} from './serializer';\n\nexport {YfmTableNode} from './const';\nexport {yfmTableType, yfmTableBodyType, yfmTableRowType, yfmTableCellType} from './utils';\n\nexport type YfmTableSpecsOptions = YfmTableSchemaOptions & {};\n\nexport const YfmTableSpecs: ExtensionWithOptions<YfmTableSpecsOptions> = (builder, options) => {\n const schemaSpecs = getSchemaSpecs(options, builder.context.get('placeholder'));\n\n builder\n .configureMd((md) => md.use(yfmTable, {log}))\n .addNode(YfmTableNode.Table, () => ({\n spec: schemaSpecs[YfmTableNode.Table],\n toMd: serializerTokens[YfmTableNode.Table],\n fromMd: {tokenSpec: parserTokens[YfmTableNode.Table]},\n }))\n .addNode(YfmTableNode.Body, () => ({\n spec: schemaSpecs[YfmTableNode.Body],\n toMd: serializerTokens[YfmTableNode.Body],\n fromMd: {tokenSpec: parserTokens[YfmTableNode.Body]},\n }))\n .addNode(YfmTableNode.Row, () => ({\n spec: schemaSpecs[YfmTableNode.Row],\n toMd: serializerTokens[YfmTableNode.Row],\n fromMd: {tokenSpec: parserTokens[YfmTableNode.Row]},\n }))\n .addNode(YfmTableNode.Cell, () => ({\n spec: schemaSpecs[YfmTableNode.Cell],\n toMd: serializerTokens[YfmTableNode.Cell],\n fromMd: {tokenSpec: parserTokens[YfmTableNode.Cell]},\n }));\n};\n"]}
|
package/build/cjs/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
/** During build process, the current version will be injected here */
|
|
5
|
-
exports.VERSION = typeof '15.
|
|
5
|
+
exports.VERSION = typeof '15.9.0' !== 'undefined' ? '15.9.0' : 'unknown';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/build/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"../../src","sources":["version.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACzD,QAAA,OAAO,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC","sourcesContent":["/** During build process, the current version will be injected here */\nexport const VERSION = typeof '15.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"../../src","sources":["version.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACzD,QAAA,OAAO,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC","sourcesContent":["/** During build process, the current version will be injected here */\nexport const VERSION = typeof '15.9.0' !== 'undefined' ? '15.9.0' : 'unknown';\n"]}
|
|
@@ -3,5 +3,17 @@ import { type ContextConfig } from "./tooltip.js";
|
|
|
3
3
|
export type { ContextConfig as SelectionContextConfig, ContextGroupItemData as SelectionContextItemData, } from "./tooltip.js";
|
|
4
4
|
export type SelectionContextOptions = {
|
|
5
5
|
config?: ContextConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Placement of context popup
|
|
8
|
+
*
|
|
9
|
+
* @default 'bottom'
|
|
10
|
+
*/
|
|
11
|
+
placement?: 'top' | 'bottom';
|
|
12
|
+
/**
|
|
13
|
+
* Prevents context popup from overflowing
|
|
14
|
+
*
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
flip?: boolean;
|
|
6
18
|
};
|
|
7
19
|
export declare const SelectionContext: ExtensionAuto<SelectionContextOptions>;
|
|
@@ -2,9 +2,10 @@ import { keydownHandler } from 'prosemirror-keymap';
|
|
|
2
2
|
import { AllSelection, Plugin, TextSelection, } from 'prosemirror-state';
|
|
3
3
|
import { isCodeBlock } from "../../../utils/nodes.js";
|
|
4
4
|
import { TooltipView } from "./tooltip.js";
|
|
5
|
-
export const SelectionContext = (builder,
|
|
5
|
+
export const SelectionContext = (builder, opts) => {
|
|
6
|
+
const { config } = opts;
|
|
6
7
|
if (Array.isArray(config) && config.length > 0) {
|
|
7
|
-
builder.addPlugin(({ actions }) => new Plugin(new SelectionTooltip(actions, config, builder.logger)));
|
|
8
|
+
builder.addPlugin(({ actions }) => new Plugin(new SelectionTooltip(actions, config, builder.logger, opts)));
|
|
8
9
|
}
|
|
9
10
|
};
|
|
10
11
|
class SelectionTooltip {
|
|
@@ -12,8 +13,8 @@ class SelectionTooltip {
|
|
|
12
13
|
tooltip;
|
|
13
14
|
hideTimeoutRef = null;
|
|
14
15
|
_isMousePressed = false;
|
|
15
|
-
constructor(actions, menuConfig, logger) {
|
|
16
|
-
this.tooltip = new TooltipView(actions, menuConfig, logger);
|
|
16
|
+
constructor(actions, menuConfig, logger, options) {
|
|
17
|
+
this.tooltip = new TooltipView(actions, menuConfig, logger, options);
|
|
17
18
|
}
|
|
18
19
|
get props() {
|
|
19
20
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/SelectionContext/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACH,YAAY,EAEZ,MAAM,EAEN,aAAa,GAChB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAC,WAAW,EAAC,gCAA6B;AAEjD,OAAO,EAAqB,WAAW,EAAC,qBAAkB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/SelectionContext/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACH,YAAY,EAEZ,MAAM,EAEN,aAAa,GAChB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAC,WAAW,EAAC,gCAA6B;AAEjD,OAAO,EAAqB,WAAW,EAAC,qBAAkB;AAuB1D,MAAM,CAAC,MAAM,gBAAgB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AI,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;YAC/B,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAClC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC/B,CAAC;IACL,CAAC;CACJ","sourcesContent":["import {keydownHandler} from 'prosemirror-keymap';\nimport {\n AllSelection,\n type EditorState,\n Plugin,\n type PluginSpec,\n TextSelection,\n} from 'prosemirror-state';\nimport type {EditorProps, EditorView} from 'prosemirror-view';\n\nimport type {ActionStorage, ExtensionAuto} from '../../../core';\nimport type {Logger2} from '../../../logger';\nimport {isCodeBlock} from '../../../utils/nodes';\n\nimport {type ContextConfig, TooltipView} from './tooltip';\n\nexport type {\n ContextConfig as SelectionContextConfig,\n ContextGroupItemData as SelectionContextItemData,\n} from './tooltip';\n\nexport type SelectionContextOptions = {\n config?: ContextConfig;\n /**\n * Placement of context popup\n *\n * @default 'bottom'\n */\n placement?: 'top' | 'bottom';\n /**\n * Prevents context popup from overflowing\n *\n * @default false\n */\n flip?: boolean;\n};\n\nexport const SelectionContext: ExtensionAuto<SelectionContextOptions> = (builder, opts) => {\n const {config} = opts;\n if (Array.isArray(config) && config.length > 0) {\n builder.addPlugin(\n ({actions}) => new Plugin(new SelectionTooltip(actions, config, builder.logger, opts)),\n );\n }\n};\n\ntype TinyState = Pick<EditorState, 'doc' | 'selection'>;\n\nclass SelectionTooltip implements PluginSpec<unknown> {\n private destroyed = false;\n\n private tooltip: TooltipView;\n private hideTimeoutRef: ReturnType<typeof setTimeout> | null = null;\n\n private _isMousePressed = false;\n\n constructor(\n actions: ActionStorage,\n menuConfig: ContextConfig,\n logger: Logger2.ILogger,\n options: SelectionContextOptions,\n ) {\n this.tooltip = new TooltipView(actions, menuConfig, logger, options);\n }\n\n get props(): EditorProps {\n return {\n // same as keymap({})\n handleKeyDown: keydownHandler({\n // hide context menu when Esc was pressed\n Escape: (_state, _dispatch, view) => {\n if (this.tooltip.isTooltipOpen) {\n this.tooltip.hide(view!);\n return true;\n }\n return false;\n },\n }),\n handleDOMEvents: {\n mousedown: (view) => {\n const startState: TinyState = {\n doc: view.state.doc,\n selection: view.state.selection,\n };\n this._isMousePressed = true;\n this.cancelTooltipHiding();\n this.tooltip.hide(view);\n\n const onMouseUp = () => {\n if (this.destroyed) return;\n this._isMousePressed = false;\n this.update(view, startState);\n };\n\n document.addEventListener('mouseup', onMouseUp, {once: true});\n },\n },\n };\n }\n\n view(view: EditorView) {\n this.update(view);\n return {\n update: this.update.bind(this),\n destroy: () => {\n this.destroyed = true;\n this.cancelTooltipHiding();\n this.tooltip.destroy();\n },\n };\n }\n\n private update(view: EditorView, prevState?: TinyState) {\n if (this._isMousePressed) return;\n\n this.cancelTooltipHiding();\n\n // Don't show tooltip if editor not mounted to the DOM\n // or when view is out of focus\n if (!view.dom.parentNode || !view.hasFocus()) {\n this.tooltip.hide(view);\n return;\n }\n\n const {state} = view;\n // Don't do anything if the document/selection didn't change\n if (prevState && prevState.doc.eq(state.doc) && prevState.selection.eq(state.selection))\n return;\n\n const {selection} = state;\n // Hide the tooltip if the selection is empty\n if (\n selection.empty ||\n !(selection instanceof TextSelection || selection instanceof AllSelection)\n ) {\n this.tooltip.hide(view);\n return;\n }\n\n // Hide the tooltip when one side of selection inside codeblock\n if (isCodeBlock(selection.$from.parent) || isCodeBlock(selection.$to.parent)) {\n this.tooltip.hide(view);\n return;\n }\n\n this.tooltip.show(view, {\n onOpenChange: (_open, _event, reason) => {\n if (reason !== 'escape-key') this.scheduleTooltipHiding(view);\n },\n });\n }\n\n private scheduleTooltipHiding(view: EditorView) {\n this.hideTimeoutRef = setTimeout(() => {\n // hide tooltip if view is out of focus after 30 ms\n if (!view.hasFocus()) {\n this.tooltip.hide(view);\n }\n }, 30);\n }\n\n private cancelTooltipHiding() {\n if (this.hideTimeoutRef !== null) {\n clearTimeout(this.hideTimeoutRef);\n this.hideTimeoutRef = null;\n }\n }\n}\n"]}
|
|
@@ -11,15 +11,22 @@ export type ContextGroupItemData = (ToolbarGroupItemData<ActionStorage> & {
|
|
|
11
11
|
});
|
|
12
12
|
export type ContextGroupData = ContextGroupItemData[];
|
|
13
13
|
export type ContextConfig = ContextGroupData[];
|
|
14
|
+
export type TooltipViewParams = {
|
|
15
|
+
/** @default 'bottom' */
|
|
16
|
+
placement?: 'top' | 'bottom';
|
|
17
|
+
/** @default false */
|
|
18
|
+
flip?: boolean;
|
|
19
|
+
};
|
|
14
20
|
export declare class TooltipView {
|
|
15
21
|
#private;
|
|
16
|
-
private logger;
|
|
17
|
-
private actions;
|
|
18
|
-
private menuConfig;
|
|
22
|
+
private readonly logger;
|
|
23
|
+
private readonly actions;
|
|
24
|
+
private readonly menuConfig;
|
|
25
|
+
private readonly placement;
|
|
19
26
|
private view;
|
|
20
27
|
private baseProps;
|
|
21
28
|
private _tooltipRenderItem;
|
|
22
|
-
constructor(actions: ActionStorage, menuConfig: ContextConfig, logger: Logger2.ILogger);
|
|
29
|
+
constructor(actions: ActionStorage, menuConfig: ContextConfig, logger: Logger2.ILogger, params: TooltipViewParams);
|
|
23
30
|
get isTooltipOpen(): boolean;
|
|
24
31
|
show(view: EditorView, popupProps?: PopupProps): void;
|
|
25
32
|
hide(view: EditorView): void;
|
|
@@ -29,5 +36,4 @@ export declare class TooltipView {
|
|
|
29
36
|
private renderPopup;
|
|
30
37
|
private get tooltipRenderItem();
|
|
31
38
|
private calcPosition;
|
|
32
|
-
private get popupTextOffset();
|
|
33
39
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { offset, shift } from '@floating-ui/react'; // eslint-disable-line import/no-extraneous-dependencies
|
|
3
2
|
import { Popup } from '@gravity-ui/uikit';
|
|
4
3
|
import { isFunction } from "../../../lodash.js";
|
|
5
4
|
import { globalLogger } from "../../../logger.js";
|
|
@@ -16,13 +15,16 @@ export class TooltipView {
|
|
|
16
15
|
logger;
|
|
17
16
|
actions;
|
|
18
17
|
menuConfig;
|
|
18
|
+
placement;
|
|
19
19
|
view;
|
|
20
20
|
baseProps = { show: false, poppupProps: {} };
|
|
21
21
|
_tooltipRenderItem = null;
|
|
22
|
-
constructor(actions, menuConfig, logger) {
|
|
22
|
+
constructor(actions, menuConfig, logger, params) {
|
|
23
23
|
this.logger = logger;
|
|
24
24
|
this.actions = actions;
|
|
25
25
|
this.menuConfig = menuConfig;
|
|
26
|
+
const { flip, placement = 'bottom' } = params;
|
|
27
|
+
this.placement = flip ? placement : [placement];
|
|
26
28
|
}
|
|
27
29
|
get isTooltipOpen() {
|
|
28
30
|
return this.#isTooltipOpen;
|
|
@@ -88,38 +90,34 @@ export class TooltipView {
|
|
|
88
90
|
return this._tooltipRenderItem;
|
|
89
91
|
}
|
|
90
92
|
calcPosition(view) {
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
const virtualElem = {
|
|
94
|
+
getBoundingClientRect() {
|
|
95
|
+
// These are in screen coordinates
|
|
96
|
+
const start = view.coordsAtPos(view.state.selection.from);
|
|
97
|
+
const end = view.coordsAtPos(view.state.selection.to);
|
|
98
|
+
// Find a center-ish x position from the selection endpoints (when
|
|
99
|
+
// crossing lines, end may be more to the left)
|
|
100
|
+
const yCenter = Math.max((start.left + end.left) / 2, start.left + 3);
|
|
101
|
+
const top = start.top;
|
|
102
|
+
const left = yCenter - 1;
|
|
103
|
+
const width = 2;
|
|
104
|
+
const height = end.bottom - start.top;
|
|
105
|
+
return {
|
|
106
|
+
top,
|
|
107
|
+
left,
|
|
108
|
+
right: left + width,
|
|
109
|
+
bottom: top + height,
|
|
110
|
+
y: top,
|
|
111
|
+
x: left,
|
|
112
|
+
height,
|
|
113
|
+
width,
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
};
|
|
104
117
|
return {
|
|
105
|
-
placement:
|
|
106
|
-
anchorElement:
|
|
107
|
-
// override floating middlewares
|
|
108
|
-
floatingMiddlewares: [
|
|
109
|
-
offset({
|
|
110
|
-
mainAxis: bottomOffset,
|
|
111
|
-
crossAxis: leftOffset,
|
|
112
|
-
}),
|
|
113
|
-
shift({
|
|
114
|
-
mainAxis: true,
|
|
115
|
-
crossAxis: false,
|
|
116
|
-
padding: 4,
|
|
117
|
-
}),
|
|
118
|
-
],
|
|
118
|
+
placement: this.placement,
|
|
119
|
+
anchorElement: virtualElem,
|
|
119
120
|
};
|
|
120
121
|
}
|
|
121
|
-
get popupTextOffset() {
|
|
122
|
-
return 4; // 4px offset from text selection
|
|
123
|
-
}
|
|
124
122
|
}
|
|
125
123
|
//# sourceMappingURL=tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/SelectionContext/tooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,oBAAoB,CAAC,CAAC,wDAAwD;AAC1G,OAAO,EAAC,KAAK,EAAkB,MAAM,mBAAmB,CAAC;AAKzD,OAAO,EAAC,UAAU,EAAC,2BAAwB;AAC3C,OAAO,EAAe,YAAY,EAAC,2BAAwB;AAC3D,OAAO,EAAC,mBAAmB,EAAC,8CAA2C;AACvE,OAAO,EAAC,OAAO,EAAC,kCAAyB;AAOzC,OAAO,EAAoB,yBAAyB,EAAC,kCAAyB;AAQ9E,MAAM,gBAAgB,GAAoC,CAAC,EACvD,IAAI,EACJ,WAAW,EACX,GAAG,YAAY,EAClB,EAAE,EAAE;IACD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,CACH,KAAC,KAAK,IAAC,IAAI,WAAK,WAAW,EAAE,KAAK,EAAE,EAAC,OAAO,EAAE,SAAS,EAAC,YACpD,KAAC,OAAO,OAAK,YAAY,GAAI,GACzB,CACX,C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MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC;QAE3E,OAAO;YACH,SAAS,EAAE,QAAQ;YACnB,aAAa,EAAE,OAAO;YACtB,gCAAgC;YAChC,mBAAmB,EAAE;gBACjB,MAAM,CAAC;oBACH,QAAQ,EAAE,YAAY;oBACtB,SAAS,EAAE,UAAU;iBACxB,CAAC;gBACF,KAAK,CAAC;oBACF,QAAQ,EAAE,IAAI;oBACd,SAAS,EAAE,KAAK;oBAChB,OAAO,EAAE,CAAC;iBACb,CAAC;aACL;SACJ,CAAC;IACN,CAAC;IAED,IAAY,eAAe;QACvB,OAAO,CAAC,CAAC,CAAC,iCAAiC;IAC/C,CAAC;CACJ","sourcesContent":["import {offset, shift} from '@floating-ui/react'; // eslint-disable-line import/no-extraneous-dependencies\nimport {Popup, type PopupProps} from '@gravity-ui/uikit';\nimport type {EditorState} from 'prosemirror-state';\nimport type {EditorView} from 'prosemirror-view';\n\nimport type {ActionStorage} from '../../../core';\nimport {isFunction} from '../../../lodash';\nimport {type Logger2, globalLogger} from '../../../logger';\nimport {ErrorLoggerBoundary} from '../../../react-utils/ErrorBoundary';\nimport {Toolbar} from '../../../toolbar';\nimport type {\n ToolbarButtonPopupData,\n ToolbarGroupItemData,\n ToolbarProps,\n ToolbarSingleItemData,\n} from '../../../toolbar';\nimport {type RendererItem, getReactRendererFromState} from '../ReactRenderer';\n\ntype SelectionTooltipBaseProps = {\n show?: boolean;\n poppupProps: PopupProps;\n};\ntype SelectionTooltipProps = SelectionTooltipBaseProps & ToolbarProps<ActionStorage>;\n\nconst SelectionTooltip: React.FC<SelectionTooltipProps> = ({\n show,\n poppupProps,\n ...toolbarProps\n}) => {\n if (!show) return null;\n return (\n <Popup open {...poppupProps} style={{padding: '4px 8px'}}>\n <Toolbar {...toolbarProps} />\n </Popup>\n );\n};\n\nexport type ContextGroupItemData =\n | (ToolbarGroupItemData<ActionStorage> & {\n condition?: (state: EditorState) => void;\n })\n | ((ToolbarSingleItemData<ActionStorage> | ToolbarButtonPopupData<ActionStorage>) & {\n condition?: 'enabled';\n });\n\nexport type ContextGroupData = ContextGroupItemData[];\nexport type ContextConfig = ContextGroupData[];\n\nexport class TooltipView {\n #isTooltipOpen = false;\n\n private logger: Logger2.ILogger;\n private actions: ActionStorage;\n private menuConfig: ContextConfig;\n\n private view!: EditorView;\n private baseProps: SelectionTooltipBaseProps = {show: false, poppupProps: {}};\n private _tooltipRenderItem: RendererItem | null = null;\n\n constructor(actions: ActionStorage, menuConfig: ContextConfig, logger: Logger2.ILogger) {\n this.logger = logger;\n this.actions = actions;\n this.menuConfig = menuConfig;\n }\n\n get isTooltipOpen(): boolean {\n return this.#isTooltipOpen;\n }\n\n show(view: EditorView, popupProps?: PopupProps) {\n this.view = view;\n this.#isTooltipOpen = true;\n this.baseProps = {\n show: true,\n poppupProps: {\n ...popupProps,\n ...this.calcPosition(view),\n },\n };\n this.renderPopup();\n }\n\n hide(view: EditorView) {\n this.view = view;\n this.#isTooltipOpen = false;\n this.baseProps = {show: false, poppupProps: {}};\n this.renderPopup();\n }\n\n destroy() {\n this._tooltipRenderItem?.remove();\n this._tooltipRenderItem = null;\n }\n\n private getSelectionTooltipProps(): SelectionTooltipProps {\n return {\n ...this.baseProps,\n focus: () => this.view.focus(),\n data: this.getFilteredConfig(),\n editor: this.actions,\n onClick: (id) => {\n globalLogger.action({mode: 'wysiwyg', source: 'context-menu', action: id});\n this.logger.action({source: 'context-menu', action: id});\n },\n };\n }\n\n private getFilteredConfig(): ContextConfig {\n return this.baseProps.show\n ? this.menuConfig\n .map((groupData) =>\n groupData.filter((item) => {\n const {condition} = item;\n if (condition === 'enabled') {\n return item.isEnable(this.actions);\n }\n if (isFunction(condition)) {\n return condition(this.view.state);\n }\n return true;\n }),\n )\n .filter((groupData) => Boolean(groupData.length))\n : [];\n }\n\n private renderPopup() {\n this.tooltipRenderItem.rerender();\n }\n\n private get tooltipRenderItem() {\n if (!this._tooltipRenderItem) {\n const reactRenderer = getReactRendererFromState(this.view.state);\n this._tooltipRenderItem = reactRenderer.createItem('selection_context', () => (\n <ErrorLoggerBoundary>\n <SelectionTooltip {...this.getSelectionTooltipProps()} />\n </ErrorLoggerBoundary>\n ));\n }\n return this._tooltipRenderItem;\n }\n\n private calcPosition(view: EditorView): PopupProps {\n const viewDom = view.dom as Element;\n // The box in which the tooltip is positioned, to use as base\n const viewBox = viewDom.getBoundingClientRect();\n\n const viewWidth = viewBox.right - viewBox.left;\n const viewHalfWidth = viewWidth / 2;\n\n // These are in screen coordinates\n const start = view.coordsAtPos(view.state.selection.from);\n const end = view.coordsAtPos(view.state.selection.to);\n\n // Find a center-ish x position from the selection endpoints (when\n // crossing lines, end may be more to the left)\n const left = Math.max((start.left + end.left) / 2, start.left + 3);\n\n const leftOffset = left - (viewBox.left + viewHalfWidth);\n const bottomOffset = -(viewBox.bottom - end.bottom) + this.popupTextOffset;\n\n return {\n placement: 'bottom',\n anchorElement: viewDom,\n // override floating middlewares\n floatingMiddlewares: [\n offset({\n mainAxis: bottomOffset,\n crossAxis: leftOffset,\n }),\n shift({\n mainAxis: true,\n crossAxis: false,\n padding: 4,\n }),\n ],\n };\n }\n\n private get popupTextOffset() {\n return 4; // 4px offset from text selection\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tooltip.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/SelectionContext/tooltip.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,KAAK,EAAuC,MAAM,mBAAmB,CAAC;AAK9E,OAAO,EAAC,UAAU,EAAC,2BAAwB;AAC3C,OAAO,EAAe,YAAY,EAAC,2BAAwB;AAC3D,OAAO,EAAC,mBAAmB,EAAC,8CAA2C;AACvE,OAAO,EAAC,OAAO,EAAC,kCAAyB;AAOzC,OAAO,EAAoB,yBAAyB,EAAC,kCAAyB;AAQ9E,MAAM,gBAAgB,GAAoC,CAAC,EACvD,IAAI,EACJ,WAAW,EACX,GAAG,YAAY,EAClB,EAAE,E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AG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;gBAEtE,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;gBACtB,MAAM,IAAI,GAAG,OAAO,GAAG,CAAC,CAAC;gBACzB,MAAM,KAAK,GAAG,CAAC,CAAC;gBAChB,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC;gBAEtC,OAAO;oBACH,GAAG;oBACH,IAAI;oBACJ,KAAK,EAAE,IAAI,GAAG,KAAK;oBACnB,MAAM,EAAE,GAAG,GAAG,MAAM;oBACpB,CAAC,EAAE,GAAG;oBACN,CAAC,EAAE,IAAI;oBACP,MAAM;oBACN,KAAK;iBACR,CAAC;YACN,CAAC;SACJ,CAAC;QAEF,OAAO;YACH,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,aAAa,EAAE,WAAW;SAC7B,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type {VirtualElement} from '@floating-ui/react'; // eslint-disable-line import/no-extraneous-dependencies\nimport {Popup, type PopupPlacement, type PopupProps} from '@gravity-ui/uikit';\nimport type {EditorState} from 'prosemirror-state';\nimport type {EditorView} from 'prosemirror-view';\n\nimport type {ActionStorage} from '../../../core';\nimport {isFunction} from '../../../lodash';\nimport {type Logger2, globalLogger} from '../../../logger';\nimport {ErrorLoggerBoundary} from '../../../react-utils/ErrorBoundary';\nimport {Toolbar} from '../../../toolbar';\nimport type {\n ToolbarButtonPopupData,\n ToolbarGroupItemData,\n ToolbarProps,\n ToolbarSingleItemData,\n} from '../../../toolbar';\nimport {type RendererItem, getReactRendererFromState} from '../ReactRenderer';\n\ntype SelectionTooltipBaseProps = {\n show?: boolean;\n poppupProps: PopupProps;\n};\ntype SelectionTooltipProps = SelectionTooltipBaseProps & ToolbarProps<ActionStorage>;\n\nconst SelectionTooltip: React.FC<SelectionTooltipProps> = ({\n show,\n poppupProps,\n ...toolbarProps\n}) => {\n if (!show) return null;\n return (\n <Popup open {...poppupProps} style={{padding: '4px 8px'}}>\n <Toolbar {...toolbarProps} />\n </Popup>\n );\n};\n\nexport type ContextGroupItemData =\n | (ToolbarGroupItemData<ActionStorage> & {\n condition?: (state: EditorState) => void;\n })\n | ((ToolbarSingleItemData<ActionStorage> | ToolbarButtonPopupData<ActionStorage>) & {\n condition?: 'enabled';\n });\n\nexport type ContextGroupData = ContextGroupItemData[];\nexport type ContextConfig = ContextGroupData[];\n\nexport type TooltipViewParams = {\n /** @default 'bottom' */\n placement?: 'top' | 'bottom';\n /** @default false */\n flip?: boolean;\n};\n\nexport class TooltipView {\n #isTooltipOpen = false;\n\n private readonly logger: Logger2.ILogger;\n private readonly actions: ActionStorage;\n private readonly menuConfig: ContextConfig;\n private readonly placement: PopupPlacement;\n\n private view!: EditorView;\n private baseProps: SelectionTooltipBaseProps = {show: false, poppupProps: {}};\n private _tooltipRenderItem: RendererItem | null = null;\n\n constructor(\n actions: ActionStorage,\n menuConfig: ContextConfig,\n logger: Logger2.ILogger,\n params: TooltipViewParams,\n ) {\n this.logger = logger;\n this.actions = actions;\n this.menuConfig = menuConfig;\n\n const {flip, placement = 'bottom'} = params;\n this.placement = flip ? placement : [placement];\n }\n\n get isTooltipOpen(): boolean {\n return this.#isTooltipOpen;\n }\n\n show(view: EditorView, popupProps?: PopupProps) {\n this.view = view;\n this.#isTooltipOpen = true;\n this.baseProps = {\n show: true,\n poppupProps: {\n ...popupProps,\n ...this.calcPosition(view),\n },\n };\n this.renderPopup();\n }\n\n hide(view: EditorView) {\n this.view = view;\n this.#isTooltipOpen = false;\n this.baseProps = {show: false, poppupProps: {}};\n this.renderPopup();\n }\n\n destroy() {\n this._tooltipRenderItem?.remove();\n this._tooltipRenderItem = null;\n }\n\n private getSelectionTooltipProps(): SelectionTooltipProps {\n return {\n ...this.baseProps,\n focus: () => this.view.focus(),\n data: this.getFilteredConfig(),\n editor: this.actions,\n onClick: (id) => {\n globalLogger.action({mode: 'wysiwyg', source: 'context-menu', action: id});\n this.logger.action({source: 'context-menu', action: id});\n },\n };\n }\n\n private getFilteredConfig(): ContextConfig {\n return this.baseProps.show\n ? this.menuConfig\n .map((groupData) =>\n groupData.filter((item) => {\n const {condition} = item;\n if (condition === 'enabled') {\n return item.isEnable(this.actions);\n }\n if (isFunction(condition)) {\n return condition(this.view.state);\n }\n return true;\n }),\n )\n .filter((groupData) => Boolean(groupData.length))\n : [];\n }\n\n private renderPopup() {\n this.tooltipRenderItem.rerender();\n }\n\n private get tooltipRenderItem() {\n if (!this._tooltipRenderItem) {\n const reactRenderer = getReactRendererFromState(this.view.state);\n this._tooltipRenderItem = reactRenderer.createItem('selection_context', () => (\n <ErrorLoggerBoundary>\n <SelectionTooltip {...this.getSelectionTooltipProps()} />\n </ErrorLoggerBoundary>\n ));\n }\n return this._tooltipRenderItem;\n }\n\n private calcPosition(view: EditorView): PopupProps {\n const virtualElem: VirtualElement = {\n getBoundingClientRect() {\n // These are in screen coordinates\n const start = view.coordsAtPos(view.state.selection.from);\n const end = view.coordsAtPos(view.state.selection.to);\n // Find a center-ish x position from the selection endpoints (when\n // crossing lines, end may be more to the left)\n const yCenter = Math.max((start.left + end.left) / 2, start.left + 3);\n\n const top = start.top;\n const left = yCenter - 1;\n const width = 2;\n const height = end.bottom - start.top;\n\n return {\n top,\n left,\n right: left + width,\n bottom: top + height,\n y: top,\n x: left,\n height,\n width,\n };\n },\n };\n\n return {\n placement: this.placement,\n anchorElement: virtualElem,\n };\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import log from '@diplodoc/transform/lib/log.js';
|
|
1
|
+
import { log } from '@diplodoc/transform/lib/log.js';
|
|
2
2
|
import sup from '@diplodoc/transform/lib/plugins/sup.js';
|
|
3
3
|
import { markTypeFactory } from "../../../../utils/schema.js";
|
|
4
4
|
export const superscriptMarkName = 'sup';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/markdown/Superscript/SuperscriptSpecs/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/markdown/Superscript/SuperscriptSpecs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,gCAAgC,CAAC;AACnD,OAAO,GAAG,MAAM,wCAAwC,CAAC;AAGzD,OAAO,EAAC,eAAe,EAAC,oCAAiC;AAEzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AACzC,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAC;AAEpE,MAAM,CAAC,MAAM,gBAAgB,GAAkB,CAAC,OAAO,EAAE,EAAE;IACvD,OAAO;SACF,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,EAAC,GAAG,EAAC,CAAC,CAAC;SACvC,OAAO,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;QACjC,IAAI,EAAE;YACF,QAAQ,EAAE,GAAG;YACb,QAAQ,EAAE,CAAC,EAAC,GAAG,EAAE,KAAK,EAAC,CAAC;YACxB,KAAK;gBACD,OAAO,CAAC,KAAK,CAAC,CAAC;YACnB,CAAC;SACJ;QACD,IAAI,EAAE;YACF,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;gBACZ,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAC9B,OAAO,GAAG,CAAC;YACf,CAAC;YACD,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACb,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC;gBAC/B,OAAO,GAAG,CAAC;YACf,CAAC;YACD,OAAO,EAAE,IAAI;YACb,wBAAwB,EAAE,IAAI;SACjC;QACD,MAAM,EAAE,EAAC,SAAS,EAAE,EAAC,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,EAAC,EAAC;KACjE,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import {log} from '@diplodoc/transform/lib/log.js';\nimport sup from '@diplodoc/transform/lib/plugins/sup.js';\n\nimport type {ExtensionAuto} from '../../../../core';\nimport {markTypeFactory} from '../../../../utils/schema';\n\nexport const superscriptMarkName = 'sup';\nexport const superscriptType = markTypeFactory(superscriptMarkName);\n\nexport const SuperscriptSpecs: ExtensionAuto = (builder) => {\n builder\n .configureMd((md) => md.use(sup, {log}))\n .addMark(superscriptMarkName, () => ({\n spec: {\n excludes: '_',\n parseDOM: [{tag: 'sup'}],\n toDOM() {\n return ['sup'];\n },\n },\n toMd: {\n open: (state) => {\n state.escapeWhitespace = true;\n return '^';\n },\n close: (state) => {\n state.escapeWhitespace = false;\n return '^';\n },\n mixable: true,\n expelEnclosingWhitespace: true,\n },\n fromMd: {tokenSpec: {name: superscriptMarkName, type: 'mark'}},\n }));\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import log from '@diplodoc/transform/lib/log.js';
|
|
1
|
+
import { log } from '@diplodoc/transform/lib/log.js';
|
|
2
2
|
import imsize from '@diplodoc/transform/lib/plugins/imsize/index.js';
|
|
3
3
|
import isNumber from 'is-number';
|
|
4
4
|
import { imageNodeName } from "../../../markdown/Image/const.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/ImgSize/ImgSizeSpecs/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/ImgSize/ImgSizeSpecs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,gCAAgC,CAAC;AACnD,OAAO,MAAM,MAAM,iDAAiD,CAAC;AACrE,OAAO,QA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,KAAK,IAAI,MAAM,EAAE,CAAC;QAClB,OAAO,KAAK,KAAK,IAAI,EAAE,IAAI,MAAM,IAAI,EAAE,EAAE,CAAC;IAC9C,CAAC;IAED,OAAO,EAAE,CAAC;AACd,CAAC","sourcesContent":["import {log} from '@diplodoc/transform/lib/log.js';\nimport imsize from '@diplodoc/transform/lib/plugins/imsize/index.js';\nimport isNumber from 'is-number';\nimport type {NodeSpec} from 'prosemirror-model';\n\nimport type {ExtensionAuto} from '../../../../core';\nimport {imageNodeName} from '../../../markdown/Image/const';\n\nimport {ImgSizeAttr} from './const';\n\ntype ImsizeTypedAttributes = {\n [ImgSizeAttr.Src]: string;\n [ImgSizeAttr.Title]: string | null;\n [ImgSizeAttr.Alt]: string | null;\n [ImgSizeAttr.Width]: string | null;\n [ImgSizeAttr.Height]: string | null;\n [ImgSizeAttr.Loading]: string | null;\n};\n\nexport {ImgSizeAttr};\n\nexport type ImgSizeSpecsOptions = {\n /**\n * @deprecated: use placeholder option in BehaviorPreset instead.\n */\n placeholder?: NodeSpec['placeholder'];\n};\n\nexport const ImgSizeSpecs: ExtensionAuto<ImgSizeSpecsOptions> = (builder, opts) => {\n const placeholderContent = builder.context.get('placeholder')?.imgSize;\n\n builder.configureMd((md) => md.use(imsize, {log, enableInlineStyling: true}));\n builder.addNode(imageNodeName, () => ({\n spec: {\n inline: true,\n attrs: {\n [ImgSizeAttr.Src]: {},\n [ImgSizeAttr.Alt]: {default: null},\n [ImgSizeAttr.Title]: {default: null},\n [ImgSizeAttr.Height]: {default: null},\n [ImgSizeAttr.Width]: {default: null},\n [ImgSizeAttr.Loading]: {default: null},\n },\n placeholder: placeholderContent ? {content: placeholderContent} : opts.placeholder,\n group: 'inline',\n draggable: true,\n parseDOM: [\n {\n tag: 'img[src]',\n getAttrs(dom) {\n const height = (dom as Element).getAttribute(ImgSizeAttr.Height);\n const width = (dom as Element).getAttribute(ImgSizeAttr.Width);\n\n return {\n [ImgSizeAttr.Src]: (dom as Element).getAttribute(ImgSizeAttr.Src),\n [ImgSizeAttr.Alt]: (dom as Element).getAttribute(ImgSizeAttr.Alt),\n [ImgSizeAttr.Title]: (dom as Element).getAttribute(ImgSizeAttr.Title),\n [ImgSizeAttr.Loading]: (dom as Element).getAttribute(\n ImgSizeAttr.Loading,\n ),\n [ImgSizeAttr.Height]: isNumber(height) ? height : null,\n [ImgSizeAttr.Width]: isNumber(width) ? height : null,\n };\n },\n },\n ],\n toDOM(node) {\n return ['img', node.attrs];\n },\n },\n fromMd: {\n tokenSpec: {\n name: imageNodeName,\n type: 'node',\n getAttrs: (tok): ImsizeTypedAttributes => ({\n [ImgSizeAttr.Src]: tok.attrGet(ImgSizeAttr.Src)!,\n [ImgSizeAttr.Title]: tok.attrGet(ImgSizeAttr.Title),\n [ImgSizeAttr.Height]: tok.attrGet(ImgSizeAttr.Height),\n [ImgSizeAttr.Width]: tok.attrGet(ImgSizeAttr.Width),\n [ImgSizeAttr.Loading]: tok.attrGet(ImgSizeAttr.Loading),\n [ImgSizeAttr.Alt]: tok.children?.[0]?.content || null,\n }),\n },\n },\n toMd: (state, node) => {\n const attrs = node.attrs as ImsizeTypedAttributes;\n let result = ' {\n result += state.esc(attrs.src);\n }\n\n if (attrs.title) {\n result += ` ${state.quote(attrs.title)}`;\n }\n\n result += getSize(attrs);\n result += ')';\n\n state.write(result);\n },\n }));\n};\n\nfunction getSize({width, height}: ImsizeTypedAttributes): string {\n if (width || height) {\n return ` =${width || ''}x${height || ''}`;\n }\n\n return '';\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import log from '@diplodoc/transform/lib/log.js';
|
|
1
|
+
import { log } from '@diplodoc/transform/lib/log.js';
|
|
2
2
|
import yfmPlugin from '@diplodoc/transform/lib/plugins/monospace.js';
|
|
3
3
|
import { markTypeFactory } from "../../../../utils/schema.js";
|
|
4
4
|
export const monospaceMarkName = 'monospace';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/Monospace/MonospaceSpecs/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/Monospace/MonospaceSpecs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,gCAAgC,CAAC;AACnD,OAAO,SAAS,MAAM,8CAA8C,CAAC;AAGrE,OAAO,EAAC,eAAe,EAAC,oCAAiC;AAEzD,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAC7C,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC,iBAAiB,CAAC,CAAC;AAEhE,MAAM,CAAC,MAAM,cAAc,GAAkB,CAAC,OAAO,EAAE,EAAE;IACrD,OAAO;SACF,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,EAAC,GAAG,EAAC,CAAC,CAAC;SAC7C,OAAO,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,CAAC;QAC/B,IAAI,EAAE;YACF,QAAQ,EAAE,CAAC,EAAC,GAAG,EAAE,MAAM,EAAC,CAAC;YACzB,KAAK;gBACD,OAAO,CAAC,MAAM,CAAC,CAAC;YACpB,CAAC;SACJ;QACD,MAAM,EAAE;YACJ,SAAS,EAAE;gBACP,IAAI,EAAE,iBAAiB;gBACvB,IAAI,EAAE,MAAM;aACf;SACJ;QACD,IAAI,EAAE;YACF,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,IAAI;YACb,wBAAwB,EAAE,IAAI;SACjC;KACJ,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import {log} from '@diplodoc/transform/lib/log.js';\nimport yfmPlugin from '@diplodoc/transform/lib/plugins/monospace.js';\n\nimport type {ExtensionAuto} from '../../../../core';\nimport {markTypeFactory} from '../../../../utils/schema';\n\nexport const monospaceMarkName = 'monospace';\nexport const monospaceType = markTypeFactory(monospaceMarkName);\n\nexport const MonospaceSpecs: ExtensionAuto = (builder) => {\n builder\n .configureMd((md) => md.use(yfmPlugin, {log}))\n .addMark(monospaceMarkName, () => ({\n spec: {\n parseDOM: [{tag: 'samp'}],\n toDOM() {\n return ['samp'];\n },\n },\n fromMd: {\n tokenSpec: {\n name: monospaceMarkName,\n type: 'mark',\n },\n },\n toMd: {\n open: '##',\n close: '##',\n mixable: true,\n expelEnclosingWhitespace: true,\n },\n }));\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import log from '@diplodoc/transform/lib/log.js';
|
|
1
|
+
import { log } from '@diplodoc/transform/lib/log.js';
|
|
2
2
|
import { VideoAttr, videoNodeName } from "./const.js";
|
|
3
3
|
import { VideoService, defaults, videoPlugin, } from "./md-video.js";
|
|
4
4
|
import { createViewStub, serializeNodeToString } from "./utils.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/Video/VideoSpecs/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/Video/VideoSpecs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,gCAAgC,CAAC;AAInD,OAAO,EAAC,SAAS,EAAE,aAAa,EAAC,mBAAgB;AACjD,OAAO,EAEH,YAAY,EAEZ,QAAQ,EACR,WAAW,GACd,sBAAmB;AACpB,OAAO,EAAC,cAAc,EAAE,qBAAqB,EAAC,mBAAgB;AAE9D,+BAA+B;AAC/B,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC;IACnD,YAAY,CAAC,OAAO;IACpB,YAAY,CAAC,KAAK;IAClB,YAAY,CAAC,IAAI;IACjB,YAAY,CAAC,KAAK;CACrB,C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C;gBACN,CAAC;gBAED,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;YAChC,CAAC;SACJ;QACD,MAAM,EAAE;YACJ,SAAS,EAAE;gBACP,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;oBAChB,CAAC,SAAS,CAAC,OAAO,CAAC,EAAG,GAAkB,CAAC,OAAO;oBAChD,CAAC,SAAS,CAAC,OAAO,CAAC,EAAG,GAAkB,CAAC,OAAO;iBACnD,CAAC;aACL;SACJ;QACD,IAAI,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAClB,KAAK,CAAC,KAAK,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7C,CAAC;KACJ,CAAC,CAAC,CAAC;AACR,CAAC,CAAC","sourcesContent":["import {log} from '@diplodoc/transform/lib/log.js';\n\nimport type {ExtensionAuto} from '../../../../core';\n\nimport {VideoAttr, videoNodeName} from './const';\nimport {\n type VideoPluginOptions,\n VideoService,\n type VideoToken,\n defaults,\n videoPlugin,\n} from './md-video';\nimport {createViewStub, serializeNodeToString} from './utils';\n\n// we don't support osf service\nconst availableServices: ReadonlySet<string> = new Set([\n VideoService.YouTube,\n VideoService.Vimeo,\n VideoService.Vine,\n VideoService.Prezi,\n]);\n\nexport {videoNodeName} from './const';\nexport {videoType} from './utils';\n\nexport type VideoSpecsOptions = VideoPluginOptions & {};\n\nexport const VideoSpecs: ExtensionAuto<VideoSpecsOptions> = (builder, opts) => {\n const options = {...defaults, ...opts, log};\n\n builder.configureMd((md) => md.use(videoPlugin, options));\n builder.addNode(videoNodeName, () => ({\n spec: {\n inline: true,\n atom: true,\n group: 'inline',\n attrs: {[VideoAttr.Service]: {}, [VideoAttr.VideoID]: {}},\n parseDOM: [\n {\n tag: `span[${VideoAttr.Service}][${VideoAttr.VideoID}]`,\n getAttrs(dom) {\n const domElem = dom as HTMLElement;\n return {\n [VideoAttr.Service]: domElem.getAttribute(VideoAttr.Service),\n [VideoAttr.VideoID]: domElem.getAttribute(VideoAttr.VideoID),\n };\n },\n },\n {\n tag: `iframe[${VideoAttr.Service}][${VideoAttr.VideoID}]`,\n getAttrs(dom) {\n const domElem = dom as HTMLElement;\n return {\n [VideoAttr.Service]: domElem.getAttribute(VideoAttr.Service),\n [VideoAttr.VideoID]: domElem.getAttribute(VideoAttr.VideoID),\n };\n },\n priority: 100,\n },\n ],\n toDOM(node) {\n const service = node.attrs[VideoAttr.Service];\n const videoId = node.attrs[VideoAttr.VideoID];\n\n if (availableServices.has(service) || !videoId) {\n let src = '';\n if (typeof options.videoUrl === 'function') {\n src = options.videoUrl(service, videoId, options);\n }\n return [\n 'div',\n {\n class: 'embed-responsive embed-responsive-16by9',\n },\n [\n 'iframe',\n {\n class: `embed-responsive-item ${service}-player`,\n type: 'text/html',\n width: String(options[service as VideoService].width),\n height: String(options[service as VideoService].height),\n src: src,\n frameborder: '0',\n webkitallowfullscreen: '',\n mozallowfullscreen: '',\n allowfullscreen: '',\n [VideoAttr.Service]: service,\n [VideoAttr.VideoID]: videoId,\n },\n ],\n ];\n }\n\n return createViewStub(node);\n },\n },\n fromMd: {\n tokenSpec: {\n name: videoNodeName,\n type: 'node',\n getAttrs: (tok) => ({\n [VideoAttr.Service]: (tok as VideoToken).service,\n [VideoAttr.VideoID]: (tok as VideoToken).videoID,\n }),\n },\n },\n toMd: (state, node) => {\n state.write(serializeNodeToString(node));\n },\n }));\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAA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AW,EAAE,GAAG,EAAE,CAAC,CAAC;QAClC,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC;QACvC,IAAI,EAAE,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC5C,MAAM,EAAE;YACJ,SAAS,EAAE,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC;SAChD;KACJ,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import {log} from '@diplodoc/transform/lib/log.js';\nimport yfmPlugin from '@diplodoc/transform/lib/plugins/notes/index.js';\nimport type {NodeSpec} from 'prosemirror-model';\n\nimport type {ExtensionAuto} from '../../../../core';\n\nimport {NoteNode} from './const';\nimport {parserTokens} from './parser';\nimport {getSchemaSpecs} from './schema';\nimport {serializerTokens} from './serializer';\n\nexport {NoteNode as YfmNoteNode} from './const';\nexport {noteType, noteTitleType} from './utils';\n\nexport type YfmNoteSpecsOptions = {\n /**\n * @deprecated: use placeholder option in BehaviorPreset instead.\n */\n yfmNoteTitlePlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];\n};\n\nexport const YfmNoteSpecs: ExtensionAuto<YfmNoteSpecsOptions> = (builder, opts) => {\n const schemaSpecs = getSchemaSpecs(opts, builder.context.get('placeholder'));\n\n builder\n .configureMd((md) => md.use(yfmPlugin, {log}))\n .addNode(NoteNode.Note, () => ({\n spec: schemaSpecs[NoteNode.Note],\n toMd: serializerTokens[NoteNode.Note],\n fromMd: {\n tokenSpec: parserTokens[NoteNode.Note],\n },\n }))\n .addNode(NoteNode.NoteTitle, () => ({\n spec: schemaSpecs[NoteNode.NoteTitle],\n toMd: serializerTokens[NoteNode.NoteTitle],\n fromMd: {\n tokenSpec: parserTokens[NoteNode.NoteTitle],\n },\n }))\n .addNode(NoteNode.NoteContent, () => ({\n spec: schemaSpecs[NoteNode.NoteContent],\n toMd: serializerTokens[NoteNode.NoteContent],\n fromMd: {\n tokenSpec: parserTokens[NoteNode.NoteContent],\n },\n }));\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmTable/YfmTableSpecs/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmTable/YfmTableSpecs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,gCAAgC,CAAC;AACnD,OAAO,QAAQ,MAAM,gDAAgD,CAAC;AAItE,OAAO,EAAC,YAAY,EAAC,mBAAgB;AACrC,OAAO,EAAC,YAAY,EAAC,oBAAiB;AACtC,OAAO,EAA6B,cAAc,EAAC,oBAAiB;AACpE,OAAO,EAAC,gBAAgB,EAAC,wBAAqB;AAE9C,OAAO,EAAC,YAAY,EAAC,mBAAgB;AACrC,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAC,mBAAgB;AAI1F,MAAM,CAAC,MAAM,aAAa,GAA+C,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;IAC1F,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;IAEhF,OAAO;SACF,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAC,GAAG,EAAC,CAAC,CAAC;SAC5C,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QAChC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC;QACrC,IAAI,EAAE,gBAAgB,CAAC,YAAY,CAAC,KAAK,CAAC;QAC1C,MAAM,EAAE,EAAC,SAAS,EAAE,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,EAAC;KACxD,CAAC,CAAC;SACF,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;QAC/B,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC;QACpC,IAAI,EAAE,gBAAgB,CAAC,YAAY,CAAC,IAAI,CAAC;QACzC,MAAM,EAAE,EAAC,SAAS,EAAE,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,EAAC;KACvD,CAAC,CAAC;SACF,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC;QACnC,IAAI,EAAE,gBAAgB,CAAC,YAAY,CAAC,GAAG,CAAC;QACxC,MAAM,EAAE,EAAC,SAAS,EAAE,YAAY,CAAC,YAAY,CAAC,GAAG,CAAC,EAAC;KACtD,CAAC,CAAC;SACF,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;QAC/B,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC;QACpC,IAAI,EAAE,gBAAgB,CAAC,YAAY,CAAC,IAAI,CAAC;QACzC,MAAM,EAAE,EAAC,SAAS,EAAE,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,EAAC;KACvD,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import {log} from '@diplodoc/transform/lib/log.js';\nimport yfmTable from '@diplodoc/transform/lib/plugins/table/index.js';\n\nimport type {ExtensionWithOptions} from '../../../../core';\n\nimport {YfmTableNode} from './const';\nimport {parserTokens} from './parser';\nimport {type YfmTableSchemaOptions, getSchemaSpecs} from './schema';\nimport {serializerTokens} from './serializer';\n\nexport {YfmTableNode} from './const';\nexport {yfmTableType, yfmTableBodyType, yfmTableRowType, yfmTableCellType} from './utils';\n\nexport type YfmTableSpecsOptions = YfmTableSchemaOptions & {};\n\nexport const YfmTableSpecs: ExtensionWithOptions<YfmTableSpecsOptions> = (builder, options) => {\n const schemaSpecs = getSchemaSpecs(options, builder.context.get('placeholder'));\n\n builder\n .configureMd((md) => md.use(yfmTable, {log}))\n .addNode(YfmTableNode.Table, () => ({\n spec: schemaSpecs[YfmTableNode.Table],\n toMd: serializerTokens[YfmTableNode.Table],\n fromMd: {tokenSpec: parserTokens[YfmTableNode.Table]},\n }))\n .addNode(YfmTableNode.Body, () => ({\n spec: schemaSpecs[YfmTableNode.Body],\n toMd: serializerTokens[YfmTableNode.Body],\n fromMd: {tokenSpec: parserTokens[YfmTableNode.Body]},\n }))\n .addNode(YfmTableNode.Row, () => ({\n spec: schemaSpecs[YfmTableNode.Row],\n toMd: serializerTokens[YfmTableNode.Row],\n fromMd: {tokenSpec: parserTokens[YfmTableNode.Row]},\n }))\n .addNode(YfmTableNode.Cell, () => ({\n spec: schemaSpecs[YfmTableNode.Cell],\n toMd: serializerTokens[YfmTableNode.Cell],\n fromMd: {tokenSpec: parserTokens[YfmTableNode.Cell]},\n }));\n};\n"]}
|
package/build/esm/version.js
CHANGED
package/build/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"../../src","sources":["version.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC","sourcesContent":["/** During build process, the current version will be injected here */\nexport const VERSION = typeof '15.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"../../src","sources":["version.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC","sourcesContent":["/** During build process, the current version will be injected here */\nexport const VERSION = typeof '15.9.0' !== 'undefined' ? '15.9.0' : 'unknown';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/markdown-editor",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.9.0",
|
|
4
4
|
"description": "Markdown wysiwyg and markup editor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"prepublishOnly": "npm run lint && npm run build",
|
|
34
34
|
"playwright:install": "playwright install chromium webkit --with-deps",
|
|
35
35
|
"playwright": "playwright test --config=tests/playwright/playwright.config.ts",
|
|
36
|
+
"playwright:generate": "node scripts/generate-playwright-test.js",
|
|
36
37
|
"playwright:watch": "npm run playwright -- --ui",
|
|
37
38
|
"playwright:update": "npm run playwright -- -u",
|
|
38
39
|
"playwright:clear": "rm -rf ./tests/playwright/.cache",
|