silverstripe-cms/client/src/state/anchorSelector/AnchorSelectorActions.js
Dylan 8ba444332a FIX pull up anchors that have been added for linking to
When editing a page an author may insert anchors into their content (via
TinyMCE), and wish to link to those anchors from another point in that
page. E.g. creating a table of contents, a "jump to top" link at the
base of the content, etc.

Previously this required the page to first be saved as a draft, then
reloaded before the anchors would show in the list to link to. Now they
are dynamically pulled from the content entered for a more fluid editing
experience.
2019-08-15 19:26:37 +12:00

45 lines
1.1 KiB
JavaScript

import ACTION_TYPES from './AnchorSelectorActionTypes';
/**
* Begin querying a page for anchors
*
* @param {Number} pageId - ID of page to query for
* @returns {Object}
*/
export function beginUpdating(pageId) {
return {
type: ACTION_TYPES.ANCHORSELECTOR_UPDATING,
payload: { pageId },
};
}
/**
* Finish updating a anchors for a page
* By default forces list of anchors for a page ID to be loaded from the server each time the page
* is selected to select on if it's anchors from.
*
* @param {Number} pageId - ID of page to query for
* @param {Array} anchors - List of anchor strings
* @param {Boolean} cacheResult - false: Refresh anchor list, true: cache result
* @returns {Object}
*/
export function updated(pageId, anchors, cacheResult = false) {
return {
type: ACTION_TYPES.ANCHORSELECTOR_UPDATED,
payload: { pageId, anchors, cacheResult },
};
}
/**
* Mark a tree as failed
*
* @param {Number} pageId - ID of page that update failed
* @returns {Object}
*/
export function updateFailed(pageId) {
return {
type: ACTION_TYPES.ANCHORSELECTOR_UPDATE_FAILED,
payload: { pageId },
};
}