@wordpress/dom
Advanced tools
Comparing version 4.6.0 to 4.7.0
@@ -27,2 +27,3 @@ export { default as computeCaretRect } from './compute-caret-rect'; | ||
export { default as safeHTML } from './safe-html'; | ||
export { default as isSelectionForward } from './is-selection-forward'; | ||
//# sourceMappingURL=index.js.map |
@@ -67,9 +67,2 @@ /** | ||
} | ||
if (!container.isContentEditable) { | ||
return; | ||
} | ||
const range = scrollIfNoRange(container, isReverse, () => getRange(container, isReverse, x)); | ||
if (!range) { | ||
return; | ||
} | ||
const { | ||
@@ -84,2 +77,10 @@ ownerDocument | ||
assertIsDefined(selection, 'selection'); | ||
if (!container.isContentEditable) { | ||
selection.removeAllRanges(); | ||
return; | ||
} | ||
const range = scrollIfNoRange(container, isReverse, () => getRange(container, isReverse, x)); | ||
if (!range) { | ||
return; | ||
} | ||
selection.removeAllRanges(); | ||
@@ -86,0 +87,0 @@ selection.addRange(range); |
@@ -27,2 +27,3 @@ export { default as computeCaretRect } from "./compute-caret-rect"; | ||
export { default as safeHTML } from "./safe-html"; | ||
export { default as isSelectionForward } from "./is-selection-forward"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -97,2 +97,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "isSelectionForward", { | ||
enumerable: true, | ||
get: function () { | ||
return _isSelectionForward.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isTextField", { | ||
@@ -190,2 +196,3 @@ enumerable: true, | ||
var _safeHtml = _interopRequireDefault(require("./safe-html")); | ||
var _isSelectionForward = _interopRequireDefault(require("./is-selection-forward")); | ||
//# sourceMappingURL=index.js.map |
@@ -74,9 +74,2 @@ "use strict"; | ||
} | ||
if (!container.isContentEditable) { | ||
return; | ||
} | ||
const range = (0, _scrollIfNoRange.scrollIfNoRange)(container, isReverse, () => getRange(container, isReverse, x)); | ||
if (!range) { | ||
return; | ||
} | ||
const { | ||
@@ -91,2 +84,10 @@ ownerDocument | ||
(0, _assertIsDefined.assertIsDefined)(selection, 'selection'); | ||
if (!container.isContentEditable) { | ||
selection.removeAllRanges(); | ||
return; | ||
} | ||
const range = (0, _scrollIfNoRange.scrollIfNoRange)(container, isReverse, () => getRange(container, isReverse, x)); | ||
if (!range) { | ||
return; | ||
} | ||
selection.removeAllRanges(); | ||
@@ -93,0 +94,0 @@ selection.addRange(range); |
@@ -5,2 +5,4 @@ <!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/HEAD/packages#maintaining-changelogs. --> | ||
## 4.7.0 (2024-09-05) | ||
## 4.6.0 (2024-08-21) | ||
@@ -7,0 +9,0 @@ |
{ | ||
"name": "@wordpress/dom", | ||
"version": "4.6.0", | ||
"version": "4.7.0", | ||
"description": "DOM utilities module for WordPress.", | ||
@@ -33,3 +33,3 @@ "author": "The WordPress Contributors", | ||
"@babel/runtime": "^7.16.0", | ||
"@wordpress/deprecated": "^4.6.0" | ||
"@wordpress/deprecated": "^4.7.0" | ||
}, | ||
@@ -39,3 +39,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "ab9564947967bb3f00343130954b9efacba6cdd7" | ||
"gitHead": "c90d920de07c53dff82c5914635b56fafa503b7f" | ||
} |
@@ -242,2 +242,18 @@ # DOM | ||
### isSelectionForward | ||
Returns true if the given selection object is in the forward direction, or false otherwise. | ||
_Related_ | ||
- <https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition> | ||
_Parameters_ | ||
- _selection_ `Selection`: Selection object to check. | ||
_Returns_ | ||
- `boolean`: Whether the selection is forward. | ||
### isTextContent | ||
@@ -244,0 +260,0 @@ |
@@ -27,1 +27,2 @@ export { default as computeCaretRect } from './compute-caret-rect'; | ||
export { default as safeHTML } from './safe-html'; | ||
export { default as isSelectionForward } from './is-selection-forward'; |
@@ -70,3 +70,10 @@ /** | ||
const { ownerDocument } = container; | ||
const { defaultView } = ownerDocument; | ||
assertIsDefined( defaultView, 'defaultView' ); | ||
const selection = defaultView.getSelection(); | ||
assertIsDefined( selection, 'selection' ); | ||
if ( ! container.isContentEditable ) { | ||
selection.removeAllRanges(); | ||
return; | ||
@@ -83,9 +90,4 @@ } | ||
const { ownerDocument } = container; | ||
const { defaultView } = ownerDocument; | ||
assertIsDefined( defaultView, 'defaultView' ); | ||
const selection = defaultView.getSelection(); | ||
assertIsDefined( selection, 'selection' ); | ||
selection.removeAllRanges(); | ||
selection.addRange( range ); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
558805
6958
408
Updated@wordpress/deprecated@^4.7.0