feat(widget-markdown): allow registering remark plugins (#5633)
This commit is contained in:
@ -4,6 +4,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { Map, List } from 'immutable';
|
||||
import { oneLine } from 'common-tags';
|
||||
|
||||
import { getRemarkPlugins } from '../../../lib/registry';
|
||||
import ValidationErrorTypes from '../../../constants/validationErrorTypes';
|
||||
|
||||
function truthy() {
|
||||
@ -326,6 +327,7 @@ export default class Widget extends Component {
|
||||
resolveWidget,
|
||||
widget,
|
||||
getEditorComponents,
|
||||
getRemarkPlugins,
|
||||
query,
|
||||
queryHits,
|
||||
clearSearch,
|
||||
|
@ -7,7 +7,12 @@ import Frame, { FrameContextConsumer } from 'react-frame-component';
|
||||
import { lengths } from 'netlify-cms-ui-default';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { resolveWidget, getPreviewTemplate, getPreviewStyles } from '../../../lib/registry';
|
||||
import {
|
||||
resolveWidget,
|
||||
getPreviewTemplate,
|
||||
getPreviewStyles,
|
||||
getRemarkPlugins,
|
||||
} from '../../../lib/registry';
|
||||
import { ErrorBoundary } from '../../UI';
|
||||
import { selectTemplateName, selectInferedField, selectField } from '../../../reducers/collections';
|
||||
import { boundGetAsset } from '../../../actions/media';
|
||||
@ -45,6 +50,7 @@ export class PreviewPane extends React.Component {
|
||||
entry={entry}
|
||||
fieldsMetaData={metadata}
|
||||
resolveWidget={resolveWidget}
|
||||
getRemarkPlugins={getRemarkPlugins}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
@ -26,6 +26,7 @@ const registry = {
|
||||
previewStyles: [],
|
||||
widgets: {},
|
||||
editorComponents: Map(),
|
||||
remarkPlugins: [],
|
||||
widgetValueSerializers: {},
|
||||
mediaLibraries: [],
|
||||
locales: {},
|
||||
@ -43,6 +44,8 @@ export default {
|
||||
resolveWidget,
|
||||
registerEditorComponent,
|
||||
getEditorComponents,
|
||||
registerRemarkPlugin,
|
||||
getRemarkPlugins,
|
||||
registerWidgetValueSerializer,
|
||||
getWidgetValueSerializer,
|
||||
registerBackend,
|
||||
@ -163,6 +166,19 @@ export function getEditorComponents() {
|
||||
return registry.editorComponents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remark plugins
|
||||
*/
|
||||
/** @typedef {import('unified').Pluggable} RemarkPlugin */
|
||||
/** @type {(plugin: RemarkPlugin) => void} */
|
||||
export function registerRemarkPlugin(plugin) {
|
||||
registry.remarkPlugins.push(plugin);
|
||||
}
|
||||
/** @type {() => Array<RemarkPlugin>} */
|
||||
export function getRemarkPlugins() {
|
||||
return registry.remarkPlugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget Serializers
|
||||
*/
|
||||
|
Reference in New Issue
Block a user