From 79877fcd1f40a4747ba80ee6f190a179d81b062e Mon Sep 17 00:00:00 2001 From: Daniel Lautzenheiser Date: Wed, 19 Apr 2023 23:49:53 -0400 Subject: [PATCH] feat: events (#717) --- packages/core/src/actions/config.ts | 14 ++++++++------ packages/core/src/actions/mediaLibrary.ts | 2 +- packages/core/src/actions/waitUntil.ts | 2 +- packages/core/src/backend.ts | 4 ++-- packages/core/src/backends/bitbucket/API.ts | 4 ++-- .../src/backends/bitbucket/implementation.ts | 6 +++--- .../backends/git-gateway/AuthenticationPage.tsx | 2 +- .../src/backends/git-gateway/implementation.tsx | 8 ++++---- packages/core/src/backends/gitea/API.ts | 2 +- .../core/src/backends/gitea/implementation.tsx | 2 +- packages/core/src/backends/github/API.ts | 2 +- .../core/src/backends/github/implementation.tsx | 4 ++-- .../core/src/backends/gitlab/implementation.ts | 2 +- packages/core/src/bootstrap.tsx | 3 ++- packages/core/src/components/App.tsx | 7 +++++++ packages/core/src/components/ErrorBoundary.tsx | 6 +++--- packages/core/src/formats/frontmatter.ts | 2 +- packages/core/src/interface.ts | 2 +- packages/core/src/lib/formatters.ts | 4 +++- packages/core/src/lib/i18n.ts | 2 +- packages/core/src/lib/registry.ts | 16 +++++++++------- packages/core/src/lib/util/API.ts | 4 ++-- packages/core/src/lib/util/asyncLock.ts | 2 +- packages/core/src/lib/util/implementation.ts | 8 ++++---- packages/core/src/lib/util/localForage.ts | 2 +- packages/core/src/reducers/selectors/entries.ts | 2 +- .../src/widgets/list/components/ListItem.tsx | 4 +++- .../plate/serialization/serializeMarkdown.ts | 2 +- .../serialization/slate/deserializeMarkdown.ts | 6 +++--- packages/docs/content/docs/beta-features.mdx | 2 +- 30 files changed, 72 insertions(+), 56 deletions(-) diff --git a/packages/core/src/actions/config.ts b/packages/core/src/actions/config.ts index ea33245f..8d15a8dc 100644 --- a/packages/core/src/actions/config.ts +++ b/packages/core/src/actions/config.ts @@ -49,7 +49,7 @@ function getConfigUrl() { }; const configLinkEl = document.querySelector('link[rel="cms-config-url"]'); if (configLinkEl && validTypes[configLinkEl.type] && configLinkEl.href) { - console.info(`Using config file path: "${configLinkEl.href}"`); + console.info(`[StaticCMS] Using config file path: "${configLinkEl.href}"`); return configLinkEl.href; } return 'config.yml'; @@ -294,7 +294,7 @@ async function getConfigYaml(file: string): Promise { const contentType = response.headers.get('Content-Type') ?? 'Not-Found'; const isYaml = contentType.indexOf('yaml') !== -1; if (!isYaml) { - console.info(`Response for ${file} was not yaml. (Content-Type: ${contentType})`); + console.info(`[StaticCMS] Response for ${file} was not yaml. (Content-Type: ${contentType})`); } return parseConfig(await response.text()); } @@ -338,7 +338,7 @@ export async function detectProxyServer(localBackend?: boolean | LocalBackend) { : localBackend.url || defaultUrl.replace('localhost', location.hostname); try { - console.info(`Looking for Static CMS Proxy Server at '${proxyUrl}'`); + console.info(`[StaticCMS] Looking for Static CMS Proxy Server at '${proxyUrl}'`); const res = await fetch(`${proxyUrl}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, @@ -349,14 +349,16 @@ export async function detectProxyServer(localBackend?: boolean | LocalBackend) { type?: string; }; if (typeof repo === 'string' && typeof type === 'string') { - console.info(`Detected Static CMS Proxy Server at '${proxyUrl}' with repo: '${repo}'`); + console.info( + `[StaticCMS] Detected Static CMS Proxy Server at '${proxyUrl}' with repo: '${repo}'`, + ); return { proxyUrl, type }; } else { - console.info(`Static CMS Proxy Server not detected at '${proxyUrl}'`); + console.info(`[StaticCMS] Static CMS Proxy Server not detected at '${proxyUrl}'`); return {}; } } catch { - console.info(`Static CMS Proxy Server not detected at '${proxyUrl}'`); + console.info(`[StaticCMS] Static CMS Proxy Server not detected at '${proxyUrl}'`); return {}; } } diff --git a/packages/core/src/actions/mediaLibrary.ts b/packages/core/src/actions/mediaLibrary.ts index 142e2874..40999698 100644 --- a/packages/core/src/actions/mediaLibrary.ts +++ b/packages/core/src/actions/mediaLibrary.ts @@ -165,7 +165,7 @@ export function loadMedia( .catch((error: { status?: number }) => { console.error(error); if (error.status === 404) { - console.info('This 404 was expected and handled appropriately.'); + console.info('[StaticCMS] This 404 was expected and handled appropriately.'); dispatch(mediaLoaded([])); } else { dispatch(mediaLoadFailed()); diff --git a/packages/core/src/actions/waitUntil.ts b/packages/core/src/actions/waitUntil.ts index 759f5ed9..8db55af4 100644 --- a/packages/core/src/actions/waitUntil.ts +++ b/packages/core/src/actions/waitUntil.ts @@ -29,7 +29,7 @@ export async function waitUntilWithTimeout( if (waitDone) { resolve(null); } else { - console.warn('Wait Action timed out'); + console.warn('[StaticCMS] Wait Action timed out'); resolve(null); } }, timeout); diff --git a/packages/core/src/backend.ts b/packages/core/src/backend.ts index 72a0abec..ba99d609 100644 --- a/packages/core/src/backend.ts +++ b/packages/core/src/backend.ts @@ -676,7 +676,7 @@ export class Backend { - console.info(`Failed getting commits for branch '${branch}'`, e); + console.info(`[StaticCMS] Failed getting commits for branch '${branch}'`, e); return []; }); diff --git a/packages/core/src/backends/bitbucket/implementation.ts b/packages/core/src/backends/bitbucket/implementation.ts index 3842770c..3487a942 100644 --- a/packages/core/src/backends/bitbucket/implementation.ts +++ b/packages/core/src/backends/bitbucket/implementation.ts @@ -126,7 +126,7 @@ export default class BitbucketBackend implements BackendClass { ); }) .catch(e => { - console.warn('Failed getting BitBucket status', e); + console.warn('[StaticCMS] Failed getting BitBucket status', e); return true; }); @@ -138,7 +138,7 @@ export default class BitbucketBackend implements BackendClass { ?.user() .then(user => !!user) .catch(e => { - console.warn('Failed getting Bitbucket user', e); + console.warn('[StaticCMS] Failed getting Bitbucket user', e); return false; })) || false; } @@ -373,7 +373,7 @@ export default class BitbucketBackend implements BackendClass { .then(attributes => getLargeMediaPatternsFromGitAttributesFile(attributes as string)) .catch((err: FetchError) => { if (err.status === 404) { - console.info('This 404 was expected and handled appropriately.'); + console.info('[StaticCMS] This 404 was expected and handled appropriately.'); } else { console.error(err); } diff --git a/packages/core/src/backends/git-gateway/AuthenticationPage.tsx b/packages/core/src/backends/git-gateway/AuthenticationPage.tsx index 19655140..267f66d8 100644 --- a/packages/core/src/backends/git-gateway/AuthenticationPage.tsx +++ b/packages/core/src/backends/git-gateway/AuthenticationPage.tsx @@ -54,7 +54,7 @@ const GitGatewayAuthenticationPage = ({ onLogin, t }: GitGatewayAuthenticationPa } if (window.netlifyIdentity) { - console.info('Manually initializing identity widget'); + console.info('[StaticCMS] Manually initializing identity widget'); initialized = true; window.netlifyIdentity.init(); clearInterval(interval); diff --git a/packages/core/src/backends/git-gateway/implementation.tsx b/packages/core/src/backends/git-gateway/implementation.tsx index 382cea53..db47ff75 100644 --- a/packages/core/src/backends/git-gateway/implementation.tsx +++ b/packages/core/src/backends/git-gateway/implementation.tsx @@ -175,7 +175,7 @@ export default class GitGateway implements BackendClass { .every((statusComponent: GitGatewayStatus) => statusComponent.status === 'operational'); }) .catch(e => { - console.warn('Failed getting Git Gateway status', e); + console.warn('[StaticCMS] Failed getting Git Gateway status', e); return true; }); @@ -186,7 +186,7 @@ export default class GitGateway implements BackendClass { (await this.tokenPromise?.() .then(token => !!token) .catch(e => { - console.warn('Failed getting Identity token', e); + console.warn('[StaticCMS] Failed getting Identity token', e); return false; })) || false; } @@ -415,7 +415,7 @@ export default class GitGateway implements BackendClass { .then((patterns: string[]) => ({ err: null, patterns })) .catch((err: Error) => { if (err.message.includes('404')) { - console.info('This 404 was expected and handled appropriately.'); + console.info('[StaticCMS] This 404 was expected and handled appropriately.'); return { err: null, patterns: [] as string[] }; } else { return { err, patterns: [] as string[] }; @@ -461,7 +461,7 @@ export default class GitGateway implements BackendClass { const entry = items[0]; const pointerFile = parsePointerFile(entry.data); if (!pointerFile.sha) { - console.warn(`Failed parsing pointer file ${path}`); + console.warn(`[StaticCMS] Failed parsing pointer file ${path}`); return { url: path, blob: new Blob() }; } diff --git a/packages/core/src/backends/gitea/API.ts b/packages/core/src/backends/gitea/API.ts index d08a0e9b..aa8ed8aa 100644 --- a/packages/core/src/backends/gitea/API.ts +++ b/packages/core/src/backends/gitea/API.ts @@ -354,7 +354,7 @@ export default class API { // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (err: any) { if (err && err.status === 404) { - console.info('This 404 was expected and handled appropriately.'); + console.info('[StaticCMS] This 404 was expected and handled appropriately.'); return []; } else { throw err; diff --git a/packages/core/src/backends/gitea/implementation.tsx b/packages/core/src/backends/gitea/implementation.tsx index 8d6f06d3..cb0afa42 100644 --- a/packages/core/src/backends/gitea/implementation.tsx +++ b/packages/core/src/backends/gitea/implementation.tsx @@ -93,7 +93,7 @@ export default class Gitea implements BackendClass { ?.user() .then(user => !!user) .catch(e => { - console.warn('Failed getting Gitea user', e); + console.warn('[StaticCMS] Failed getting Gitea user', e); return false; })) || false; diff --git a/packages/core/src/backends/github/API.ts b/packages/core/src/backends/github/API.ts index 2cc227d1..1e5d926a 100644 --- a/packages/core/src/backends/github/API.ts +++ b/packages/core/src/backends/github/API.ts @@ -369,7 +369,7 @@ export default class API { // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (err: any) { if (err && err.status === 404) { - console.info('This 404 was expected and handled appropriately.'); + console.info('[StaticCMS] This 404 was expected and handled appropriately.'); return []; } else { throw err; diff --git a/packages/core/src/backends/github/implementation.tsx b/packages/core/src/backends/github/implementation.tsx index f41612a8..ae858634 100644 --- a/packages/core/src/backends/github/implementation.tsx +++ b/packages/core/src/backends/github/implementation.tsx @@ -109,7 +109,7 @@ export default class GitHub implements BackendClass { ); }) .catch(e => { - console.warn('Failed getting GitHub status', e); + console.warn('[StaticCMS] Failed getting GitHub status', e); return true; }); @@ -121,7 +121,7 @@ export default class GitHub implements BackendClass { ?.getUser() .then(user => !!user) .catch(e => { - console.warn('Failed getting GitHub user', e); + console.warn('[StaticCMS] Failed getting GitHub user', e); return false; })) || false; } diff --git a/packages/core/src/backends/gitlab/implementation.ts b/packages/core/src/backends/gitlab/implementation.ts index b26e846c..7da9151b 100644 --- a/packages/core/src/backends/gitlab/implementation.ts +++ b/packages/core/src/backends/gitlab/implementation.ts @@ -86,7 +86,7 @@ export default class GitLab implements BackendClass { ?.user() .then(user => !!user) .catch(e => { - console.warn('Failed getting GitLab user', e); + console.warn('[StaticCMS] Failed getting GitLab user', e); return false; })) || false; diff --git a/packages/core/src/bootstrap.tsx b/packages/core/src/bootstrap.tsx index 572ff5e1..fc93665c 100644 --- a/packages/core/src/bootstrap.tsx +++ b/packages/core/src/bootstrap.tsx @@ -40,6 +40,7 @@ const ROOT_ID = 'nc-root'; // @ts-ignore // eslint-disable-next-line @typescript-eslint/no-unused-vars, import/order import ReactDOM from 'react-dom'; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = true; @@ -79,7 +80,7 @@ function bootstrap(opts?: { * Log the version number. */ if (typeof STATIC_CMS_CORE_VERSION === 'string') { - console.info(`static-cms-core ${STATIC_CMS_CORE_VERSION}`); + console.info(`[StaticCMS] Using @staticcms/core ${STATIC_CMS_CORE_VERSION}`); } /** diff --git a/packages/core/src/components/App.tsx b/packages/core/src/components/App.tsx index ec5c144c..6a90341c 100644 --- a/packages/core/src/components/App.tsx +++ b/packages/core/src/components/App.tsx @@ -18,6 +18,7 @@ import { loginUser as loginUserAction } from '@staticcms/core/actions/auth'; import { discardDraft } from '@staticcms/core/actions/entries'; import { currentBackend } from '@staticcms/core/backend'; import { changeTheme } from '../actions/globalUI'; +import { invokeEvent } from '../lib/registry'; import { getDefaultPath } from '../lib/util/collection.util'; import { selectTheme } from '../reducers/selectors/globalUI'; import { useAppDispatch, useAppSelector } from '../store/hooks'; @@ -229,6 +230,12 @@ const App = ({ ); }, [authenticationPage, collections, defaultPath, isFetching, user]); + useEffect(() => { + setTimeout(() => { + invokeEvent({ name: 'mounted' }); + }); + }, []); + if (!config.config) { return configError(t('app.app.configNotFound')); } diff --git a/packages/core/src/components/ErrorBoundary.tsx b/packages/core/src/components/ErrorBoundary.tsx index 9e28e4ef..bb6f2cb0 100644 --- a/packages/core/src/components/ErrorBoundary.tsx +++ b/packages/core/src/components/ErrorBoundary.tsx @@ -62,7 +62,7 @@ function buildIssueUrl(title: string, config?: Config) { return `${ISSUE_URL}${params.toString()}`; } catch (e) { - console.info(e); + console.error(e); return `${ISSUE_URL}template=bug_report.md`; } } @@ -72,7 +72,7 @@ interface RecoveredEntryProps { } const RecoveredEntry = ({ entry, t }: TranslatedProps) => { - console.info(entry); + console.info('[StaticCMS] Recovered entry', entry); return ( <>
@@ -134,7 +134,7 @@ class ErrorBoundary extends Component, Error if (this.props.showBackup) { const backup = await localForage.getItem('backup'); if (backup) { - console.info(backup); + console.info('[StaticCMS] Recovered backup', backup); this.setState({ backup }); } } diff --git a/packages/core/src/formats/frontmatter.ts b/packages/core/src/formats/frontmatter.ts index a8a76248..0aed630f 100644 --- a/packages/core/src/formats/frontmatter.ts +++ b/packages/core/src/formats/frontmatter.ts @@ -67,7 +67,7 @@ function inferFrontmatterFormat(str: string) { case '{': return getFormatOpts(Languages.JSON); default: - console.warn('Unrecognized front-matter format.'); + console.warn('[StaticCMS] Unrecognized front-matter format.'); } } diff --git a/packages/core/src/interface.ts b/packages/core/src/interface.ts index 526aaf3f..430a635b 100644 --- a/packages/core/src/interface.ts +++ b/packages/core/src/interface.ts @@ -821,7 +821,7 @@ export interface EventData { export type EventListenerOptions = Record; export type EventListenerHandler = ( - data: EventData, + data: EventData | undefined, options: EventListenerOptions, ) => Promise; diff --git a/packages/core/src/lib/formatters.ts b/packages/core/src/lib/formatters.ts index 0a3de953..c2f6c2e9 100644 --- a/packages/core/src/lib/formatters.ts +++ b/packages/core/src/lib/formatters.ts @@ -54,7 +54,9 @@ export function commitMessageFormatter( case 'author-name': return authorName || ''; default: - console.warn(`Ignoring unknown variable “${variable}” in commit message template.`); + console.warn( + `[StaticCMS] Ignoring unknown variable “${variable}” in commit message template.`, + ); return ''; } }); diff --git a/packages/core/src/lib/i18n.ts b/packages/core/src/lib/i18n.ts index 974c3c53..80dc2a9e 100644 --- a/packages/core/src/lib/i18n.ts +++ b/packages/core/src/lib/i18n.ts @@ -246,7 +246,7 @@ function mergeValues( let defaultEntry = values.find(e => e.locale === defaultLocale); if (!defaultEntry) { defaultEntry = values[0]; - console.warn(`Could not locale entry for default locale '${defaultLocale}'`); + console.warn(`[StaticCMS] Could not locale entry for default locale '${defaultLocale}'`); } const i18n = values .filter(e => e.locale !== defaultEntry!.locale) diff --git a/packages/core/src/lib/registry.ts b/packages/core/src/lib/registry.ts index 145063d0..dcb9d290 100644 --- a/packages/core/src/lib/registry.ts +++ b/packages/core/src/lib/registry.ts @@ -26,7 +26,7 @@ import type { WidgetValueSerializer, } from '../interface'; -export const allowedEvents = ['preSave', 'postSave'] as const; +export const allowedEvents = ['mounted', 'preSave', 'postSave'] as const; export type AllowedEvent = (typeof allowedEvents)[number]; const eventHandlers = allowedEvents.reduce((acc, e) => { @@ -219,7 +219,7 @@ export function registerWidget( } = nameOrWidgetOrWidgets; if (registry.widgets[widgetName]) { console.warn(oneLine` - Multiple widgets registered with name "${widgetName}". Only the last widget registered with + [StaticCMS] Multiple widgets registered with name "${widgetName}". Only the last widget registered with this name will be used. `); } @@ -323,22 +323,24 @@ export function registerEventListener( registry.eventHandlers[name].push({ handler, options }); } -export async function invokeEvent({ name, data }: { name: AllowedEvent; data: EventData }) { +export async function invokeEvent({ name, data }: { name: AllowedEvent; data?: EventData }) { validateEventName(name); const handlers = registry.eventHandlers[name]; - let _data = { ...data }; + console.info(`[StaticCMS] Firing event ${name}`, data); + + let _data = data ? { ...data } : undefined; for (const { handler, options } of handlers) { const result = await handler(_data, options); - if (result !== undefined) { + if (_data !== undefined && result !== undefined) { const entry = { ..._data.entry, data: result, } as Entry; - _data = { ...data, entry }; + _data = { ..._data, entry }; } } - return _data.entry.data; + return _data?.entry.data; } export function removeEventListener({ name, handler }: EventListener) { diff --git a/packages/core/src/lib/util/API.ts b/packages/core/src/lib/util/API.ts index 465e88d7..14512a60 100644 --- a/packages/core/src/lib/util/API.ts +++ b/packages/core/src/lib/util/API.ts @@ -83,7 +83,7 @@ export async function requestWithBackoff( if (!api.rateLimiter) { const timeout = error.resetSeconds || attempt * attempt; console.info( - `Pausing requests for ${timeout} ${ + `[StaticCMS] Pausing requests for ${timeout} ${ attempt === 1 ? 'second' : 'seconds' } due to fetch failures:`, error.message, @@ -93,7 +93,7 @@ export async function requestWithBackoff( setTimeout(() => { api.rateLimiter?.release(); api.rateLimiter = undefined; - console.info(`Done pausing requests`); + console.info('[StaticCMS] Done pausing requests'); }, 1000 * timeout); } return requestWithBackoff(api, req, attempt + 1); diff --git a/packages/core/src/lib/util/asyncLock.ts b/packages/core/src/lib/util/asyncLock.ts index f076d74b..148e3c6e 100644 --- a/packages/core/src/lib/util/asyncLock.ts +++ b/packages/core/src/lib/util/asyncLock.ts @@ -33,7 +33,7 @@ export function asyncLock(): AsyncLock { if (e instanceof Error && e.message !== 'leave called too many times.') { throw e; } else { - console.warn('leave called too many times.'); + console.warn('[StaticCMS] Leave called too many times.'); lock = semaphore(1); } } diff --git a/packages/core/src/lib/util/implementation.ts b/packages/core/src/lib/util/implementation.ts index 6c9a983a..f1834a58 100644 --- a/packages/core/src/lib/util/implementation.ts +++ b/packages/core/src/lib/util/implementation.ts @@ -114,7 +114,7 @@ export async function runWithLock(lock: AsyncLock, func: Function, message: stri try { const acquired = await lock.acquire(); if (!acquired) { - console.warn(message); + console.warn('[StaticCMS]', message); } const result = await func(); @@ -315,7 +315,7 @@ export async function allEntriesByFolder({ const localTreeInBranch = await isShaExistsInBranch(branch.name, localTree.head); if (!localTreeInBranch) { console.info( - `Can't find local tree head '${localTree.head}' in branch '${branch.name}', rebuilding local tree`, + `[StaticCMS] Can't find local tree head '${localTree.head}' in branch '${branch.name}', rebuilding local tree`, ); return listAllFilesAndPersist(); } @@ -329,12 +329,12 @@ export async function allEntriesByFolder({ getFileId, filterFile, }).catch(e => { - console.info('Failed getting diff from local tree:', e); + console.info('[StaticCMS] Failed getting diff from local tree:', e); return null; }); if (!diff) { - console.info(`Diff is null, rebuilding local tree`); + console.info(`[StaticCMS] Diff is null, rebuilding local tree`); return listAllFilesAndPersist(); } diff --git a/packages/core/src/lib/util/localForage.ts b/packages/core/src/lib/util/localForage.ts index c7589caf..65ad6466 100644 --- a/packages/core/src/lib/util/localForage.ts +++ b/packages/core/src/lib/util/localForage.ts @@ -10,7 +10,7 @@ function localForageTest() { .catch(err => { if (err.code === 22) { const message = 'Unable to set localStorage key. Quota exceeded! Full disk?'; - console.warn(message); + console.warn('[StaticCMS]', message); } console.info(err); }); diff --git a/packages/core/src/reducers/selectors/entries.ts b/packages/core/src/reducers/selectors/entries.ts index aabd0559..61fb1529 100644 --- a/packages/core/src/reducers/selectors/entries.ts +++ b/packages/core/src/reducers/selectors/entries.ts @@ -89,7 +89,7 @@ export function getGroup(entry: Entry, selectedGroup: GroupMap) { value = matched[0]; } } catch (e: unknown) { - console.warn(`Invalid view group pattern '${pattern}' for field '${field}'`, e); + console.warn(`[StaticCMS] Invalid view group pattern '${pattern}' for field '${field}'`, e); } return { id: `${label}${value}`, diff --git a/packages/core/src/widgets/list/components/ListItem.tsx b/packages/core/src/widgets/list/components/ListItem.tsx index 9c711cb1..7887caa1 100644 --- a/packages/core/src/widgets/list/components/ListItem.tsx +++ b/packages/core/src/widgets/list/components/ListItem.tsx @@ -50,7 +50,9 @@ function validateItem(field: ListField, item: ValueOrNestedValue) { if (typeof item !== 'object') { console.warn( - `'${field.name}' field item value value should be an object but is a '${typeof item}'`, + `[StaticCMS] '${ + field.name + }' field item value value should be an object but is a '${typeof item}'`, ); return false; } diff --git a/packages/core/src/widgets/markdown/plate/serialization/serializeMarkdown.ts b/packages/core/src/widgets/markdown/plate/serialization/serializeMarkdown.ts index 5037bf11..376c3c27 100644 --- a/packages/core/src/widgets/markdown/plate/serialization/serializeMarkdown.ts +++ b/packages/core/src/widgets/markdown/plate/serialization/serializeMarkdown.ts @@ -333,7 +333,7 @@ ${bodyRows.join('\n')}`; )}${shortcodeConfig.closeTag}`; default: - console.warn('Unrecognized slate node, proceeding as text', `"${type}"`, chunk); + console.warn('[StaticCMS] Unrecognized slate node, proceeding as text', `"${type}"`, chunk); return children; } } diff --git a/packages/core/src/widgets/markdown/plate/serialization/slate/deserializeMarkdown.ts b/packages/core/src/widgets/markdown/plate/serialization/slate/deserializeMarkdown.ts index f0a9570e..f0d136d4 100644 --- a/packages/core/src/widgets/markdown/plate/serialization/slate/deserializeMarkdown.ts +++ b/packages/core/src/widgets/markdown/plate/serialization/slate/deserializeMarkdown.ts @@ -276,7 +276,7 @@ export default function deserializeMarkdown(node: MdastNode, options: Options) { case 'br': return { type: NodeTypes.paragraph, children: [{ text: '' }] }; default: - console.warn('unrecognized mdx flow element', node); + console.warn('[StaticCMS] Unrecognized mdx flow element', node); break; } } @@ -335,7 +335,7 @@ export default function deserializeMarkdown(node: MdastNode, options: Options) { ...persistLeafFormats(children as Array), } as TextNode; default: - console.warn('unrecognized mdx text element', node); + console.warn('[StaticCMS] Unrecognized mdx text element', node); break; } } @@ -356,7 +356,7 @@ export default function deserializeMarkdown(node: MdastNode, options: Options) { return nodes.map(node => (node.type === 'text' ? { text: node.value ?? '' } : node)); default: - console.warn('Unrecognized mdast node, proceeding as text', node); + console.warn('[StaticCMS] Unrecognized mdast node, proceeding as text', node); return { text: node.value || '' }; } } diff --git a/packages/docs/content/docs/beta-features.mdx b/packages/docs/content/docs/beta-features.mdx index 8ac198e0..77f6b59a 100644 --- a/packages/docs/content/docs/beta-features.mdx +++ b/packages/docs/content/docs/beta-features.mdx @@ -92,7 +92,7 @@ CMS.registerEventListener({ }); ``` -Supported events are `preSave` and `postSave`. The `preSave` hook can be used to modify the entry data like so: +Supported events are `mounted`, `preSave` and `postSave`. The `preSave` hook can be used to modify the entry data like so: ```javascript CMS.registerEventListener({