@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
121 lines (101 loc) • 2.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _exportNames = {
postTitle: true,
clipboard: true,
notices: true
};
exports.clipboard = clipboard;
exports.notices = notices;
exports.default = exports.postTitle = void 0;
var _data = require("@wordpress/data");
var _reducer = require("./reducer.js");
Object.keys(_reducer).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _reducer[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _reducer[key];
}
});
});
var _defaults = require("./defaults.js");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
_defaults.EDITOR_SETTINGS_DEFAULTS.autosaveInterval = 1; // This is a way to override default behavior on mobile, and make it ping the native save every second as long as something changed
/**
* Reducer returning the post title state.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {Object} Updated state.
*/
const postTitle = (0, _data.combineReducers)({
isSelected(state = false, action) {
switch (action.type) {
case 'TOGGLE_POST_TITLE_SELECTION':
return action.isSelected;
}
return state;
}
});
/**
* Reducer returning the clipboard state.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {Object} Updated state.
*/
exports.postTitle = postTitle;
function clipboard(state = null, action) {
switch (action.type) {
case 'UPDATE_CLIPBOARD':
return action.clipboard;
}
return state;
}
/**
* Reducer returning the notices state.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {Object} Updated state.
*/
function notices(state = [], action) {
switch (action.type) {
case 'CREATE_NOTICE':
return [...state, action.notice];
case 'REMOVE_ALL_NOTICES':
return [];
case 'REMOVE_NOTICE':
return state.filter(notice => notice.id !== action.id);
}
return state;
}
var _default = (0, _data.combineReducers)({
postId: _reducer.postId,
postType: _reducer.postType,
postTitle,
preferences: _reducer.preferences,
saving: _reducer.saving,
postLock: _reducer.postLock,
postSavingLock: _reducer.postSavingLock,
template: _reducer.template,
isReady: _reducer.isReady,
editorSettings: _reducer.editorSettings,
clipboard,
notices
});
exports.default = _default;
//# sourceMappingURL=reducer.native.js.map