@bettercms-ai/sdk 1.30.0 → 1.31.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.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _bettercms_ai_types from '@bettercms-ai/types';
2
- import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, BetterCMSErrorCode, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Perspective, DeliveryEntry, DeliveryList, DeliveryPage, DeliveryComponent, PageMetaJson, DeliveryEntrySeo, SiteSeoDefaults, Page, MediaAsset, FormField, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
2
+ import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, BetterCMSErrorCode, ComponentPreview, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Perspective, DeliveryEntry, DeliveryList, DeliveryPage, DeliveryComponent, PageMetaJson, DeliveryEntrySeo, SiteSeoDefaults, Page, MediaAsset, FormField, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
3
3
  export { ApiError, ApiKey, ApiKeyPermission, ApiKeyTokenType, AssertEqual, AuthSession, AuthUser, BetterCMSErrorCode, BlockType, ButtonBlock, ButtonProps, ColumnsBlock, ColumnsProps, Content, ContentBlock, ContentEntry, ContentModel, ContentModelField, ContentPageResult, ContentResponse, DeepReadonly, DeliveryComponent, DeliveryEntry, DeliveryList, DeliveryPage, Form, FormBlock, FormField, FormProps, FormSubmission, HeadingBlock, HeadingProps, ImageBlock, ImageProps, MediaAsset, Page, PageMetaJson, PaginatedResult, Perspective, Redirect, SignInInput, SignUpInput, SiteSeoDefaults, SpacerBlock, SpacerProps, TextBlock, TextProps, VideoBlock, VideoProps, Workspace, getBlockType, isBlock } from '@bettercms-ai/types';
4
4
  export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder, imageValueObjectPosition, imageValueUrl } from '@bettercms-ai/image-url';
5
5
 
@@ -766,6 +766,10 @@ interface ManagedComponent {
766
766
  }>;
767
767
  }> | null;
768
768
  thumbnail?: string | null;
769
+ /** How an instance reads as a row in a parent's slot list. @see ComponentPreview */
770
+ preview?: ComponentPreview | null;
771
+ /** The block icon (a /kit schema's document-level `icon`), a dock icon name. */
772
+ icon?: string | null;
769
773
  /** Send it back as `ifMatch` on updateComponent. */
770
774
  optimisticVersion?: number;
771
775
  }
