@bettercms-ai/types 1.53.0 → 1.55.0
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 +45 -9
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4180,8 +4180,11 @@ declare function schemaHashInput(table: SchemaHashTable, def: Readonly<Record<st
|
|
|
4180
4180
|
|
|
4181
4181
|
/** The always-on inline marks, Lexical-era names kept as written (richtext ALWAYS_ON_FEATURES). */
|
|
4182
4182
|
declare const RICHTEXT_MARK_FEATURES: readonly ["bold", "italic", "underline", "strikethrough", "code", "highlight"];
|
|
4183
|
-
/**
|
|
4184
|
-
|
|
4183
|
+
/**
|
|
4184
|
+
* The toggleable capabilities stored configs already name, in their order (richtext
|
|
4185
|
+
* TOGGLEABLE_FEATURES), minus `headings`: that one is an alias for the six levels, not a feature.
|
|
4186
|
+
*/
|
|
4187
|
+
declare const RICHTEXT_TOGGLE_FEATURES: readonly ["blockquote", "horizontalRule", "orderedList", "unorderedList", "checklist", "link", "internalLink", "inlineImage", "videoEmbed", "codeBlock", "table", "columns"];
|
|
4185
4188
|
/** One feature per heading level, so a field can allow h2 and h3 without h1. */
|
|
4186
4189
|
declare const RICHTEXT_HEADING_FEATURES: readonly ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
4187
4190
|
/**
|
|
@@ -4190,8 +4193,11 @@ declare const RICHTEXT_HEADING_FEATURES: readonly ["h1", "h2", "h3", "h4", "h5",
|
|
|
4190
4193
|
* `videoEmbed` stays the video, so a field can take a video without taking an X post.
|
|
4191
4194
|
*/
|
|
4192
4195
|
declare const RICHTEXT_BLOCK_FEATURES: readonly ["gallery", "embed", "tableOfContents", "relatedPosts", "authorBio", "footnotes", "button"];
|
|
4193
|
-
/**
|
|
4194
|
-
|
|
4196
|
+
/**
|
|
4197
|
+
* The canonical features, in vocabulary order: what a normalised config holds and the full set
|
|
4198
|
+
* a field can be given. An alias (`headings`) is a name a config may carry but never a feature.
|
|
4199
|
+
*/
|
|
4200
|
+
declare const RICHTEXT_FEATURES: readonly ["bold", "italic", "underline", "strikethrough", "code", "highlight", "blockquote", "horizontalRule", "orderedList", "unorderedList", "checklist", "link", "internalLink", "inlineImage", "videoEmbed", "codeBlock", "table", "columns", "h1", "h2", "h3", "h4", "h5", "h6", "gallery", "embed", "tableOfContents", "relatedPosts", "authorBio", "footnotes", "button"];
|
|
4195
4201
|
type RichTextFeature = (typeof RICHTEXT_FEATURES)[number];
|
|
4196
4202
|
/**
|
|
4197
4203
|
* Legacy names → the canonical features they mean. A read expands them, and a write stores the
|
|
@@ -4200,10 +4206,10 @@ type RichTextFeature = (typeof RICHTEXT_FEATURES)[number];
|
|
|
4200
4206
|
*/
|
|
4201
4207
|
declare const RICHTEXT_FEATURE_ALIASES: Record<string, readonly RichTextFeature[]>;
|
|
4202
4208
|
/**
|
|
4203
|
-
* A stored or submitted feature list in canonical form: aliases expanded
|
|
4204
|
-
*
|
|
4205
|
-
* `unknown` keeps each name
|
|
4206
|
-
* log it and a writer can refuse it
|
|
4209
|
+
* A stored or submitted feature list in canonical form: aliases expanded, duplicates dropped,
|
|
4210
|
+
* VOCABULARY order, so two lists that mean the same thing are equal arrays (and RICHTEXT_FEATURES
|
|
4211
|
+
* is its own normal form). `unknown` keeps each name that is neither a feature nor an alias, as
|
|
4212
|
+
* written and once, so a reader can log it and a writer can refuse it (`richtext.feature_unknown:<name>`).
|
|
4207
4213
|
*/
|
|
4208
4214
|
declare function normaliseRichTextFeatures(names: readonly string[]): {
|
|
4209
4215
|
features: RichTextFeature[];
|
|
@@ -4225,4 +4231,34 @@ type RichTextRefusalCode = "block_not_accepted" | "derived_field" | "feature_unk
|
|
|
4225
4231
|
*/
|
|
4226
4232
|
declare const richTextRefusal: (code: RichTextRefusalCode, detail: string) => UiRefusal;
|
|
4227
4233
|
|
|
4228
|
-
|
|
4234
|
+
/**
|
|
4235
|
+
* What a delivered rich-text value carries for its embeds, beside its `html`: the one shape the
|
|
4236
|
+
* server writes (at html-cache build), the SDK surfaces and every renderer reads.
|
|
4237
|
+
*/
|
|
4238
|
+
/**
|
|
4239
|
+
* An X post's card, from the oEmbed fetch the server makes: plain strings, escaped by the
|
|
4240
|
+
* renderer, never X's markup. `date` is as X shows it ("Oct 24, 2026").
|
|
4241
|
+
*/
|
|
4242
|
+
interface EmbedCard {
|
|
4243
|
+
text: string;
|
|
4244
|
+
authorName: string;
|
|
4245
|
+
authorUrl?: string;
|
|
4246
|
+
date?: string;
|
|
4247
|
+
}
|
|
4248
|
+
/**
|
|
4249
|
+
* `cards` is keyed by the CANONICAL embed url (@bettercms-ai/richtext `canonicalEmbedUrl`), so a
|
|
4250
|
+
* post pasted two ways finds the same card. The site's opt-in to X's script is not here: it is a
|
|
4251
|
+
* page setting, so turning it on or off re-bakes no value's html.
|
|
4252
|
+
*/
|
|
4253
|
+
interface RichTextEmbeds {
|
|
4254
|
+
cards: Record<string, EmbedCard>;
|
|
4255
|
+
}
|
|
4256
|
+
|
|
4257
|
+
/**
|
|
4258
|
+
* The id a heading's words make, V2's `slugify` byte for byte, so V2's stored links keep working.
|
|
4259
|
+
* The one spelling: @bettercms-ai/richtext stamps it on every rendered h2/h3 and re-exports it,
|
|
4260
|
+
* and the kit's table of contents reads it from here without the Portable Text stack.
|
|
4261
|
+
*/
|
|
4262
|
+
declare const slugify: (s: string) => string;
|
|
4263
|
+
|
|
4264
|
+
export { type AlignToken, type AllowRule, type ApiError, type ApiKey, type ApiKeyPermission, type ApiKeyTokenType, type ArrayZoneConfig, type AssertEqual, type AuthResponse, type AuthSession, type AuthUser, BLOCK_BINDINGS, BLOCK_FIELD_TYPES, BLOCK_FIELD_TYPES_RENDERABLE_NOW, BODY_SCHEMA_ORIGINS, BREAKPOINTS, BUTTON_ACTIONS, BUTTON_FULL_WIDTH_INVALID, BUTTON_ICONS, BUTTON_ICON_NAMES, BUTTON_LOOK_KEYS, BUTTON_PLACEMENT_KEYS, BUTTON_SIZES, BUTTON_VARIANTS, type BetterCMSErrorCode, type BgToken, type BindingKind, type BlockBinding, type BlockHoverStyle, type BlockStyle, type BlockType, type BodySchema, type BodySchemaOrigin, type ButtonAction, type ButtonBlock, type ButtonIcon, type ButtonLinkCandidate, type ButtonLookKey, type ButtonProps, type ButtonSiteLook, type ButtonSizeName, type ButtonValue, type ButtonVariant, CANVAS_GESTURE_NAMES, CODE_SLOT_PREFIX, COMPONENT_PROP_TYPES, CONTROL_HELP, type CanonicalInputDefinition, type CanvasGesture, type ChoiceOption, type CollectionBlock, type CollectionFilter, type CollectionProps, type ColorToken, type ColumnsBlock, type ColumnsProps, type Component, type ComponentBlock, type ComponentCategory, type ComponentFormPropRef, type ComponentPreview, type ComponentPropDef, type ComponentPropType, type ComponentPropUi, type ComponentProps, type ComponentSubField, type ComponentTab, type ComponentV2, type ComponentVariantGroup, type Content, type ContentBlock, type ContentEntry, type ContentModel, type ContentModelField, type ContentModelFieldType, type ContentModelFieldUi, type ContentModelV2, type ContentPageResult, type ContentResponse, type ContentWidthToken, type ControlKind, type CornerToken, DEPTH_MAX, DERIVE_MINTED_RESERVED, DIALOG_SELECTOR, DOCK_BUDGET, DOCK_ICON_NAMES, DOCK_ICON_NAME_SET, type DeepReadonly, type DefSources, type DeliveredLayout, type DeliveryComponent, type DeliveryEntry, type DeliveryEntrySeo, type DeliveryList, type DeliveryPage, type DerivedLocator, type DockBudget, type DockFieldLike, type DockFieldsetLike, type DockIconName, type DockInputRef, type DockLane, type DockNode, type DockPropGroupLike, type DockScreen, type ElementLike, type EmbedCard, type ExpandedBinding, FIELD_SIZE_ZOOM, FIELD_STYLE_KEYS, FOOTER_SECTION_ID, type FieldConfig, type FieldSize, type FieldStyle, type FieldStyleKey, type FieldStyles, type Fieldset, type FieldsetKind, type FieldsetUiBefore, type FontSizeToken, type FooterBlock, type FooterColumn, type FooterProps, type Form, type FormBlock, type FormField, type FormProps, type FormSubmission, HELP_CAPS, HELP_MAX, type HeadingBlock, type HeadingProps, IMAGE_ASPECTS, IMAGE_FRAME_RADIUS, type ImageAspect, type ImageBlock, type ImageProps, KEY_FORBIDDEN, KEY_FORMAT, KEY_RESERVED, KEY_RESERVED_PREFIX, KIT_CATEGORIES, type KitCategory, LANDMARK_SELECTOR, LAYOUT_SECTION_ICONS, LAYOUT_SECTION_ICON_SET, LINK_RELS, LINK_VALUE_TYPES, LIST_ITEMS_CAP, LOCATOR_PATH, type LandmarkChainElement, type LandmarkElement, type LayoutComponentItem, type LayoutDataDocument, type LayoutFieldDefinition, type LayoutFieldItem, type LayoutFieldType, type LayoutScalarFieldType, type LayoutSection, type LayoutSectionIcon, type LayoutSectionItem, type LayoutStructureDocument, type LayoutZone, type LinkPairSibling, type LinkRel, type LinkValue, type LinkValueType, type LocatorGrammar, MAIN_SELECTOR, type ManagementLayoutCommand, type MediaAsset, type MediaCaptionTrack, type MediaFieldValue, NAVIGATION_SECTION_ID, type NavLink, type NavbarBlock, type NavbarProps, type NumberFieldFormat, type NumberScale, OPTION_DESCRIPTION_MAX, type OpenMode, PAGE_CONTENT_ANCHOR_ID, PRIMITIVE_ARRAY_RULE, type Page, type PageLayoutOverrideDataDocument, type PageLayoutOverrideDocument, type PageLayoutOverrideState, type PageLayoutOverrideStructureDocument, type PageLayoutSectionOverride, type PageLayoutSectionStructureOverride, type PageMetaJson, type PageOnlyLayoutSection, type PageSectionPlacement, type PaginatedResult, type Perspective, type PortableTextDocument, type PortableTextNode, type PropGroup, type PropTab, RESPONSIVE_CSS, RICHTEXT_ADVANCED_ELEMENTS, RICHTEXT_BLOCK_ELEMENTS, RICHTEXT_BLOCK_FEATURES, RICHTEXT_CORE_ELEMENTS, RICHTEXT_ELEMENTS, RICHTEXT_FEATURES, RICHTEXT_FEATURE_ALIASES, RICHTEXT_HEADING_FEATURES, RICHTEXT_MARK_FEATURES, RICHTEXT_TOGGLE_FEATURES, ROLE_HELP, ROLE_KEYS, type RadiusToken, type ReadButtonValue, type Redirect, type ReservedLayoutSection, type ResolvedLayoutNode, type RichTextBlock, type RichTextElementName, type RichTextEmbeds, type RichTextFeature, type RichTextProps, type RichTextRefusalCode, SCHEMA_HASH_INPUTS, SECTION_DOCTRINE, SECTION_SPACE_TOKENS, SEGMENTED_MAX, SEGMENTED_MIN, SIDE_SPACE_MIN_PX, SIDE_SPACE_TOKENS, SLOT_CHILD_KEYS, SLOT_ITEMS_CAP, SLOT_MAX_ITEMS, SLOT_SETTINGS_MAX, SLOT_SETTINGS_TYPES, SOURCE_RANK, SPACE_BOTTOM_TOKENS, SPACE_STEP_TOKENS, type ScaleUnit, type SchemaHashTable, type SchemaSource, type SectionBlock, type SectionPlanItem, type SectionProps, type SectionSpaceToken, type ShadowToken, type ShowIf, type ShowIfRule, type SignInInput, type SignUpInput, type SiteSeoDefaults, type SlideItem, type SliderBlock, type SliderProps, type SlotChild, type SlotItem, type SlotShapeOptions, type SlotShapeProblem, type SlotValue, type SourcedFacet, type SpaceStepToken, type SpaceToken, type SpacerBlock, type SpacerProps, TABLE_COLUMN_TYPES, TABLE_JSONLD_TYPES, TABLE_LIMITS, TABLE_RESPONSIVE, TAB_MAX, TAB_MAX_RENDERABLE_NOW, TAG_HEADS, type TabItem, type TableCell, type TableCellObject, type TableCellValue, type TableCheckOptions, type TableColumn, type TableColumnType, type TableFieldOptions, type TableFootnote, type TableGroup, type TableLink, type TableProblem, type TableRef, type TableRefResolved, type TableRow, type TableValue, type TabsBlock, type TabsProps, type TextBlock, type TextProps, type ThemeToken, UI_REFUSAL_CODES, type UiBefore, type UiOrigin, type UiRefusal, type UiRefusalFamily, type V2Placement, type V2Shape, type V2VariantMeta, V2_KEYS, V2_PLACEMENTS, V2_SHAPES, VIDEO_TRANSCRIPT_MAX, VIDEO_VALUE_KEYS, type VariantGroupV2, type VariantInputMapping, type VideoBlock, type VideoProps, type VideoValue, type VisibilityWindow, type WeightToken, type WindowState, type Workspace, type ZoneField, allowRuleOf, anchorTargetRel, blockStyleToColumnCss, blockStyleToCss, blockStyleToInnerCss, bodySchemaOf, buttonBlockProps, buttonFullWidthProblem, buttonIconOf, buttonIconSvg, buttonLinkPairs, buttonLookValue, buttonSiteLookOf, buttonValueOfInstance, buttonValueProblem, buttonVariantOf, candidateRole, canonicalJson, componentInstanceAddresses, componentPropTargetKey, derivedPairs, dockBudget, dockScreens, exampleFor, expandBlockBindings, fieldGroupOf, fieldStyleCssText, fieldStyleToCss, formatNumber, formatPropsAttribute, getBlockType, headingPaintCss, hiddenEverywhere, hideOnAttr, imageFrameCss, inWindow, isBlock, isButtonLookValue, isChromeLandmark, isCodeButton, isDeriveReservedKey, isLinkObject, isReservedKey, isRoleKey, isRulePaired, isScriptHref, isSlotChild, isTableValue, isUiRefusal, keyWords, landmarkRegions, linkAnchorOf, linkHref, linkRefOf, linkValueProblem, locatorFor, locatorPath, mayOverwrite, normaliseRichTextFeatures, normalizeLinkValue, normalizeTableValue, normalizeWindow, parseNumberText, parsePropsAttribute, pickFieldStyle, placementBindOf, planSections, readButtonValue, readNumberFormat, readPath, regionOf, renderTableHtml, richTextRefusal, rulePartnerOf, safeCssUrl, schemaHashInput, sideFloorApplies, sideSpaceCss, slotBindOf, slotChildValues, slotItems, slotPathString, slotShapeProblems, slugify, spaceTokenCss, splitButtonStyle, tableCellText, tablePathString, tableRefCells, tableSearchText, tableToMarkdown, tableValueProblems, topFieldKeyOf, uiRefusalId, usesHideOn, videoUrlOf, videoValueProblem, visibleBlocks, visibleDeliveredLayout, visibleLayoutStructure, windowState, withButtonLookProps, withExample };
|
package/dist/index.js
CHANGED
|
@@ -4723,7 +4723,6 @@ function schemaHashInput(table, def) {
|
|
|
4723
4723
|
// src/richtext-features.ts
|
|
4724
4724
|
var RICHTEXT_MARK_FEATURES = ["bold", "italic", "underline", "strikethrough", "code", "highlight"];
|
|
4725
4725
|
var RICHTEXT_TOGGLE_FEATURES = [
|
|
4726
|
-
"headings",
|
|
4727
4726
|
"blockquote",
|
|
4728
4727
|
"horizontalRule",
|
|
4729
4728
|
"orderedList",
|
|
@@ -4757,16 +4756,15 @@ var RICHTEXT_FEATURE_ALIASES = {
|
|
|
4757
4756
|
headings: RICHTEXT_HEADING_FEATURES
|
|
4758
4757
|
};
|
|
4759
4758
|
var KNOWN = new Set(RICHTEXT_FEATURES);
|
|
4760
|
-
var isAlias = (name) => Object.hasOwn(RICHTEXT_FEATURE_ALIASES, name);
|
|
4761
4759
|
function normaliseRichTextFeatures(names) {
|
|
4762
4760
|
const want = /* @__PURE__ */ new Set();
|
|
4763
4761
|
const unknown = [];
|
|
4764
4762
|
for (const name of names) {
|
|
4765
|
-
if (
|
|
4763
|
+
if (Object.hasOwn(RICHTEXT_FEATURE_ALIASES, name)) for (const f of RICHTEXT_FEATURE_ALIASES[name]) want.add(f);
|
|
4766
4764
|
else if (KNOWN.has(name)) want.add(name);
|
|
4767
4765
|
else if (!unknown.includes(name)) unknown.push(name);
|
|
4768
4766
|
}
|
|
4769
|
-
return { features: RICHTEXT_FEATURES.filter((f) => want.has(f)
|
|
4767
|
+
return { features: RICHTEXT_FEATURES.filter((f) => want.has(f)), unknown };
|
|
4770
4768
|
}
|
|
4771
4769
|
var RICHTEXT_CORE_ELEMENTS = [
|
|
4772
4770
|
"p",
|
|
@@ -4803,6 +4801,9 @@ var richTextRefusal = (code, detail) => ({
|
|
|
4803
4801
|
detail,
|
|
4804
4802
|
message: `richtext.${code}:${detail}`
|
|
4805
4803
|
});
|
|
4804
|
+
|
|
4805
|
+
// src/heading-id.ts
|
|
4806
|
+
var slugify = (s) => s.toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "section";
|
|
4806
4807
|
export {
|
|
4807
4808
|
BLOCK_BINDINGS,
|
|
4808
4809
|
BLOCK_FIELD_TYPES,
|
|
@@ -4975,6 +4976,7 @@ export {
|
|
|
4975
4976
|
slotItems,
|
|
4976
4977
|
slotPathString,
|
|
4977
4978
|
slotShapeProblems,
|
|
4979
|
+
slugify,
|
|
4978
4980
|
spaceTokenCss,
|
|
4979
4981
|
splitButtonStyle,
|
|
4980
4982
|
tableCellText,
|