UNPKG

@wordpress/editor

Version:
46 lines (43 loc) 901 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = usePostTitle; var _data = require("@wordpress/data"); var _store = require("../../store"); /** * WordPress dependencies */ /** * Internal dependencies */ /** * Custom hook for managing the post title in the editor. * * @return {Object} An object containing the current title and a function to update the title. */ function usePostTitle() { const { editPost } = (0, _data.useDispatch)(_store.store); const { title } = (0, _data.useSelect)(select => { const { getEditedPostAttribute } = select(_store.store); return { title: getEditedPostAttribute('title') }; }, []); function updateTitle(newTitle) { editPost({ title: newTitle }); } return { title, setTitle: updateTitle }; } //# sourceMappingURL=use-post-title.js.map