slate-react 0.76.1-202233161544 → 0.76.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/dist/index.js CHANGED
@@ -1221,6 +1221,8 @@ var getClipboardData = function getClipboardData(dataTransfer) {
1221
1221
  return dataTransfer;
1222
1222
  };
1223
1223
 
1224
+ var TRIPLE_CLICK = 3;
1225
+
1224
1226
  var _excluded$2 = ["autoFocus", "decorate", "onDOMBeforeInput", "placeholder", "readOnly", "renderElement", "renderLeaf", "renderPlaceholder", "scrollSelectionIntoView", "style", "as"];
1225
1227
 
1226
1228
  function _createForOfIteratorHelper$2(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
@@ -1831,30 +1833,46 @@ var Editable$1 = function Editable(props) {
1831
1833
  IS_FOCUSED["delete"](editor);
1832
1834
  }, [readOnly, attributes.onBlur]),
1833
1835
  onClick: React.useCallback(function (event) {
1834
- if (!readOnly && hasTarget(editor, event.target) && !isEventHandled(event, attributes.onClick) && isDOMNode(event.target)) {
1836
+ if (hasTarget(editor, event.target) && !isEventHandled(event, attributes.onClick) && isDOMNode(event.target)) {
1835
1837
  var node = ReactEditor.toSlateNode(editor, event.target);
1836
- var path = ReactEditor.findPath(editor, node); // At this time, the Slate document may be arbitrarily different,
1838
+ var path = ReactEditor.findPath(editor, node);
1839
+
1840
+ if (event.detail === TRIPLE_CLICK) {
1841
+ var _start = slate.Editor.start(editor, [path[0]]);
1842
+
1843
+ var end = slate.Editor.end(editor, [path[0]]);
1844
+ var range = slate.Editor.range(editor, _start, end);
1845
+ slate.Transforms.select(editor, range);
1846
+ return;
1847
+ }
1848
+
1849
+ if (readOnly) {
1850
+ return;
1851
+ } // At this time, the Slate document may be arbitrarily different,
1837
1852
  // because onClick handlers can change the document before we get here.
1838
1853
  // Therefore we must check that this path actually exists,
1839
1854
  // and that it still refers to the same node.
1840
1855
 
1856
+
1841
1857
  if (slate.Editor.hasPath(editor, path)) {
1842
1858
  var lookupNode = slate.Node.get(editor, path);
1843
1859
 
1844
1860
  if (lookupNode === node) {
1845
- var _start = slate.Editor.start(editor, path);
1861
+ var _start2 = slate.Editor.start(editor, path);
1862
+
1863
+ var _end = slate.Editor.end(editor, path);
1846
1864
 
1847
- var end = slate.Editor.end(editor, path);
1848
1865
  var startVoid = slate.Editor["void"](editor, {
1849
- at: _start
1866
+ at: _start2
1850
1867
  });
1851
1868
  var endVoid = slate.Editor["void"](editor, {
1852
- at: end
1869
+ at: _end
1853
1870
  });
1854
1871
 
1855
1872
  if (startVoid && endVoid && slate.Path.equals(startVoid[1], endVoid[1])) {
1856
- var range = slate.Editor.range(editor, _start);
1857
- slate.Transforms.select(editor, range);
1873
+ var _range = slate.Editor.range(editor, _start2);
1874
+
1875
+ slate.Transforms.select(editor, _range);
1858
1876
  }
1859
1877
  }
1860
1878
  }