@@ -785,6 +789,10 @@ interface ManagedComponentInput {
785
789
  group?: string;
786
790
  groupId?: string | null;
787
791
  description?: string;
792
+ /** title/subtitle/media name top-level prop keys (422 `preview_key_unknown` otherwise); null clears it. */
793
+ preview?: ComponentPreview | null;
794
+ /** The block icon, a dock icon name (bettercms://icons/dock); null clears it. */
795
+ icon?: string | null;
788
796
  blockJson?: unknown[];
789
797
  props?: unknown[];
790
798
  /**
@@ -1425,6 +1433,16 @@ declare function plain(value: TextOrRich): string;
1425
1433
  * alone, so a body field still renders as a document.
1426
1434
  */
1427
1435
  declare function rich(value: TextOrRich, fallback?: string): string;
1436
+ /**
1437
+ * Renderable HTML for a ONE-LINE place: a heading, a button, a caption. `rich()`, except that several
1438
+ * paragraphs are that place's LINES, joined with `<br>` (a heading-styled first block counts as one).
1439
+ *
1440
+ * An author who presses Enter in a heading's editor stores a second paragraph. `rich()` leaves it a
1441
+ * paragraph, and `<h1><p>…</p><p>…</p></h1>` is what the build then draws, while a publish between
1442
+ * builds writes the same value into the built heading as lines. This draws what the publish draws.
1443
+ * A value holding anything else (a list, an image, a table) is returned as `rich()` returns it.
1444
+ */
1445
+ declare function lines(value: TextOrRich, fallback?: string): string;
1428
1446
 
1429
1447
  /**
1430
1448
  * resolveSeo — framework-agnostic page-over-site SEO merge for headless consumers.
@@ -1896,4 +1914,29 @@ interface WebhookListResponse {
1896
1914
  };
1897
1915
  }
1898
1916
 
1899
- export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, CONTENT_APPLIED, type CommandManagedLayoutInput, type ContentAppliedMessage, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedMediaAsset, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, PORTABLE_TEXT_FORMAT, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type PublishedContent, type ResolvedSeo, type RichTextValue, STEGA_OPEN, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type TextOrRich, type UpdateApiKeyInput, type UpdateAssetInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWebhookInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type Webhook, type WebhookAdvancedConfig, type WebhookEvent, type WebhookListResponse, type WebhookWithSecret, type WriteContentInput, addModelFields, addPageFields, asStringArray, commandManagedLayout, contentApplied, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, onContentApplied, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveSeo, resolveStega, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
1917
+ /**
1918
+ * `inEditor()`: is this page running inside the BetterCMS Visual Editor's canvas?
1919
+ *
1920
+ * The editor frames the site and names the frame, so the answer is the page's own `window.name`:
1921
+ * there from the first script, kept through every navigation inside the frame, and never set on
1922
+ * a published page a visitor opens. A site asks before it starts what the canvas cannot share:
1923
+ *
1924
+ * const smooth = inEditor() ? null : new LocomotiveScroll({ el, smooth: true });
1925
+ *
1926
+ * The canvas owns the scroll, the pointer and the place on the page; the site's motion (scroll
1927
+ * triggers, timelines, WebGL scenes) runs there as it does live. What has to stand down is only
1928
+ * what takes those three away: scroll that is not the window's own, an intro that holds the
1929
+ * page, a cursor drawn over it.
1930
+ */
1931
+ /** The canvas frame's name. The dashboard sets this exact word (`EDITOR_FRAME_NAME`). */
1932
+ declare const EDITOR_FRAME_NAME = "bcms-editor";
1933
+ /** The least of `window` this needs. */
1934
+ interface FramedWindow {
1935
+ name: string;
1936
+ self: unknown;
1937
+ top: unknown;
1938
+ }
1939
+ /** True inside the editor's canvas. Safe where there is no window (a server render): false. */
1940
+ declare function inEditor(win?: FramedWindow | undefined): boolean;
1941
+
1942
+ export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, CONTENT_APPLIED, type CommandManagedLayoutInput, type ContentAppliedMessage, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, EDITOR_FRAME_NAME, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedMediaAsset, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, PORTABLE_TEXT_FORMAT, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type PublishedContent, type ResolvedSeo, type RichTextValue, STEGA_OPEN, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type TextOrRich, type UpdateApiKeyInput, type UpdateAssetInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWebhookInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type Webhook, type WebhookAdvancedConfig, type WebhookEvent, type WebhookListResponse, type WebhookWithSecret, type WriteContentInput, addModelFields, addPageFields, asStringArray, commandManagedLayout, contentApplied, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inEditor, inviteMember, isMultiValueField, isRichText, lines, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, onContentApplied, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveSeo, resolveStega, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _bettercms_ai_types from '@bettercms-ai/types';
2
- import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, BetterCMSErrorCode, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Perspective, DeliveryEntry, DeliveryList, DeliveryPage, DeliveryComponent, PageMetaJson, DeliveryEntrySeo, SiteSeoDefaults, Page, MediaAsset, FormField, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
2
+ import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, BetterCMSErrorCode, ComponentPreview, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Perspective, DeliveryEntry, DeliveryList, DeliveryPage, DeliveryComponent, PageMetaJson, DeliveryEntrySeo, SiteSeoDefaults, Page, MediaAsset, FormField, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
3
3
  export { ApiError, ApiKey, ApiKeyPermission, ApiKeyTokenType, AssertEqual, AuthSession, AuthUser, BetterCMSErrorCode, BlockType, ButtonBlock, ButtonProps, ColumnsBlock, ColumnsProps, Content, ContentBlock, ContentEntry, ContentModel, ContentModelField, ContentPageResult, ContentResponse, DeepReadonly, DeliveryComponent, DeliveryEntry, DeliveryList, DeliveryPage, Form, FormBlock, FormField, FormProps, FormSubmission, HeadingBlock, HeadingProps, ImageBlock, ImageProps, MediaAsset, Page, PageMetaJson, PaginatedResult, Perspective, Redirect, SignInInput, SignUpInput, SiteSeoDefaults, SpacerBlock, SpacerProps, TextBlock, TextProps, VideoBlock, VideoProps, Workspace, getBlockType, isBlock } from '@bettercms-ai/types';
4
4
  export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder, imageValueObjectPosition, imageValueUrl } from '@bettercms-ai/image-url';
