# extendify/3.1.5/src/Draft/hooks/useContentHighlight.js

Extendify, version 3.1.5. 26 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.1.5/code/src/Draft/hooks/useContentHighlight.js
- Raw: https://pluginprobe.com/plugins/extendify/3.1.5/raw/src/Draft/hooks/useContentHighlight.js
- Modified: 2023-10-11T02:07:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.1.5/code/src/Draft/hooks/useContentHighlight.js#L10-L20`.

```javascript
import { useDispatch, useSelect } from '@wordpress/data';

export const useContentHighlight = () => {
	const { getBlockInsertionPoint } = useSelect(
		(select) => select('core/block-editor'),
		[],
	);
	const { toggleBlockHighlight, showInsertionPoint, hideInsertionPoint } =
		useDispatch('core/block-editor');

	const toggleHighlight = (clientIds, { isHighlighted }) => {
		toggleBlockHighlight(clientIds[0], isHighlighted);
	};

	const toggleInsertionPoint = ({ isVisible }) => {
		if (!isVisible) {
			hideInsertionPoint();
			return;
		}
		const { rootClientId, index } = getBlockInsertionPoint();
		showInsertionPoint(rootClientId, index);
	};

	return { toggleHighlight, toggleInsertionPoint };
};

```
