@gravity-ui/markdown-editor 13.15.0 → 13.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/bundle/Editor.js +30 -1
- package/build/cjs/extensions/yfm/YfmHtmlBlock/utils.js +19 -0
- package/build/cjs/version.js +1 -1
- package/build/esm/bundle/Editor.js +30 -1
- package/build/esm/extensions/yfm/YfmHtmlBlock/utils.js +19 -0
- package/build/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ var _EditorImpl_markup, _EditorImpl_editorMode, _EditorImpl_toolbarVisible, _Edi
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.EditorImpl = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
+
const view_1 = require("@codemirror/view");
|
|
6
7
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
7
8
|
const core_1 = require("../core");
|
|
8
9
|
const bundle_1 = require("../i18n/bundle");
|
|
@@ -265,11 +266,28 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
265
266
|
let cmLine = line + 1; // lines in codemirror is 1-based
|
|
266
267
|
cmLine = Math.max(cmLine, 1);
|
|
267
268
|
cmLine = Math.min(cmLine, view.state.doc.lines);
|
|
269
|
+
const yMargin = getTopOffset();
|
|
270
|
+
const anchor = view.state.doc.line(cmLine).from;
|
|
268
271
|
view.dispatch({
|
|
269
272
|
scrollIntoView: true,
|
|
270
|
-
selection: { anchor
|
|
273
|
+
selection: { anchor },
|
|
274
|
+
effects: [
|
|
275
|
+
view_1.EditorView.scrollIntoView(anchor, { y: 'start', x: 'start', yMargin }),
|
|
276
|
+
],
|
|
271
277
|
});
|
|
272
278
|
break;
|
|
279
|
+
// eslint-disable-next-line no-inner-declarations
|
|
280
|
+
function getTopOffset() {
|
|
281
|
+
const TOOLBAR_HEIGHT = 36; //px
|
|
282
|
+
const TOOLBAR_BOTTOM_OFFSET = 8; // px
|
|
283
|
+
const TOOLBAR_TOP_ADDITIONAL_OFFSET = 8; // px
|
|
284
|
+
const TOOLBAR_TOP_OFFSET_VAR = '--g-md-toolbar-sticky-offset';
|
|
285
|
+
const topOffsetValue = window
|
|
286
|
+
.getComputedStyle(view.dom)
|
|
287
|
+
.getPropertyValue(TOOLBAR_TOP_OFFSET_VAR);
|
|
288
|
+
const toolbarTopOffset = calculateCSSNumberValue(topOffsetValue) + TOOLBAR_TOP_ADDITIONAL_OFFSET;
|
|
289
|
+
return toolbarTopOffset + TOOLBAR_HEIGHT + TOOLBAR_BOTTOM_OFFSET;
|
|
290
|
+
}
|
|
273
291
|
}
|
|
274
292
|
case 'wysiwyg': {
|
|
275
293
|
const node = this.wysiwygEditor.dom.querySelector(`[data-line="${line}"]`);
|
|
@@ -292,3 +310,14 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
292
310
|
}
|
|
293
311
|
exports.EditorImpl = EditorImpl;
|
|
294
312
|
_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();
|
|
313
|
+
function calculateCSSNumberValue(cssValue) {
|
|
314
|
+
const tmp = document.createElement('div');
|
|
315
|
+
tmp.style.position = 'absolute';
|
|
316
|
+
tmp.style.top = '-99999px';
|
|
317
|
+
tmp.style.left = '-99999px';
|
|
318
|
+
tmp.style.width = `calc(${cssValue})`;
|
|
319
|
+
document.body.appendChild(tmp);
|
|
320
|
+
const value = tmp.getBoundingClientRect().width;
|
|
321
|
+
tmp.remove();
|
|
322
|
+
return value;
|
|
323
|
+
}
|
|
@@ -6,6 +6,7 @@ const sanitize_1 = tslib_1.__importDefault(require("@diplodoc/transform/lib/sani
|
|
|
6
6
|
// yfmHtmlBlock additional css properties white list
|
|
7
7
|
const getYfmHtmlBlockWhiteList = () => {
|
|
8
8
|
const whiteList = {};
|
|
9
|
+
// flex, grid, column
|
|
9
10
|
whiteList['align-content'] = true; // default: auto
|
|
10
11
|
whiteList['align-items'] = true; // default: auto
|
|
11
12
|
whiteList['align-self'] = true; // default: auto
|
|
@@ -51,6 +52,24 @@ const getYfmHtmlBlockWhiteList = () => {
|
|
|
51
52
|
whiteList.order = true; // default: 0
|
|
52
53
|
whiteList.orphans = true; // default: 2
|
|
53
54
|
whiteList['row-gap'] = true;
|
|
55
|
+
// position, opacity, overflow
|
|
56
|
+
whiteList['all'] = true; // default: depending on individual properties
|
|
57
|
+
whiteList['bottom'] = true; // default: auto
|
|
58
|
+
whiteList['content'] = true; // default: normal
|
|
59
|
+
whiteList['cursor'] = true; // default: auto
|
|
60
|
+
whiteList['direction'] = true; // default: ltr
|
|
61
|
+
whiteList['left'] = true; // default: auto
|
|
62
|
+
whiteList['line-break'] = true; // default: auto
|
|
63
|
+
whiteList['opacity'] = true; // default: 1
|
|
64
|
+
whiteList['overflow'] = true; // default: depending on individual properties
|
|
65
|
+
whiteList['overflow-wrap'] = true; // default: normal
|
|
66
|
+
whiteList['overflow-x'] = true; // default: visible
|
|
67
|
+
whiteList['overflow-y'] = true; // default: visible
|
|
68
|
+
whiteList['position'] = true; // default: static
|
|
69
|
+
whiteList['right'] = true; // default: auto
|
|
70
|
+
whiteList['top'] = true; // default: auto
|
|
71
|
+
whiteList['white-space'] = true; // default: normal
|
|
72
|
+
whiteList['z-index'] = true; // default: auto
|
|
54
73
|
return whiteList;
|
|
55
74
|
};
|
|
56
75
|
// yfmHtmlBlock additional allowedTags
|
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.
|
|
5
|
+
exports.VERSION = typeof '13.16.0' !== 'undefined' ? '13.16.0' : 'unknown';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var _EditorImpl_markup, _EditorImpl_editorMode, _EditorImpl_toolbarVisible, _EditorImpl_splitModeEnabled, _EditorImpl_splitMode, _EditorImpl_renderPreview, _EditorImpl_wysiwygEditor, _EditorImpl_markupEditor, _EditorImpl_markupConfig, _EditorImpl_escapeConfig, _EditorImpl_preset, _EditorImpl_allowHTML, _EditorImpl_linkify, _EditorImpl_linkifyTlds, _EditorImpl_extensions, _EditorImpl_renderStorage, _EditorImpl_fileUploadHandler, _EditorImpl_needToSetDimensionsForUploadedImages, _EditorImpl_prepareRawMarkup, _EditorImpl_beforeEditorModeChange;
|
|
2
2
|
import { __classPrivateFieldGet, __classPrivateFieldSet, __rest } from "tslib";
|
|
3
|
+
import { EditorView as CMEditorView } from '@codemirror/view';
|
|
3
4
|
import { TextSelection } from 'prosemirror-state';
|
|
4
5
|
import { WysiwygEditor } from '../core';
|
|
5
6
|
import { i18n } from '../i18n/bundle';
|
|
@@ -262,11 +263,28 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
262
263
|
let cmLine = line + 1; // lines in codemirror is 1-based
|
|
263
264
|
cmLine = Math.max(cmLine, 1);
|
|
264
265
|
cmLine = Math.min(cmLine, view.state.doc.lines);
|
|
266
|
+
const yMargin = getTopOffset();
|
|
267
|
+
const anchor = view.state.doc.line(cmLine).from;
|
|
265
268
|
view.dispatch({
|
|
266
269
|
scrollIntoView: true,
|
|
267
|
-
selection: { anchor
|
|
270
|
+
selection: { anchor },
|
|
271
|
+
effects: [
|
|
272
|
+
CMEditorView.scrollIntoView(anchor, { y: 'start', x: 'start', yMargin }),
|
|
273
|
+
],
|
|
268
274
|
});
|
|
269
275
|
break;
|
|
276
|
+
// eslint-disable-next-line no-inner-declarations
|
|
277
|
+
function getTopOffset() {
|
|
278
|
+
const TOOLBAR_HEIGHT = 36; //px
|
|
279
|
+
const TOOLBAR_BOTTOM_OFFSET = 8; // px
|
|
280
|
+
const TOOLBAR_TOP_ADDITIONAL_OFFSET = 8; // px
|
|
281
|
+
const TOOLBAR_TOP_OFFSET_VAR = '--g-md-toolbar-sticky-offset';
|
|
282
|
+
const topOffsetValue = window
|
|
283
|
+
.getComputedStyle(view.dom)
|
|
284
|
+
.getPropertyValue(TOOLBAR_TOP_OFFSET_VAR);
|
|
285
|
+
const toolbarTopOffset = calculateCSSNumberValue(topOffsetValue) + TOOLBAR_TOP_ADDITIONAL_OFFSET;
|
|
286
|
+
return toolbarTopOffset + TOOLBAR_HEIGHT + TOOLBAR_BOTTOM_OFFSET;
|
|
287
|
+
}
|
|
270
288
|
}
|
|
271
289
|
case 'wysiwyg': {
|
|
272
290
|
const node = this.wysiwygEditor.dom.querySelector(`[data-line="${line}"]`);
|
|
@@ -288,3 +306,14 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
288
306
|
}
|
|
289
307
|
}
|
|
290
308
|
_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();
|
|
309
|
+
function calculateCSSNumberValue(cssValue) {
|
|
310
|
+
const tmp = document.createElement('div');
|
|
311
|
+
tmp.style.position = 'absolute';
|
|
312
|
+
tmp.style.top = '-99999px';
|
|
313
|
+
tmp.style.left = '-99999px';
|
|
314
|
+
tmp.style.width = `calc(${cssValue})`;
|
|
315
|
+
document.body.appendChild(tmp);
|
|
316
|
+
const value = tmp.getBoundingClientRect().width;
|
|
317
|
+
tmp.remove();
|
|
318
|
+
return value;
|
|
319
|
+
}
|
|
@@ -2,6 +2,7 @@ import diplodocSanitize from '@diplodoc/transform/lib/sanitize';
|
|
|
2
2
|
// yfmHtmlBlock additional css properties white list
|
|
3
3
|
const getYfmHtmlBlockWhiteList = () => {
|
|
4
4
|
const whiteList = {};
|
|
5
|
+
// flex, grid, column
|
|
5
6
|
whiteList['align-content'] = true; // default: auto
|
|
6
7
|
whiteList['align-items'] = true; // default: auto
|
|
7
8
|
whiteList['align-self'] = true; // default: auto
|
|
@@ -47,6 +48,24 @@ const getYfmHtmlBlockWhiteList = () => {
|
|
|
47
48
|
whiteList.order = true; // default: 0
|
|
48
49
|
whiteList.orphans = true; // default: 2
|
|
49
50
|
whiteList['row-gap'] = true;
|
|
51
|
+
// position, opacity, overflow
|
|
52
|
+
whiteList['all'] = true; // default: depending on individual properties
|
|
53
|
+
whiteList['bottom'] = true; // default: auto
|
|
54
|
+
whiteList['content'] = true; // default: normal
|
|
55
|
+
whiteList['cursor'] = true; // default: auto
|
|
56
|
+
whiteList['direction'] = true; // default: ltr
|
|
57
|
+
whiteList['left'] = true; // default: auto
|
|
58
|
+
whiteList['line-break'] = true; // default: auto
|
|
59
|
+
whiteList['opacity'] = true; // default: 1
|
|
60
|
+
whiteList['overflow'] = true; // default: depending on individual properties
|
|
61
|
+
whiteList['overflow-wrap'] = true; // default: normal
|
|
62
|
+
whiteList['overflow-x'] = true; // default: visible
|
|
63
|
+
whiteList['overflow-y'] = true; // default: visible
|
|
64
|
+
whiteList['position'] = true; // default: static
|
|
65
|
+
whiteList['right'] = true; // default: auto
|
|
66
|
+
whiteList['top'] = true; // default: auto
|
|
67
|
+
whiteList['white-space'] = true; // default: normal
|
|
68
|
+
whiteList['z-index'] = true; // default: auto
|
|
50
69
|
return whiteList;
|
|
51
70
|
};
|
|
52
71
|
// yfmHtmlBlock additional allowedTags
|
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.
|
|
2
|
+
export const VERSION = typeof '13.16.0' !== 'undefined' ? '13.16.0' : 'unknown';
|