@gravity-ui/markdown-editor 13.21.2 → 13.21.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/bundle/Editor.js +17 -16
- package/build/cjs/extensions/behavior/SelectionContext/index.js +5 -3
- package/build/cjs/version.js +1 -1
- package/build/esm/bundle/Editor.js +17 -16
- package/build/esm/extensions/behavior/SelectionContext/index.js +5 -3
- package/build/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -267,7 +267,7 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
267
267
|
let cmLine = line + 1; // lines in codemirror is 1-based
|
|
268
268
|
cmLine = Math.max(cmLine, 1);
|
|
269
269
|
cmLine = Math.min(cmLine, view.state.doc.lines);
|
|
270
|
-
const yMargin = getTopOffset();
|
|
270
|
+
const yMargin = getTopOffset(view.dom);
|
|
271
271
|
const anchor = view.state.doc.line(cmLine).from;
|
|
272
272
|
view.dispatch({
|
|
273
273
|
scrollIntoView: true,
|
|
@@ -278,24 +278,16 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
278
278
|
});
|
|
279
279
|
break;
|
|
280
280
|
// eslint-disable-next-line no-inner-declarations
|
|
281
|
-
function getTopOffset() {
|
|
282
|
-
const TOOLBAR_HEIGHT = 36; //px
|
|
283
|
-
const TOOLBAR_BOTTOM_OFFSET = 8; // px
|
|
284
|
-
const TOOLBAR_TOP_ADDITIONAL_OFFSET = 8; // px
|
|
285
|
-
const TOOLBAR_TOP_OFFSET_VAR = '--g-md-toolbar-sticky-offset';
|
|
286
|
-
const topOffsetValue = window
|
|
287
|
-
.getComputedStyle(view.dom)
|
|
288
|
-
.getPropertyValue(TOOLBAR_TOP_OFFSET_VAR);
|
|
289
|
-
const toolbarTopOffset = calculateCSSNumberValue(topOffsetValue) + TOOLBAR_TOP_ADDITIONAL_OFFSET;
|
|
290
|
-
return toolbarTopOffset + TOOLBAR_HEIGHT + TOOLBAR_BOTTOM_OFFSET;
|
|
291
|
-
}
|
|
292
281
|
}
|
|
293
282
|
case 'wysiwyg': {
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
const
|
|
283
|
+
const elem = this.wysiwygEditor.dom.querySelector(`[data-line="${line}"]`);
|
|
284
|
+
if (elem) {
|
|
285
|
+
const elemTop = elem.getBoundingClientRect().top;
|
|
286
|
+
const topOffset = getTopOffset(this.wysiwygEditor.dom);
|
|
287
|
+
window.scrollTo({ top: elemTop + window.scrollY - topOffset });
|
|
288
|
+
const position = this._wysiwygView.posAtDOM(elem, 0);
|
|
297
289
|
const { tr } = this._wysiwygView.state;
|
|
298
|
-
this._wysiwygView.dispatch(tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, position))
|
|
290
|
+
this._wysiwygView.dispatch(tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, position)));
|
|
299
291
|
}
|
|
300
292
|
break;
|
|
301
293
|
}
|
|
@@ -311,6 +303,15 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
311
303
|
}
|
|
312
304
|
exports.EditorImpl = EditorImpl;
|
|
313
305
|
_EditorImpl_markup = new WeakMap(), _EditorImpl_editorMode = new WeakMap(), _EditorImpl_toolbarVisible = new WeakMap(), _EditorImpl_splitModeEnabled = new WeakMap(), _EditorImpl_splitMode = new WeakMap(), _EditorImpl_renderPreview = new WeakMap(), _EditorImpl_wysiwygEditor = new WeakMap(), _EditorImpl_markupEditor = new WeakMap(), _EditorImpl_markupConfig = new WeakMap(), _EditorImpl_escapeConfig = new WeakMap(), _EditorImpl_preset = new WeakMap(), _EditorImpl_allowHTML = new WeakMap(), _EditorImpl_linkify = new WeakMap(), _EditorImpl_linkifyTlds = new WeakMap(), _EditorImpl_extensions = new WeakMap(), _EditorImpl_renderStorage = new WeakMap(), _EditorImpl_fileUploadHandler = new WeakMap(), _EditorImpl_needToSetDimensionsForUploadedImages = new WeakMap(), _EditorImpl_prepareRawMarkup = new WeakMap(), _EditorImpl_beforeEditorModeChange = new WeakMap();
|
|
306
|
+
function getTopOffset(elem) {
|
|
307
|
+
const TOOLBAR_HEIGHT = 36; //px
|
|
308
|
+
const TOOLBAR_BOTTOM_OFFSET = 8; // px
|
|
309
|
+
const TOOLBAR_TOP_ADDITIONAL_OFFSET = 8; // px
|
|
310
|
+
const TOOLBAR_TOP_OFFSET_VAR = '--g-md-toolbar-sticky-offset';
|
|
311
|
+
const topOffsetValue = window.getComputedStyle(elem).getPropertyValue(TOOLBAR_TOP_OFFSET_VAR);
|
|
312
|
+
const toolbarTopOffset = calculateCSSNumberValue(topOffsetValue) + TOOLBAR_TOP_ADDITIONAL_OFFSET;
|
|
313
|
+
return toolbarTopOffset + TOOLBAR_HEIGHT + TOOLBAR_BOTTOM_OFFSET;
|
|
314
|
+
}
|
|
314
315
|
function calculateCSSNumberValue(cssValue) {
|
|
315
316
|
const tmp = document.createElement('div');
|
|
316
317
|
tmp.style.position = 'absolute';
|
|
@@ -33,6 +33,10 @@ class SelectionTooltip {
|
|
|
33
33
|
}),
|
|
34
34
|
handleDOMEvents: {
|
|
35
35
|
mousedown: (view) => {
|
|
36
|
+
const startState = {
|
|
37
|
+
doc: view.state.doc,
|
|
38
|
+
selection: view.state.selection,
|
|
39
|
+
};
|
|
36
40
|
this._isMousePressed = true;
|
|
37
41
|
this.cancelTooltipHiding();
|
|
38
42
|
this.tooltip.hide(view);
|
|
@@ -40,7 +44,7 @@ class SelectionTooltip {
|
|
|
40
44
|
if (this.destroyed)
|
|
41
45
|
return;
|
|
42
46
|
this._isMousePressed = false;
|
|
43
|
-
this.update(view,
|
|
47
|
+
this.update(view, startState);
|
|
44
48
|
};
|
|
45
49
|
document.addEventListener('mouseup', onMouseUp, { once: true });
|
|
46
50
|
},
|
|
@@ -59,10 +63,8 @@ class SelectionTooltip {
|
|
|
59
63
|
};
|
|
60
64
|
}
|
|
61
65
|
update(view, prevState) {
|
|
62
|
-
this._prevState = prevState;
|
|
63
66
|
if (this._isMousePressed)
|
|
64
67
|
return;
|
|
65
|
-
this._prevState = null;
|
|
66
68
|
this.cancelTooltipHiding();
|
|
67
69
|
// Don't show tooltip if editor not mounted to the DOM
|
|
68
70
|
// or when view is out of focus
|
package/build/cjs/version.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
/** During build process, the current version will be injected here */
|
|
5
|
-
exports.VERSION = typeof '13.21.
|
|
5
|
+
exports.VERSION = typeof '13.21.4' !== 'undefined' ? '13.21.4' : 'unknown';
|
|
@@ -264,7 +264,7 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
264
264
|
let cmLine = line + 1; // lines in codemirror is 1-based
|
|
265
265
|
cmLine = Math.max(cmLine, 1);
|
|
266
266
|
cmLine = Math.min(cmLine, view.state.doc.lines);
|
|
267
|
-
const yMargin = getTopOffset();
|
|
267
|
+
const yMargin = getTopOffset(view.dom);
|
|
268
268
|
const anchor = view.state.doc.line(cmLine).from;
|
|
269
269
|
view.dispatch({
|
|
270
270
|
scrollIntoView: true,
|
|
@@ -275,24 +275,16 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
275
275
|
});
|
|
276
276
|
break;
|
|
277
277
|
// eslint-disable-next-line no-inner-declarations
|
|
278
|
-
function getTopOffset() {
|
|
279
|
-
const TOOLBAR_HEIGHT = 36; //px
|
|
280
|
-
const TOOLBAR_BOTTOM_OFFSET = 8; // px
|
|
281
|
-
const TOOLBAR_TOP_ADDITIONAL_OFFSET = 8; // px
|
|
282
|
-
const TOOLBAR_TOP_OFFSET_VAR = '--g-md-toolbar-sticky-offset';
|
|
283
|
-
const topOffsetValue = window
|
|
284
|
-
.getComputedStyle(view.dom)
|
|
285
|
-
.getPropertyValue(TOOLBAR_TOP_OFFSET_VAR);
|
|
286
|
-
const toolbarTopOffset = calculateCSSNumberValue(topOffsetValue) + TOOLBAR_TOP_ADDITIONAL_OFFSET;
|
|
287
|
-
return toolbarTopOffset + TOOLBAR_HEIGHT + TOOLBAR_BOTTOM_OFFSET;
|
|
288
|
-
}
|
|
289
278
|
}
|
|
290
279
|
case 'wysiwyg': {
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
293
|
-
const
|
|
280
|
+
const elem = this.wysiwygEditor.dom.querySelector(`[data-line="${line}"]`);
|
|
281
|
+
if (elem) {
|
|
282
|
+
const elemTop = elem.getBoundingClientRect().top;
|
|
283
|
+
const topOffset = getTopOffset(this.wysiwygEditor.dom);
|
|
284
|
+
window.scrollTo({ top: elemTop + window.scrollY - topOffset });
|
|
285
|
+
const position = this._wysiwygView.posAtDOM(elem, 0);
|
|
294
286
|
const { tr } = this._wysiwygView.state;
|
|
295
|
-
this._wysiwygView.dispatch(tr.setSelection(TextSelection.create(tr.doc, position))
|
|
287
|
+
this._wysiwygView.dispatch(tr.setSelection(TextSelection.create(tr.doc, position)));
|
|
296
288
|
}
|
|
297
289
|
break;
|
|
298
290
|
}
|
|
@@ -307,6 +299,15 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
307
299
|
}
|
|
308
300
|
}
|
|
309
301
|
_EditorImpl_markup = new WeakMap(), _EditorImpl_editorMode = new WeakMap(), _EditorImpl_toolbarVisible = new WeakMap(), _EditorImpl_splitModeEnabled = new WeakMap(), _EditorImpl_splitMode = new WeakMap(), _EditorImpl_renderPreview = new WeakMap(), _EditorImpl_wysiwygEditor = new WeakMap(), _EditorImpl_markupEditor = new WeakMap(), _EditorImpl_markupConfig = new WeakMap(), _EditorImpl_escapeConfig = new WeakMap(), _EditorImpl_preset = new WeakMap(), _EditorImpl_allowHTML = new WeakMap(), _EditorImpl_linkify = new WeakMap(), _EditorImpl_linkifyTlds = new WeakMap(), _EditorImpl_extensions = new WeakMap(), _EditorImpl_renderStorage = new WeakMap(), _EditorImpl_fileUploadHandler = new WeakMap(), _EditorImpl_needToSetDimensionsForUploadedImages = new WeakMap(), _EditorImpl_prepareRawMarkup = new WeakMap(), _EditorImpl_beforeEditorModeChange = new WeakMap();
|
|
302
|
+
function getTopOffset(elem) {
|
|
303
|
+
const TOOLBAR_HEIGHT = 36; //px
|
|
304
|
+
const TOOLBAR_BOTTOM_OFFSET = 8; // px
|
|
305
|
+
const TOOLBAR_TOP_ADDITIONAL_OFFSET = 8; // px
|
|
306
|
+
const TOOLBAR_TOP_OFFSET_VAR = '--g-md-toolbar-sticky-offset';
|
|
307
|
+
const topOffsetValue = window.getComputedStyle(elem).getPropertyValue(TOOLBAR_TOP_OFFSET_VAR);
|
|
308
|
+
const toolbarTopOffset = calculateCSSNumberValue(topOffsetValue) + TOOLBAR_TOP_ADDITIONAL_OFFSET;
|
|
309
|
+
return toolbarTopOffset + TOOLBAR_HEIGHT + TOOLBAR_BOTTOM_OFFSET;
|
|
310
|
+
}
|
|
310
311
|
function calculateCSSNumberValue(cssValue) {
|
|
311
312
|
const tmp = document.createElement('div');
|
|
312
313
|
tmp.style.position = 'absolute';
|
|
@@ -29,6 +29,10 @@ class SelectionTooltip {
|
|
|
29
29
|
}),
|
|
30
30
|
handleDOMEvents: {
|
|
31
31
|
mousedown: (view) => {
|
|
32
|
+
const startState = {
|
|
33
|
+
doc: view.state.doc,
|
|
34
|
+
selection: view.state.selection,
|
|
35
|
+
};
|
|
32
36
|
this._isMousePressed = true;
|
|
33
37
|
this.cancelTooltipHiding();
|
|
34
38
|
this.tooltip.hide(view);
|
|
@@ -36,7 +40,7 @@ class SelectionTooltip {
|
|
|
36
40
|
if (this.destroyed)
|
|
37
41
|
return;
|
|
38
42
|
this._isMousePressed = false;
|
|
39
|
-
this.update(view,
|
|
43
|
+
this.update(view, startState);
|
|
40
44
|
};
|
|
41
45
|
document.addEventListener('mouseup', onMouseUp, { once: true });
|
|
42
46
|
},
|
|
@@ -55,10 +59,8 @@ class SelectionTooltip {
|
|
|
55
59
|
};
|
|
56
60
|
}
|
|
57
61
|
update(view, prevState) {
|
|
58
|
-
this._prevState = prevState;
|
|
59
62
|
if (this._isMousePressed)
|
|
60
63
|
return;
|
|
61
|
-
this._prevState = null;
|
|
62
64
|
this.cancelTooltipHiding();
|
|
63
65
|
// Don't show tooltip if editor not mounted to the DOM
|
|
64
66
|
// or when view is out of focus
|
package/build/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** During build process, the current version will be injected here */
|
|
2
|
-
export const VERSION = typeof '13.21.
|
|
2
|
+
export const VERSION = typeof '13.21.4' !== 'undefined' ? '13.21.4' : 'unknown';
|