@uiw/react-md-editor 3.20.6 → 3.20.8

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.
@@ -1,13 +1,3 @@
1
- /*!
2
- * @uiw/copy-to-clipboard v1.0.12
3
- * Copy to clipboard.
4
- *
5
- * Copyright (c) 2021 Kenny Wang
6
- * https://github.com/uiwjs/copy-to-clipboard.git
7
- *
8
- * Licensed under the MIT license.
9
- */
10
-
11
1
  /*!
12
2
  * Determine if an object is a Buffer
13
3
  *
@@ -34,3 +24,15 @@
34
24
  * This source code is licensed under the MIT license found in the
35
25
  * LICENSE file in the root directory of this source tree.
36
26
  */
27
+
28
+ /**!
29
+ * @uiw/copy-to-clipboard v1.0.14
30
+ * Copy to clipboard.
31
+ *
32
+ * Copyright (c) 2023 Kenny Wang
33
+ * https://github.com/uiwjs/copy-to-clipboard.git
34
+ *
35
+ * @website: https://uiwjs.github.io/copy-to-clipboard
36
+
37
+ * Licensed under the MIT license
38
+ */
@@ -8,6 +8,12 @@ var DragBar = props => {
8
8
  } = props || {};
9
9
  var $dom = useRef(null);
10
10
  var dragRef = useRef();
