the editable site (validation-lab)

This commit is contained in:
kpgarrod committed 2026-11-21 08:03:55 +01:00
commit 3ac81d5a52
13454 files changed
+2227005

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
export function parseStyle(cssText: string): Record<string, string>;
/**
* Tagged template that creates React elements from HTML-like markup, powered by HTM. It lets you
* write custom preview templates, field types and editor component previews in a JSX-like syntax
* without a build step. Components are embedded with `<${Component} prop=${value} />`.
* @type {(strings: TemplateStringsArray, ...values: any[]) => ReactElement | ReactElement[]}
* @see https://github.com/developit/htm
*/
export const html: (strings: TemplateStringsArray, ...values: any[]) => ReactElement | ReactElement[];
import type { ReactElement } from 'react';
+37
View File
@@ -0,0 +1,37 @@
export default CMS;
declare namespace CMS {
export { React };
export { getFieldType };
export { getFieldType as getWidget };
export { init };
export { registerCustomFormat };
export { registerCustomPage };
export { registerEditorComponent };
export { registerEventListener };
export { registerFieldType };
export { registerPreviewStyle };
export { registerPreviewTemplate };
export { registerStringTransformation };
export { registerFieldType as registerWidget };
export { renderRichText };
}
import { getFieldType } from './methods/get-field-type';
import { init } from './methods/init';
/**
* The React instance bundled with the CMS, which renders custom preview templates, custom field
* types and editor component previews. Hooks such as `useState` only work when taken from this
* instance, not from another copy of React, e.g. the `react` package installed by the user.
* @type {typeof import('react')}
* @see https://sveltiacms.app/en/docs/api#writing-react-components
*/
export const React: typeof import("react");
import { registerCustomFormat } from './methods/register-custom-format';
import { registerCustomPage } from './methods/register-custom-page';
import { registerEditorComponent } from './methods/register-editor-component';
import { registerEventListener } from './methods/register-event-listener';
import { registerFieldType } from './methods/register-field-type';
import { registerPreviewStyle } from './methods/register-preview-style';
import { registerPreviewTemplate } from './methods/register-preview-template';
import { registerStringTransformation } from './methods/register-string-transformation';
import { renderRichText } from './methods/render-rich-text';
export { getFieldType, getFieldType as getWidget, init, registerCustomFormat, registerCustomPage, registerEditorComponent, registerEventListener, registerFieldType, registerPreviewStyle, registerPreviewTemplate, registerStringTransformation, registerFieldType as registerWidget, renderRichText };
+18
View File
@@ -0,0 +1,18 @@
/**
* @import { FieldTypeDefinition } from '../../../types/public';
*/
/**
* Get the definition of a field type (widget), so that a custom field type can reuse the control
* and/or preview component of another field type. The components are React components; for a
* built-in field type, they render the built-in Svelte components internally. Only the built-in
* field types that work outside the entry editor can be reused: `boolean`, `color`, `datetime`,
* `map`, `number`, `select`, `string`, `text` and `uuid`. `CMS.getWidget()` is an alias of this
* method for compatibility with Netlify/Decap CMS.
* @param {string} name Field type name.
* @returns {FieldTypeDefinition | undefined} Field type definition, or `undefined` if the field
* type is not registered or cannot be reused.
* @throws {TypeError} If `name` is not a non-empty string.
* @see https://sveltiacms.app/en/docs/api/field-types
*/
export function getFieldType(name: string): FieldTypeDefinition | undefined;
import type { FieldTypeDefinition } from '../../../types/public';
+23
View File
@@ -0,0 +1,23 @@
/**
* Initialize the CMS, optionally with the given CMS configuration. When the CMS is loaded with a
* classic `<script>` tag, e.g. from a CDN, it initializes itself automatically unless
* `window.CMS_MANUAL_INIT` is set to `true` before the script is loaded. When it’s imported as a
* module, e.g. from the npm package, this method always has to be called. It mounts the app on the
* `<div id="nc-root">` element if present, or the `<body>` element otherwise, waiting for the page
* content to be loaded if needed. Calls after the first one are ignored.
* @param {object} [options] Options.
* @param {CmsConfig} [options.config] Configuration to be merged with the configuration file, such
* as `config.yml`. Its options override the file’s, except for arrays such as `collections`, which
* are concatenated, so an array item can be added but not replaced. Include
* `load_config_file: false` to prevent the configuration file from being loaded, in which case
* this has to be a complete configuration.
* @returns {Promise<void>} Promise that resolves once the app has been mounted.
* @throws {TypeError} If `config` is neither an object nor `undefined`. As this is an async
* function, the error is thrown as a rejection of the returned Promise.
* @see https://decapcms.org/docs/manual-initialization/
* @see https://sveltiacms.app/en/docs/api/initialization
*/
export function init({ config }?: {
config?: CmsConfig | undefined;
}): Promise<void>;
import type { CmsConfig } from '../../../types/public';
@@ -0,0 +1,31 @@
/**
* @import { FileFormatter, FileParser } from '../../../types/public';
*/
/**
* Register a custom entry file format. A custom format with the same name as a built-in one, such
* as `json`, takes precedence over it, and registering a format again replaces the previous one.
* @param {string} name Format name. This should match the `format` option of a collection where the
* custom format will be used.
* @param {string} extension File extension without a leading dot, e.g. `json5`. Files in a
* collection with the custom format use this extension, regardless of the collection’s `extension`
* option.
* @param {{ fromFile?: FileParser, toFile?: FileFormatter }} methods Parser and/or formatter
* methods. Async functions can be used. Without `fromFile`, files in the format are parsed with the
* built-in parser for the format name, if any; without `toFile`, they are formatted likewise. If
* the format name isn’t a built-in one, such as `yaml` or `json`, omit neither: without `fromFile`,
* files in the format can’t be loaded, and without `toFile`, saving an entry fails with an error,
* leaving the file untouched. A warning is logged when either is missing. `toFile` is also given a
* context with a `serialize` function, which formats the content with the built-in formatter for
* a built-in format name, so its output can be post-processed, e.g. with a code formatter.
* @throws {TypeError} If `name` or `extension` is not a non-empty string, or if `fromFile` or
* `toFile` is given but not a function.
* @throws {Error} If neither `fromFile` nor `toFile` is provided.
* @see https://decapcms.org/docs/custom-formatters/
* @see https://sveltiacms.app/en/docs/api/file-formats
*/
export function registerCustomFormat(name: string, extension: string, { fromFile, toFile }?: {
fromFile?: FileParser;
toFile?: FileFormatter;
}): void;
import type { FileParser } from '../../../types/public';
import type { FileFormatter } from '../../../types/public';
@@ -0,0 +1,18 @@
/**
* @import { CustomPageDefinition } from '../../../types/public';
*/
/**
* Register a custom page, which is listed in the global toolbar, or in the Menu on small screens.
* The page renders a React component, or embeds a web page in an iframe. With the `newTab` option,
* the web page is opened in a new browser tab instead. Pages are listed in the order of
* registration, and registering a page with the same `id` again replaces the previous one in place.
* @param {CustomPageDefinition} definition Page definition.
* @throws {TypeError} If `definition` is not an object, `id` is not a string of alphanumeric
* characters, hyphens and underscores, `label` is not a non-empty string, `icon` is given but not a
* non-empty string, neither or both of `component` and `url` are given, `component` is not a React
* component, `url` is not a valid `http` or `https` URL or file path, or `newTab` is given but not
* a boolean or along with `component`.
* @see https://sveltiacms.app/en/docs/api/custom-pages
*/
export function registerCustomPage(definition: CustomPageDefinition): void;
import type { CustomPageDefinition } from '../../../types/public';
@@ -0,0 +1,19 @@
/**
* Register a custom rich text editor component, which can be used in RichText and Markdown fields.
* Registering a component with the same `id` again replaces the previous one. A component with the
* `type` option set to `inline` is a pattern-based inline component, compatible with Decap CMS,
* which has no fields.
* @param {CustomEditorComponentDefinition} definition Component definition.
* @throws {TypeError} If `definition` is not an object, `id` is not a non-empty string, `label` is
* given but not a non-empty string, `pattern` is not a regular expression, `toPreview` is given
* but not a function, or the other options are invalid. A field-based component must have
* `toBlock` as a function and `fields` as an array, and the HTML options must be valid:
* `htmlSelector`, `fromBlockHTML` and `toBlockHTML` must be given together, and `htmlSelector`
* must be a valid CSS selector naming the element types it matches. An inline component must have
* `toInline` as a function, `fromInline`, `onInsert` and `onEdit` must be functions if given, and
* `trigger` must be a non-empty string if given.
* @see https://decapcms.org/docs/custom-widgets/#registereditorcomponent
* @see https://sveltiacms.app/en/docs/api/editor-components
*/
export function registerEditorComponent(definition: CustomEditorComponentDefinition): void;
import type { CustomEditorComponentDefinition } from '../../../types/public';
@@ -0,0 +1,15 @@
/**
* @import { AppEventListener } from '../../../types/public';
*/
/**
* Register an event listener. Multiple listeners can be registered for the same event; they are
* called in the order of registration.
* @param {AppEventListener} eventListener Event listener.
* @throws {TypeError} If the event listener is not an object, `name` is not a string, or `handler`
* is not a function.
* @throws {RangeError} If the event listener name is not a supported event type.
* @see https://decapcms.org/docs/registering-events/
* @see https://sveltiacms.app/en/docs/api/events
*/
export function registerEventListener(eventListener: AppEventListener): void;
import type { AppEventListener } from '../../../types/public';
@@ -0,0 +1,35 @@
/**
* @import {
* CustomFieldControl,
* CustomFieldPreview,
* CustomFieldSchema,
* CustomFieldTypeDefinition,
* } from '../../../types/public';
*/
/**
* Register a custom field type (widget), which can be used with the `widget` field option.
* Registering a field type with the same name again replaces the previous one.
* `CMS.registerWidget()` is an alias of this method for compatibility with Netlify/Decap CMS. The
* field type can be given either as positional arguments or as a single definition object, which
* also takes a summary component.
* @param {string | CustomFieldTypeDefinition} name Field type name, which cannot be the name of a
* built-in field type, or a field type definition. With a definition, the other arguments are
* ignored.
* @param {CustomFieldControl | string} [control] React component for the edit pane, or the name of
* another custom field type whose control is reused. Required unless a definition is given.
* @param {CustomFieldPreview} [preview] React component for the preview pane. If omitted, no
* preview is rendered for the field.
* @param {CustomFieldSchema} [schema] JSON schema to validate the field type’s options in the CMS
* configuration.
* @throws {TypeError} If `name` is neither a non-empty string nor a definition object, the control
* is neither a React component nor a string, the preview or the summary is given but not a React
* component, or the schema is given but not an object.
* @throws {Error} If `name` is the name of a built-in field type.
* @see https://decapcms.org/docs/custom-widgets/
* @see https://sveltiacms.app/en/docs/api/field-types
*/
export function registerFieldType(name: string | CustomFieldTypeDefinition, control?: CustomFieldControl | string, preview?: CustomFieldPreview, schema?: CustomFieldSchema): void;
import type { CustomFieldTypeDefinition } from '../../../types/public';
import type { CustomFieldControl } from '../../../types/public';
import type { CustomFieldPreview } from '../../../types/public';
import type { CustomFieldSchema } from '../../../types/public';
@@ -0,0 +1,23 @@
/**
* Register a custom stylesheet to be applied to the entry preview pane. Multiple stylesheets can
* be registered. A stylesheet can be limited to the entries of a collection, or to a file in a
* file/singleton collection.
* @param {string} style URL or file path of a stylesheet, or a raw CSS string if the `raw` option
* is `true`. A relative path is resolved against the current page URL.
* @param {object} [options] Options.
* @param {boolean} [options.raw] Whether `style` is a raw CSS string. Default: `false`.
* @param {string} [options.collection] Name of the collection whose entries the stylesheet is
* applied to. Use `_singletons` for the singleton collection. Default: all collections.
* @param {string} [options.file] Name of the file in the file/singleton collection given with the
* `collection` option that the stylesheet is applied to. Default: all files in the collection.
* @throws {TypeError} If `style` is not a non-empty string, `raw` is not a boolean, `style` is not
* a valid URL or file path when `raw` is `false`, `collection` or `file` is given but not a
* non-empty string, or `file` is given without `collection`.
* @see https://decapcms.org/docs/customization/#registerpreviewstyle
* @see https://sveltiacms.app/en/docs/api/preview-styles
*/
export function registerPreviewStyle(style: string, { raw, collection, file }?: {
raw?: boolean | undefined;
collection?: string | undefined;
file?: string | undefined;
}): void;
@@ -0,0 +1,15 @@
/**
* @import { CustomPreviewTemplate } from '../../../types/public';
*/
/**
* Register a custom preview template, which replaces the default entry preview. Registering a
* template with the same name again replaces the previous one.
* @param {string} name Name of the entry collection, or of the file in a file/singleton collection,
* whose entries are previewed with the template.
* @param {CustomPreviewTemplate} component React component.
* @throws {TypeError} If `name` is not a non-empty string or `component` is not a React component.
* @see https://decapcms.org/docs/customization/#registerpreviewtemplate
* @see https://sveltiacms.app/en/docs/api/preview-templates
*/
export function registerPreviewTemplate(name: string, component: CustomPreviewTemplate): void;
import type { CustomPreviewTemplate } from '../../../types/public';
@@ -0,0 +1,24 @@
/**
* @import { StringTransformer } from '../../../types/public';
*/
/**
* Register a custom string transformation, which can be used in template tags like the built-in
* ones, e.g. `{{title | reverse}}` or `{{title | wrap('[', ']')}}`, in the contexts where string
* transformations are supported, such as the `summary` collection option and the Compute field’s
* `value` option. Registering a transformation with the same name again replaces the previous one.
* The transformation should be registered before the CMS is initialized, so it’s available when
* entry summaries and field values are first rendered.
* @param {string} name Transformation name, which can contain letters, digits and underscores, and
* cannot start with a digit or be the name of a built-in transformation, such as `upper`.
* @param {StringTransformer} transform Function that receives the value and a context
* object containing the `args` given to the transformation and the content `locale`, and returns
* the transformed string synchronously. If it throws an error or returns a Promise, the value is
* passed through unchanged, and the first such failure of the function is logged to the console.
* @throws {TypeError} If `name` is not a valid transformation name or `transform` is not a
* function.
* @throws {Error} If `name` is the name of a built-in transformation.
* @see https://github.com/decaporg/decap-cms/issues/3677
* @see https://sveltiacms.app/en/docs/api/string-transformations
*/
export function registerStringTransformation(name: string, transform: StringTransformer): void;
import type { StringTransformer } from '../../../types/public';
+22
View File
@@ -0,0 +1,22 @@
/**
* @import { RenderRichTextOptions } from '../../../types/public';
*/
/**
* Render a Markdown/rich text value into the given element with the same pipeline as the built-in
* RichText field preview: editor component previews (including nested components), Markdown
* parsing, syntax highlighting, image URL resolution and HTML sanitization. This is primarily
* intended for an editor component `toPreview()` that returns an `HTMLElement`, so the verbatim
* value of a nested RichText or Markdown field can be rendered recursively.
* @param {HTMLElement} target The element to render the preview into. The content is rendered
* asynchronously, and the element doesn’t have to be attached to the document yet.
* @param {string} value Markdown string.
* @param {RenderRichTextOptions} [options] Options.
* @returns {() => void} Function to remove the rendered preview and destroy any editor component
* previews within it. Call it when the target element is no longer needed, e.g. when the element
* preview receives an `Unmount` event.
* @throws {TypeError} If `target` is not an element, `value` is not a string, or `fieldConfig` is
* given but not an object.
* @see https://sveltiacms.app/en/docs/api/editor-components
*/
export function renderRichText(target: HTMLElement, value: string, { fieldConfig }?: RenderRichTextOptions): () => void;
import type { RenderRichTextOptions } from '../../../types/public';