ampless 1.0.0-beta.63 → 1.0.0-beta.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +43 -1
- package/dist/index.js +28 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -165,13 +165,55 @@ interface ThemeLinkListField extends Omit<ThemeFieldBase, 'default' | 'cssVar'>
|
|
|
165
165
|
maxItems?: number;
|
|
166
166
|
}
|
|
167
167
|
type ThemeField = ThemeColorField | ThemeTextField | ThemeSelectField | ThemeImageField | ThemeLengthField | ThemeFontFamilyField | ThemeLinkListField;
|
|
168
|
+
/**
|
|
169
|
+
* Where a theme-declared custom class can be applied. Only `table` is
|
|
170
|
+
* supported today: the class goes on the tiptap `table` node and renders
|
|
171
|
+
* as `tiptap-table--<id>` next to the base `tiptap-table` class.
|
|
172
|
+
*/
|
|
173
|
+
type ThemeCustomClassTarget = 'table';
|
|
174
|
+
/**
|
|
175
|
+
* A class the theme styles and that editors can opt a block into, e.g.
|
|
176
|
+
* `{ id: 'compact', label: 'Compact', target: 'table' }` with theme CSS for
|
|
177
|
+
* `.tiptap-table--compact`. The id must match `CUSTOM_CLASS_ID_PATTERN`.
|
|
178
|
+
*/
|
|
179
|
+
interface ThemeCustomClass {
|
|
180
|
+
id: string;
|
|
181
|
+
label: LocalizedString;
|
|
182
|
+
description?: LocalizedString;
|
|
183
|
+
target: ThemeCustomClassTarget;
|
|
184
|
+
}
|
|
168
185
|
interface ThemeManifest {
|
|
169
186
|
/** Theme directory name (`themes/<name>/`). */
|
|
170
187
|
name: string;
|
|
171
188
|
label: LocalizedString;
|
|
172
189
|
description?: LocalizedString;
|
|
173
190
|
fields: ReadonlyArray<ThemeField>;
|
|
191
|
+
/**
|
|
192
|
+
* Optional classes this theme styles and lets editors apply to blocks
|
|
193
|
+
* (see `ThemeCustomClass`). The admin editor offers the active theme's
|
|
194
|
+
* entries; ids stored in posts keep rendering after a theme switch.
|
|
195
|
+
*/
|
|
196
|
+
customClasses?: ReadonlyArray<ThemeCustomClass>;
|
|
174
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Allowed custom class ids: lowercase letters, digits and hyphens. The
|
|
200
|
+
* renderers re-check this on every render (post bodies can be written via
|
|
201
|
+
* MCP / GraphQL, not only through the admin), so an id can never break out
|
|
202
|
+
* of the `class` attribute.
|
|
203
|
+
*/
|
|
204
|
+
declare const CUSTOM_CLASS_ID_PATTERN: RegExp;
|
|
205
|
+
/** Max length of a custom class id (keeps generated class names sane). */
|
|
206
|
+
declare const CUSTOM_CLASS_ID_MAX_LENGTH = 64;
|
|
207
|
+
/** True when `id` is a string usable as a custom class id. */
|
|
208
|
+
declare function isValidCustomClassId(id: unknown): id is string;
|
|
209
|
+
/** Class name emitted for a table custom class id (`tiptap-table--<id>`). */
|
|
210
|
+
declare function tableCustomClassName(id: string): string;
|
|
211
|
+
/**
|
|
212
|
+
* Valid `target: 'table'` entries of a manifest, de-duplicated by id
|
|
213
|
+
* (first wins). Invalid ids are dropped with a console warning so a typo
|
|
214
|
+
* in a theme never reaches the editor or the markup.
|
|
215
|
+
*/
|
|
216
|
+
declare function themeTableClasses(manifest: Pick<ThemeManifest, 'customClasses' | 'name'>): ThemeCustomClass[];
|
|
175
217
|
declare function defineTheme(m: ThemeManifest): ThemeManifest;
|
|
176
218
|
/**
|
|
177
219
|
* Resolve a `LocalizedString` to a plain string for display.
|
|
@@ -2194,4 +2236,4 @@ declare function pickDefaultEntrypoint(files: readonly {
|
|
|
2194
2236
|
|
|
2195
2237
|
declare const VERSION = "0.0.1";
|
|
2196
2238
|
|
|
2197
|
-
export { type AiConfig, type AmplessEvent, type AmplessPlugin, type AuthContext, type BoundedScanOptions, type BoundedScanPage, type BoundedScanResult, type BoundedScanTruncation, type BundleExtractResult, type CacheConfig, type CacheStrategy, type Config, type ContentEventPayload, type ContentEventType, type ContentFieldRenderer, type ContentFormat, type ContentTypeDefinition, type CreatePostInput, DEFAULT_ENTRYPOINT, type DateFormat, type EventPayloadOf, type EventType, type ExtractedFile, type FieldDefinition, type FieldType, type HistoryConfig, type ImageDisplay, type KvItem, type KvStore, type LinkListItem, type ListOptions, type ListPostHistoryOptions, type LocalizedString, MAX_BUNDLE_BYTES, type MarkdownEmbedMatch, type Media, type MediaEventPayload, type MediaEventType, type MediaMetadata, type MediaProcessingDefaults, type OgImageConfig, type OgImageFont, type OgImageRenderContext, PLUGIN_KEY_PATTERN, type Page, type PluginBooleanField, type PluginCapability, type PluginCodeField, type PluginEventHandler, type PluginHookResult, type PluginJsonField, type PluginMetadata, type PluginNumberField, type PluginPackageManifest, type PluginPublicRenderContext, type PluginRepeatableField, type PluginRepeatableSubField, type PluginRuntimeContext, type PluginSecretField, type PluginSelectField, type PluginSettingField, type PluginSettingsManifest, type PluginTextField, type PluginTextareaField, type PluginUninstallContext, type PluginUrlField, type Post, type PostIndexEventPayload, type PostIndexEventType, type PostListFilterOptions, type PostListSort, type PostListStatusFilter, type PostMetadata, type PostRevision, type PostRevisionConnection, type PostStatus, type PostSummary, type PostsProvider, type PublicBodyDescriptor, type PublicHeadDescriptor, type PublicPostBodyDescriptor, type PublicPostHtmlDescriptor, type PublicPostHtmlPosition, type PublicPostScriptDescriptor, type Role, SITE_CONFIG_PK, type ScriptStrategy, type SiteSettingsEventPayload, type SiteSettingsEventType, type StaticPostBody, type StaticPostFileMeta, type StreamEventName, type SummaryListOptions, TEXT_EXTENSIONS, type ThemeColorField, type ThemeField, type ThemeFieldType, type ThemeFontFamilyField, type ThemeImageField, type ThemeLengthField, type ThemeLinkListField, type ThemeManifest, type ThemeModule, type ThemeRouteContext, type ThemeSelectField, type ThemeTextField, type TiptapNodeHtmlAdapters, type TiptapNodeMarkdownAdapters, type TiptapNodeToHtml, type TiptapNodeToMarkdown, type TiptapRenderNode, type TrustLevel, type TrustedPluginRuntimeContext, VERSION, type ValidationIssue, bundlePrefix, collectBounded, collectTags, createPost, decodeAwsJson, defineConfig, definePlugin, defineSchema, defineTheme, defineThemeModule, deletePost, deleteSiteSetting, detectContentEvents, encodeAwsJson, escapeXml, extractFirstImageUrl, filterSortPostSummaries, findAbsolutePathRefs, flattenSettings, formatColorPair, formatDate, formatPublicAssetUrl, getKvStore, getPost, getPostById, getSiteSetting, hasKvStore, hasPostsProvider, isTagListUrl, isValidPluginKey, listPostHistory, listPostSummaries, listPosts, listSiteSettings, mimeTypeFor, parseColorPair, parseLinkList, pickDefaultEntrypoint, resolveLocalized, resolvePluginSettings, resolvePublicMcpEndpoint, resolveThemeValues, setKvStore, setPostsProvider, setSiteSetting, stringifyLinkList, stripCommonPrefix, themeSettingKey, unflattenSettings, updatePost, validateBundle, validateBundlePath, validatePluginSettingValue, validatePublicAssetKey, validateThemeValue };
|
|
2239
|
+
export { type AiConfig, type AmplessEvent, type AmplessPlugin, type AuthContext, type BoundedScanOptions, type BoundedScanPage, type BoundedScanResult, type BoundedScanTruncation, type BundleExtractResult, CUSTOM_CLASS_ID_MAX_LENGTH, CUSTOM_CLASS_ID_PATTERN, type CacheConfig, type CacheStrategy, type Config, type ContentEventPayload, type ContentEventType, type ContentFieldRenderer, type ContentFormat, type ContentTypeDefinition, type CreatePostInput, DEFAULT_ENTRYPOINT, type DateFormat, type EventPayloadOf, type EventType, type ExtractedFile, type FieldDefinition, type FieldType, type HistoryConfig, type ImageDisplay, type KvItem, type KvStore, type LinkListItem, type ListOptions, type ListPostHistoryOptions, type LocalizedString, MAX_BUNDLE_BYTES, type MarkdownEmbedMatch, type Media, type MediaEventPayload, type MediaEventType, type MediaMetadata, type MediaProcessingDefaults, type OgImageConfig, type OgImageFont, type OgImageRenderContext, PLUGIN_KEY_PATTERN, type Page, type PluginBooleanField, type PluginCapability, type PluginCodeField, type PluginEventHandler, type PluginHookResult, type PluginJsonField, type PluginMetadata, type PluginNumberField, type PluginPackageManifest, type PluginPublicRenderContext, type PluginRepeatableField, type PluginRepeatableSubField, type PluginRuntimeContext, type PluginSecretField, type PluginSelectField, type PluginSettingField, type PluginSettingsManifest, type PluginTextField, type PluginTextareaField, type PluginUninstallContext, type PluginUrlField, type Post, type PostIndexEventPayload, type PostIndexEventType, type PostListFilterOptions, type PostListSort, type PostListStatusFilter, type PostMetadata, type PostRevision, type PostRevisionConnection, type PostStatus, type PostSummary, type PostsProvider, type PublicBodyDescriptor, type PublicHeadDescriptor, type PublicPostBodyDescriptor, type PublicPostHtmlDescriptor, type PublicPostHtmlPosition, type PublicPostScriptDescriptor, type Role, SITE_CONFIG_PK, type ScriptStrategy, type SiteSettingsEventPayload, type SiteSettingsEventType, type StaticPostBody, type StaticPostFileMeta, type StreamEventName, type SummaryListOptions, TEXT_EXTENSIONS, type ThemeColorField, type ThemeCustomClass, type ThemeCustomClassTarget, type ThemeField, type ThemeFieldType, type ThemeFontFamilyField, type ThemeImageField, type ThemeLengthField, type ThemeLinkListField, type ThemeManifest, type ThemeModule, type ThemeRouteContext, type ThemeSelectField, type ThemeTextField, type TiptapNodeHtmlAdapters, type TiptapNodeMarkdownAdapters, type TiptapNodeToHtml, type TiptapNodeToMarkdown, type TiptapRenderNode, type TrustLevel, type TrustedPluginRuntimeContext, VERSION, type ValidationIssue, bundlePrefix, collectBounded, collectTags, createPost, decodeAwsJson, defineConfig, definePlugin, defineSchema, defineTheme, defineThemeModule, deletePost, deleteSiteSetting, detectContentEvents, encodeAwsJson, escapeXml, extractFirstImageUrl, filterSortPostSummaries, findAbsolutePathRefs, flattenSettings, formatColorPair, formatDate, formatPublicAssetUrl, getKvStore, getPost, getPostById, getSiteSetting, hasKvStore, hasPostsProvider, isTagListUrl, isValidCustomClassId, isValidPluginKey, listPostHistory, listPostSummaries, listPosts, listSiteSettings, mimeTypeFor, parseColorPair, parseLinkList, pickDefaultEntrypoint, resolveLocalized, resolvePluginSettings, resolvePublicMcpEndpoint, resolveThemeValues, setKvStore, setPostsProvider, setSiteSetting, stringifyLinkList, stripCommonPrefix, tableCustomClassName, themeSettingKey, themeTableClasses, unflattenSettings, updatePost, validateBundle, validateBundlePath, validatePluginSettingValue, validatePublicAssetKey, validateThemeValue };
|
package/dist/index.js
CHANGED
|
@@ -772,6 +772,29 @@ function detectContentEvents(input) {
|
|
|
772
772
|
}
|
|
773
773
|
|
|
774
774
|
// src/theme.ts
|
|
775
|
+
var CUSTOM_CLASS_ID_PATTERN = /^[a-z0-9-]+$/;
|
|
776
|
+
var CUSTOM_CLASS_ID_MAX_LENGTH = 64;
|
|
777
|
+
function isValidCustomClassId(id) {
|
|
778
|
+
return typeof id === "string" && id.length > 0 && id.length <= CUSTOM_CLASS_ID_MAX_LENGTH && CUSTOM_CLASS_ID_PATTERN.test(id);
|
|
779
|
+
}
|
|
780
|
+
function tableCustomClassName(id) {
|
|
781
|
+
return `tiptap-table--${id}`;
|
|
782
|
+
}
|
|
783
|
+
function themeTableClasses(manifest) {
|
|
784
|
+
const out = [];
|
|
785
|
+
const seen = /* @__PURE__ */ new Set();
|
|
786
|
+
for (const c of manifest.customClasses ?? []) {
|
|
787
|
+
if (c?.target !== "table") continue;
|
|
788
|
+
if (!isValidCustomClassId(c.id)) {
|
|
789
|
+
console.warn(`[ampless] theme "${manifest.name}": ignoring custom class with invalid id ${JSON.stringify(c?.id)}`);
|
|
790
|
+
continue;
|
|
791
|
+
}
|
|
792
|
+
if (seen.has(c.id)) continue;
|
|
793
|
+
seen.add(c.id);
|
|
794
|
+
out.push(c);
|
|
795
|
+
}
|
|
796
|
+
return out;
|
|
797
|
+
}
|
|
775
798
|
function defineTheme(m) {
|
|
776
799
|
return m;
|
|
777
800
|
}
|
|
@@ -924,6 +947,8 @@ function defaultValueAsString(field) {
|
|
|
924
947
|
// src/index.ts
|
|
925
948
|
var VERSION = "0.0.1";
|
|
926
949
|
export {
|
|
950
|
+
CUSTOM_CLASS_ID_MAX_LENGTH,
|
|
951
|
+
CUSTOM_CLASS_ID_PATTERN,
|
|
927
952
|
DEFAULT_ENTRYPOINT,
|
|
928
953
|
MAX_BUNDLE_BYTES,
|
|
929
954
|
PLUGIN_KEY_PATTERN,
|
|
@@ -959,6 +984,7 @@ export {
|
|
|
959
984
|
hasKvStore,
|
|
960
985
|
hasPostsProvider,
|
|
961
986
|
isTagListUrl,
|
|
987
|
+
isValidCustomClassId,
|
|
962
988
|
isValidPluginKey,
|
|
963
989
|
listPostHistory,
|
|
964
990
|
listPostSummaries,
|
|
@@ -977,7 +1003,9 @@ export {
|
|
|
977
1003
|
setSiteSetting,
|
|
978
1004
|
stringifyLinkList,
|
|
979
1005
|
stripCommonPrefix,
|
|
1006
|
+
tableCustomClassName,
|
|
980
1007
|
themeSettingKey,
|
|
1008
|
+
themeTableClasses,
|
|
981
1009
|
unflattenSettings,
|
|
982
1010
|
updatePost,
|
|
983
1011
|
validateBundle,
|