@skbkontur/markdown 1.4.0 → 1.4.1
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/package.json
CHANGED
package/src/Markdown/Markdown.js
CHANGED
|
@@ -32,7 +32,7 @@ import { MarkdownActions } from './MarkdownActions';
|
|
|
32
32
|
import { MarkdownEditor } from './MarkdownEditor';
|
|
33
33
|
import { usePasteFromClipboard } from './MarkdownHelpers/markdownHelpers';
|
|
34
34
|
import { getMentionValue, mentionActions } from './MarkdownHelpers/markdownMentionHelpers';
|
|
35
|
-
import { getCursorCoordinates,
|
|
35
|
+
import { getCursorCoordinates, useFullscreenHorizontalPadding, useListenTextareaScroll, } from './MarkdownHelpers/markdownTextareaHelpers';
|
|
36
36
|
import { MarkdownMention } from './MarkdownMention';
|
|
37
37
|
import { ViewMode } from './types';
|
|
38
38
|
import { Guid } from './utils/guid';
|
|
@@ -68,7 +68,7 @@ export var Markdown = function (props) {
|
|
|
68
68
|
textareaNode.selectionEnd = selectionEnd !== null && selectionEnd !== void 0 ? selectionEnd : 0;
|
|
69
69
|
}
|
|
70
70
|
}, [fullscreen, isEditMode, selectionEnd, selectionStart]);
|
|
71
|
-
var fullscreenTextareaPadding =
|
|
71
|
+
var fullscreenTextareaPadding = useFullscreenHorizontalPadding(fullscreen, initialWidth);
|
|
72
72
|
var horizontalPaddings = {
|
|
73
73
|
panelPadding: panelHorizontalPadding,
|
|
74
74
|
fullscreenPadding: fullscreenTextareaPadding,
|
|
@@ -7,5 +7,5 @@ export declare const getCursorCoordinates: (textArea: HTMLTextAreaElement, id: s
|
|
|
7
7
|
y: number;
|
|
8
8
|
};
|
|
9
9
|
export declare const useListenTextareaScroll: (setMention: (value: undefined) => void, textarea?: Textarea | null) => void;
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const useFullscreenHorizontalPadding: (fullscreen: boolean, textareaWidth?: number) => number | undefined;
|
|
11
11
|
export declare const getPastedHtml: (html: string, event: ClipboardEvent, textArea: HTMLTextAreaElement) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { setMarkdownPastedHtml } from './markdownHelpers';
|
|
3
3
|
import { MENTION_WRAPPER_ID_POSTFIX } from '../constants';
|
|
4
4
|
import { turndownService } from '../utils/htmlToMd';
|
|
@@ -72,10 +72,22 @@ export var useListenTextareaScroll = function (setMention, textarea) {
|
|
|
72
72
|
return window.removeEventListener('scroll', resetMention);
|
|
73
73
|
}, [resetMention]);
|
|
74
74
|
};
|
|
75
|
-
export var
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
export var useFullscreenHorizontalPadding = function (fullscreen, textareaWidth) {
|
|
76
|
+
var _a = useState(), padding = _a[0], setPadding = _a[1];
|
|
77
|
+
useEffect(function () {
|
|
78
|
+
if (fullscreen && textareaWidth) {
|
|
79
|
+
var observable = document.body;
|
|
80
|
+
var handleChangeWidth_1 = function (width) { return setPadding((width - textareaWidth) / 2); };
|
|
81
|
+
handleChangeWidth_1(observable.clientWidth);
|
|
82
|
+
var observer_1 = new ResizeObserver(function (entries) { return entries.forEach(function (e) { return handleChangeWidth_1(e.contentRect.width); }); });
|
|
83
|
+
observer_1.observe(observable);
|
|
84
|
+
return function () { return observer_1.disconnect(); };
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
setPadding(0);
|
|
88
|
+
}
|
|
89
|
+
}, [fullscreen, textareaWidth]);
|
|
90
|
+
return padding;
|
|
79
91
|
};
|
|
80
92
|
export var getPastedHtml = function (html, event, textArea) {
|
|
81
93
|
/** Игнорируем Google Docs/Tables/Presentations **/
|