slate-react 0.72.2-2021111752157 → 0.72.2-2021112212944
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/CHANGELOG.md +4 -1
- package/dist/components/string.d.ts.map +1 -1
- package/dist/index.es.js +22 -13
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +21 -12
- package/dist/index.js.map +1 -1
- package/dist/slate-react.js +21 -12
- package/dist/slate-react.min.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# slate-react
|
|
2
2
|
|
|
3
|
-
## 0.72.2-
|
|
3
|
+
## 0.72.2-2021112212944
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- [#4734](https://github.com/ianstormtaylor/slate/pull/4734) [`3c07a870`](https://github.com/ianstormtaylor/slate/commit/3c07a8706ef152fe35c5363a2316aa291c12c2f0) Thanks [@YasinChan](https://github.com/YasinChan)! - [AndroidEditor] Solve input association problems and add click events.
|
|
8
8
|
|
|
9
|
+
- Updated dependencies [[`ab62da20`](https://github.com/ianstormtaylor/slate/commit/ab62da2064921f534ce158f20cd853d2d904f6f6), [`205d4b7e`](https://github.com/ianstormtaylor/slate/commit/205d4b7e66b30ec911e8968a736593aaf2be1567), [`e5427ddd`](https://github.com/ianstormtaylor/slate/commit/e5427dddfc57b4362b7545e9971cdfb9b05d5c3d)]:
|
|
10
|
+
- slate@0.72.2-2021112212944
|
|
11
|
+
|
|
9
12
|
## 0.72.1
|
|
10
13
|
|
|
11
14
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/components/string.tsx"],"names":[],"mappings":";AACA,OAAO,EAAU,IAAI,EAAQ,OAAO,EAAQ,MAAM,OAAO,CAAA;AAIzD;;GAEG;AAEH,QAAA,MAAM,MAAM,UAAW;IACrB,MAAM,EAAE,OAAO,CAAA;IACf,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,OAAO,CAAA;IACf,IAAI,EAAE,IAAI,CAAA;CACX,gBAsCA,CAAA;
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/components/string.tsx"],"names":[],"mappings":";AACA,OAAO,EAAU,IAAI,EAAQ,OAAO,EAAQ,MAAM,OAAO,CAAA;AAIzD;;GAEG;AAEH,QAAA,MAAM,MAAM,UAAW;IACrB,MAAM,EAAE,OAAO,CAAA;IACf,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,OAAO,CAAA;IACf,IAAI,EAAE,IAAI,CAAA;CACX,gBAsCA,CAAA;AAoDD,eAAe,MAAM,CAAA"}
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef,
|
|
1
|
+
import React, { useRef, useLayoutEffect, useEffect, useState, Fragment, useContext, createContext, useMemo, useCallback } from 'react';
|
|
2
2
|
import { Path, Node, Editor, Text as Text$1, Range, Element as Element$1, Transforms } from 'slate';
|
|
3
3
|
import getDirection from 'direction';
|
|
4
4
|
import debounce from 'lodash/debounce';
|
|
@@ -117,21 +117,30 @@ var TextString = props => {
|
|
|
117
117
|
text,
|
|
118
118
|
isTrailing = false
|
|
119
119
|
} = props;
|
|
120
|
-
var ref = useRef(null);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
|
|
120
|
+
var ref = useRef(null); // This is the actual text rendering boundary where we interface with the DOM
|
|
121
|
+
// The text is not rendered as part of the virtual DOM, as since we handle basic character insertions natively,
|
|
122
|
+
// updating the DOM is not a one way dataflow anymore. What we need here is not reconciliation and diffing
|
|
123
|
+
// with previous version of the virtual DOM, but rather diffing with the actual DOM element, and replace the DOM <span> content
|
|
124
|
+
// exactly if and only if its current content does not match our current virtual DOM.
|
|
125
|
+
// Otherwise the DOM TextNode would always be replaced by React as the user types, which interferes with native text features,
|
|
126
|
+
// eg makes native spellcheck opt out from checking the text node.
|
|
127
|
+
// useLayoutEffect: updating our span before browser paint
|
|
128
|
+
|
|
129
|
+
useLayoutEffect(() => {
|
|
130
|
+
// null coalescing text to make sure we're not outputing "null" as a string in the extreme case it is nullish at runtime
|
|
131
|
+
var textWithTrailing = "".concat(text !== null && text !== void 0 ? text : '').concat(isTrailing ? '\n' : '');
|
|
132
|
+
|
|
133
|
+
if (ref.current && ref.current.textContent !== textWithTrailing) {
|
|
134
|
+
ref.current.textContent = textWithTrailing;
|
|
135
|
+
} // intentionally not specifying dependencies, so that this effect runs on every render
|
|
136
|
+
// as this effectively replaces "specifying the text in the virtual DOM under the <span> below" on each render
|
|
137
|
+
|
|
138
|
+
}); // the span is intentionally same on every render in virtual DOM, actual rendering happens in the layout effect above
|
|
129
139
|
|
|
130
140
|
return /*#__PURE__*/React.createElement("span", {
|
|
131
141
|
"data-slate-string": true,
|
|
132
|
-
ref: ref
|
|
133
|
-
|
|
134
|
-
}, text, isTrailing ? '\n' : null);
|
|
142
|
+
ref: ref
|
|
143
|
+
});
|
|
135
144
|
};
|
|
136
145
|
/**
|
|
137
146
|
* Leaf strings without text, render as zero-width strings.
|