slate-react 0.133.2 → 0.133.3-20261012052143

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 +1 @@
1
- {"version":3,"file":"use-decorations.d.ts","sourceRoot":"","sources":["../../../../packages/slate-react/src/hooks/use-decorations.ts"],"names":[],"mappings":";AAQA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAQ,SAAS,EAAE,MAAM,OAAO,CAAA;AAOnE,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAA;AAE1B;;;GAGG;AAEH,eAAO,MAAM,eAAe;oCACM,cAAc,EAAE;iCACnB,QAAQ,KAAK,MAAM,IAAI;EACzC,CAAA;AAEb,eAAO,MAAM,cAAc,SACnB,UAAU,qBACG,cAAc,EAAE,KAClC,cAAc,EA0BhB,CAAA;AAED,eAAO,MAAM,kBAAkB,uCACO,cAAc,EAAE;;iCAkCJ,QAAQ;CAYzD,CAAA"}
1
+ {"version":3,"file":"use-decorations.d.ts","sourceRoot":"","sources":["../../../../packages/slate-react/src/hooks/use-decorations.ts"],"names":[],"mappings":";AAQA,OAAO,EACL,cAAc,EACd,UAAU,EAGV,SAAS,EAEV,MAAM,OAAO,CAAA;AAOd,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAA;AAE1B;;;GAGG;AAEH,eAAO,MAAM,eAAe;oCACM,cAAc,EAAE;iCACnB,QAAQ,KAAK,MAAM,IAAI;EACzC,CAAA;AAEb,eAAO,MAAM,cAAc,SACnB,UAAU,qBACG,cAAc,EAAE,KAClC,cAAc,EAoChB,CAAA;AAED,eAAO,MAAM,kBAAkB,uCACO,cAAc,EAAE;;iCAkCJ,QAAQ;CAYzD,CAAA"}
package/dist/index.es.js CHANGED
@@ -1258,7 +1258,15 @@ const useDecorations = (node, parentDecorations) => {
1258
1258
  // Not memoized since we want nodes to be decorated on each render
1259
1259
  const selector = () => {
1260
1260
  const path = ReactEditor.findPath(editor, node);
1261
- return decorate([node, path]);
1261
+ const decorations = decorate([node, path]);
1262
+ if (Node.isText(node)) {
1263
+ const range = Editor.range(editor, path);
1264
+ return decorations.flatMap(decoration => {
1265
+ const intersection = Range.intersection(decoration, range);
1266
+ return intersection ? [intersection] : [];
1267
+ });
1268
+ }
1269
+ return decorations;
1262
1270
  };
1263
1271
  const equalityFn = Node.isText(node) ? isTextDecorationsEqual : isElementDecorationsEqual;
1264
1272
  const [decorations, update] = useGenericSelector(selector, equalityFn);