5
5
 
@@ -766,6 +766,10 @@ interface ManagedComponent {
766
766
  }>;
767
767
  }> | null;
768
768
  thumbnail?: string | null;
769
+ /** How an instance reads as a row in a parent's slot list. @see ComponentPreview */
770
+ preview?: ComponentPreview | null;
771
+ /** The block icon (a /kit schema's document-level `icon`), a dock icon name. */
772
+ icon?: string | null;
769
773
  /** Send it back as `ifMatch` on updateComponent. */
770
774
  optimisticVersion?: number;
771
775
  }
@@ -785,6 +789,10 @@ interface ManagedComponentInput {
785
789
  group?: string;
786
790
  groupId?: string | null;
787
791
  description?: string;
792
+ /** title/subtitle/media name top-level prop keys (422 `preview_key_unknown` otherwise); null clears it. */
793
+ preview?: ComponentPreview | null;
794
+ /** The block icon, a dock icon name (bettercms://icons/dock); null clears it. */
795
+ icon?: string | null;
788
796
  blockJson?: unknown[];
789
797
  props?: unknown[];
790
798
  /**
@@ -1425,6 +1433,16 @@ declare function plain(value: TextOrRich): string;
1425
1433
  * alone, so a body field still renders as a document.
1426
1434
  */
1427
1435
  declare function rich(value: TextOrRich, fallback?: string): string;
1436
+ /**
1437
+ * Renderable HTML for a ONE-LINE place: a heading, a button, a caption. `rich()`, except that several
1438
+ * paragraphs are that place's LINES, joined with `<br>` (a heading-styled first block counts as one).
1439
+ *
1440
+ * An author who presses Enter in a heading's editor stores a second paragraph. `rich()` leaves it a
1441
+ * paragraph, and `<h1><p>…</p><p>…</p></h1>` is what the build then draws, while a publish between
1442
+ * builds writes the same value into the built heading as lines. This draws what the publish draws.
1443
+ * A value holding anything else (a list, an image, a table) is returned as `rich()` returns it.
1444
+ */
1445
+ declare function lines(value: TextOrRich, fallback?: string): string;
1428
1446
 
1429
1447
  /**
1430
1448
  * resolveSeo — framework-agnostic page-over-site SEO merge for headless consumers.
@@ -1896,4 +1914,29 @@ interface WebhookListResponse {
1896
1914
  };
1897
1915
  }
1898
1916
 
1899
- export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, CONTENT_APPLIED, type CommandManagedLayoutInput, type ContentAppliedMessage, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedMediaAsset, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, PORTABLE_TEXT_FORMAT, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type PublishedContent, type ResolvedSeo, type RichTextValue, STEGA_OPEN, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type TextOrRich, type UpdateApiKeyInput, type UpdateAssetInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWebhookInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type Webhook, type WebhookAdvancedConfig, type WebhookEvent, type WebhookListResponse, type WebhookWithSecret, type WriteContentInput, addModelFields, addPageFields, asStringArray, commandManagedLayout, contentApplied, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, onContentApplied, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveSeo, resolveStega, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
1917
+ /**
1918
+ * `inEditor()`: is this page running inside the BetterCMS Visual Editor's canvas?
1919
+ *
1920
+ * The editor frames the site and names the frame, so the answer is the page's own `window.name`:
1921
+ * there from the first script, kept through every navigation inside the frame, and never set on
1922
+ * a published page a visitor opens. A site asks before it starts what the canvas cannot share:
1923
+ *
1924
+ * const smooth = inEditor() ? null : new LocomotiveScroll({ el, smooth: true });
1925
+ *
1926
+ * The canvas owns the scroll, the pointer and the place on the page; the site's motion (scroll
1927
+ * triggers, timelines, WebGL scenes) runs there as it does live. What has to stand down is only
1928
+ * what takes those three away: scroll that is not the window's own, an intro that holds the
1929
+ * page, a cursor drawn over it.
1930
+ */
1931
+ /** The canvas frame's name. The dashboard sets this exact word (`EDITOR_FRAME_NAME`). */
1932
+ declare const EDITOR_FRAME_NAME = "bcms-editor";
1933
+ /** The least of `window` this needs. */
1934
+ interface FramedWindow {
1935
+ name: string;
1936
+ self: unknown;
1937
+ top: unknown;
1938
+ }
1939
+ /** True inside the editor's canvas. Safe where there is no window (a server render): false. */
1940
+ declare function inEditor(win?: FramedWindow | undefined): boolean;
1941
+
1942
+ export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, CONTENT_APPLIED, type CommandManagedLayoutInput, type ContentAppliedMessage, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, EDITOR_FRAME_NAME, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedMediaAsset, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, PORTABLE_TEXT_FORMAT, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type PublishedContent, type ResolvedSeo, type RichTextValue, STEGA_OPEN, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type TextOrRich, type UpdateApiKeyInput, type UpdateAssetInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWebhookInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type Webhook, type WebhookAdvancedConfig, type WebhookEvent, type WebhookListResponse, type WebhookWithSecret, type WriteContentInput, addModelFields, addPageFields, asStringArray, commandManagedLayout, contentApplied, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inEditor, inviteMember, isMultiValueField, isRichText, lines, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, onContentApplied, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveSeo, resolveStega, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
package/dist/index.js CHANGED
@@ -1461,6 +1461,15 @@ function rich(value, fallback = "") {
1461
1461
  const html = (typeof value === "string" ? escapeHtml(value) : isRichText(value) ? value.html ?? "" : "").trim();
1462
1462
  return html ? unwrapLoneBlock(html) : escapeHtml(fallback);
1463
1463
  }
1464
+ function lines(value, fallback = "") {
1465
+ const html = rich(value, fallback);
1466
+ const block = /<(p|h[1-6])(?:\s[^>]*)?>([\s\S]*?)<\/\1>/gi;
1467
+ if (html.length > 1e4) return html;
1468
+ const found = [...html.matchAll(block)];
1469
+ if (found.length < 2 || html.replace(block, "").trim() !== "") return html;
1470
+ const shown = found.map((m) => m[2].trim()).filter((line) => line.replace(/<br\s*\/?>/gi, "").trim() !== "");
1471
+ return shown.length ? shown.join("<br>") : html;
1472
+ }
1464
1473
  function unwrapLoneBlock(html) {
1465
1474
  const m = html.match(/^<(p|div|h[1-6])(?:\s[^>]*)?>([\s\S]*)<\/\1>$/i);
1466
1475
  return m && !new RegExp(`</${m[1]}>`, "i").test(m[2]) ? m[2] : html;
@@ -1951,6 +1960,16 @@ async function submitForm(opts) {
1951
1960
 
1952
1961
  // src/index.ts
1953
1962
  import { isBlock, getBlockType } from "@bettercms-ai/types";
1963
+
1964
+ // src/in-editor.ts
1965
+ var EDITOR_FRAME_NAME = "bcms-editor";
1966
+ function inEditor(win = globalThis.window) {
1967
+ try {
1968
+ return !!win && win.name === EDITOR_FRAME_NAME && win.self !== win.top;
1969
+ } catch {
1970
+ return false;
1971
+ }
1972
+ }
1954
1973
  export {
1955
1974
  BetterCMSError as BCMSClientError,
1956
1975
  ErrorCodes as BCMSErrorCodes,
@@ -1960,6 +1979,7 @@ export {
1960
1979
  BetterCMSError,
1961
1980
  BetterCMSManagementClient,
1962
1981
  CONTENT_APPLIED,
1982
+ EDITOR_FRAME_NAME,
1963
1983
  ErrorCodes,
1964
1984
  PORTABLE_TEXT_FORMAT,
1965
1985
  STEGA_OPEN,
@@ -2001,10 +2021,12 @@ export {
2001
2021
  default2 as imageUrlBuilder,
2002
2022
  imageValueObjectPosition,
2003
2023
  imageValueUrl,
2024
+ inEditor,
2004
2025
  inviteMember,
2005
2026
  isBlock,
2006
2027
  isMultiValueField,
2007
2028
  isRichText,
2029
+ lines,
2008
2030
  listApiKeys,
2009
2031
  listEntries,
2010
2032
  listForms2 as listForms,