11
+ var heightRef = useRef(props.height);
12
+ useEffect(() => {
13
+ if (heightRef.current !== props.height) {
14
+ heightRef.current = props.height;
15
+ }
16
+ }, [props.height]);
11
17
  function handleMouseMove(event) {
12
18
  if (dragRef.current) {
13
19
  var _changedTouches$;
@@ -31,7 +37,7 @@ var DragBar = props => {
31
37
  event.preventDefault();
32
38
  var clientY = event.clientY || ((_changedTouches$2 = event.changedTouches[0]) == null ? void 0 : _changedTouches$2.clientY);
33
39
  dragRef.current = {
34
- height: props.height,
40
+ height: heightRef.current,
35
41
  dragY: clientY
36
42
  };
37
43
  document.addEventListener('mousemove', handleMouseMove);
@@ -6,14 +6,14 @@ import rehypePrism from 'rehype-prism-plus';
6
6
  import { EditorContext } from '../../Context';
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
8
  function html2Escape(sHtml) {
9
- return sHtml.replace(/```(\w+)?([\s\S]*?)(\s.+)?```/g, str => {
10
- return str.replace(/[<&"]/g, c => ({
11
- '<': '&lt;',
12
- '>': '&gt;',
13
- '&': '&amp;',
14
- '"': '&quot;'
15
- })[c]);
16
- }).replace(/[<&"]/g, c => ({
9
+ return sHtml
10
+ // .replace(/```(\w+)?([\s\S]*?)(\s.+)?```/g, (str: string) => {
11
+ // return str.replace(
12
+ // /[<&"]/g,
13
+ // (c: string) => (({ '<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;' } as Record<string, string>)[c]),
14
+ // );
15
+ // })
16
+ .replace(/[<&"]/g, c => ({
17
17
  '<': '&lt;',
18
18
  '>': '&gt;',
19
19
  '&': '&amp;',
@@ -13,6 +13,12 @@ var DragBar = function DragBar(props) {
13
13
  onChange = _ref.onChange;
14
14
  var $dom = (0, _react.useRef)(null);
15
15
  var dragRef = (0, _react.useRef)();
16
+ var heightRef = (0, _react.useRef)(props.height);
17
+ (0, _react.useEffect)(function () {
18
+ if (heightRef.current !== props.height) {
19
+ heightRef.current = props.height;
20
+ }
21
+ }, [props.height]);
16
22
  function handleMouseMove(event) {
17
23
  if (dragRef.current) {
18
24
  var _changedTouches$;
@@ -36,7 +42,7 @@ var DragBar = function DragBar(props) {
36
42
  event.preventDefault();
37
43
  var clientY = event.clientY || ((_changedTouches$2 = event.changedTouches[0]) === null || _changedTouches$2 === void 0 ? void 0 : _changedTouches$2.clientY);
38
44
  dragRef.current = {
39
- height: props.height,
45
+ height: heightRef.current,
40
46
  dragY: clientY
41
47
  };
42
48
  document.addEventListener('mousemove', handleMouseMove);
@@ -14,16 +14,14 @@ var _Context = require("../../Context");
14
14
  var _jsxRuntime = require("react/jsx-runtime");
15
15
  var _templateObject;
16
16
  function html2Escape(sHtml) {
17
- return sHtml.replace(/```(\w+)?([\s\S]*?)(\s.+)?```/g, function (str) {
18
- return str.replace(/[<&"]/g, function (c) {
19
- return {
20
- '<': '&lt;',
21
- '>': '&gt;',
22
- '&': '&amp;',
23
- '"': '&quot;'
24
- }[c];
25
- });
26
- }).replace(/[<&"]/g, function (c) {
17
+ return sHtml
18
+ // .replace(/```(\w+)?([\s\S]*?)(\s.+)?```/g, (str: string) => {
19
+ // return str.replace(
20
+ // /[<&"]/g,
21
+ // (c: string) => (({ '<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;' } as Record<string, string>)[c]),
22
+ // );
23
+ // })
24
+ .replace(/[<&"]/g, function (c) {
27
25
  return {
28
26
  '<': '&lt;',
29
27
  '>': '&gt;',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-md-editor",
3
- "version": "3.20.6",
3
+ "version": "3.20.8",
4
4
  "description": "A markdown editor with preview, implemented with React.js and TypeScript.",
5
5
  "homepage": "https://uiwjs.github.io/react-md-editor/",
6
6
  "author": "kenny wang <wowohoo@qq.com>",
@@ -13,6 +13,14 @@ const DragBar: React.FC<IDragBarProps> = (props) => {
13
13
  const { prefixCls, onChange } = props || {};
14
14
  const $dom = useRef<HTMLDivElement>(null);
15
15
  const dragRef = useRef<{ height: number; dragY: number }>();
16
+ const heightRef = useRef(props.height);
17
+
18
+ useEffect(() => {
19
+ if (heightRef.current !== props.height) {
20
+ heightRef.current = props.height;
21
+ }
22
+ }, [props.height]);
23
+
16
24
  function handleMouseMove(event: Event) {
17
25
  if (dragRef.current) {
18
26
  const clientY =
@@ -35,7 +43,7 @@ const DragBar: React.FC<IDragBarProps> = (props) => {
35
43
  const clientY =
36
44
  (event as unknown as MouseEvent).clientY || (event as unknown as TouchEvent).changedTouches[0]?.clientY;
37
45
  dragRef.current = {
38
- height: props.height,
46
+ height: heightRef.current,
39
47
  dragY: clientY,
40
48
  };
41
49
  document.addEventListener('mousemove', handleMouseMove);
@@ -5,17 +5,19 @@ import { IProps } from '../../Editor';
5
5
  import { EditorContext } from '../../Context';
6
6
 
7
7
  function html2Escape(sHtml: string) {
8
- return sHtml
9
- .replace(/```(\w+)?([\s\S]*?)(\s.+)?```/g, (str: string) => {
10
- return str.replace(
8
+ return (
9
+ sHtml
10
+ // .replace(/```(\w+)?([\s\S]*?)(\s.+)?```/g, (str: string) => {
11
+ // return str.replace(
12
+ // /[<&"]/g,
13
+ // (c: string) => (({ '<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;' } as Record<string, string>)[c]),
14
+ // );
15
+ // })
16
+ .replace(
11
17
  /[<&"]/g,
12
18
  (c: string) => (({ '<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;' } as Record<string, string>)[c]),
13
- );
14
- })
15
- .replace(
16
- /[<&"]/g,
17
- (c: string) => (({ '<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;' } as Record<string, string>)[c]),
18
- );
19
+ )
20
+ );
19
21
  }
20
22
 
21
23
  export interface MarkdownProps extends IProps, React.HTMLAttributes<HTMLPreElement> {}