@tinacms/schema-tools 2.7.4 → 2.8.1

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 CHANGED
@@ -4,3 +4,4 @@ export * from './validate';
4
4
  export * from './util/namer';
5
5
  export * from './util/parseURL';
6
6
  export * from './util/normalizePath';
7
+ export * from './util/headingLevels';
package/dist/index.js CHANGED
@@ -2292,6 +2292,14 @@ const CONTENT_FORMATS = [
2292
2292
  "yml",
2293
2293
  "toml"
2294
2294
  ];
2295
+ const ALL_HEADING_LEVELS = [
2296
+ "h1",
2297
+ "h2",
2298
+ "h3",
2299
+ "h4",
2300
+ "h5",
2301
+ "h6"
2302
+ ];
2295
2303
  const parseZodError = ({ zodError }) => {
2296
2304
  var _a, _b, _c, _d;
2297
2305
  const errors = zodError.flatten((issue) => {
@@ -2804,7 +2812,29 @@ const validateSchema = ({ schema }) => {
2804
2812
  throw new Error(e);
2805
2813
  }
2806
2814
  };
2815
+ const isHeadingLevel = (value) => {
2816
+ switch (value) {
2817
+ case "h1":
2818
+ case "h2":
2819
+ case "h3":
2820
+ case "h4":
2821
+ case "h5":
2822
+ case "h6":
2823
+ return true;
2824
+ default:
2825
+ return false;
2826
+ }
2827
+ };
2828
+ const normalizeHeadingLevels = (configured) => {
2829
+ const seen = /* @__PURE__ */ new Set();
2830
+ for (const level of configured) {
2831
+ if (isHeadingLevel(level))
2832
+ seen.add(level);
2833
+ }
2834
+ return Array.from(seen);
2835
+ };
2807
2836
  export {
2837
+ ALL_HEADING_LEVELS,
2808
2838
  CONTENT_FORMATS,
2809
2839
  NAMER,
2810
2840
  TINA_HOST,
@@ -2812,6 +2842,8 @@ export {
2812
2842
  TinaSchemaValidationError,
2813
2843
  addNamespaceToSchema,
2814
2844
  canonicalPath,
2845
+ isHeadingLevel,
2846
+ normalizeHeadingLevels,
2815
2847
  normalizePath,
2816
2848
  parseURL,
2817
2849
  resolveField,
@@ -255,6 +255,13 @@ export type DisplayOnlyField = BaseField & {
255
255
  };
256
256
  };
257
257
  export type ToolbarOverrideType = 'heading' | 'link' | 'image' | 'quote' | 'ul' | 'ol' | 'code' | 'codeBlock' | 'bold' | 'italic' | 'strikethrough' | 'highlight' | 'raw' | 'embed' | 'mermaid' | 'table' | 'hr';
258
+ /**
259
+ * Heading node type as used by the rich-text editor. Mirrors
260
+ * `@udecode/plate-heading`'s `HEADING_KEYS` so consumers can pass these
261
+ * values straight through without translation.
262
+ */
263
+ export type HeadingLevel = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
264
+ export declare const ALL_HEADING_LEVELS: readonly HeadingLevel[];
258
265
  type RichTextAst = {
259
266
  type: 'root';
260
267
  children: Record<string, unknown>[];
@@ -274,6 +281,16 @@ export type RichTextField<WithNamespace extends boolean = false> = (FieldGeneric
274
281
  toolbar?: ToolbarOverrideType[];
275
282
  /**Default set to true */
276
283
  showFloatingToolbar?: boolean;
284
+ /**
285
+ * Restricts which heading levels are offered in the editor UI
286
+ * (headings dropdown, "Turn into" menu, slash menu, and markdown
287
+ * autoformat shortcuts like `## `). When omitted, all levels are
288
+ * available. UI-only — existing content with disallowed levels is
289
+ * rendered as-is.
290
+ *
291
+ * @example headingLevels: ['h1', 'h2', 'h3']
292
+ */
293
+ headingLevels?: HeadingLevel[];
277
294
  };
278
295
  /**
279
296
  * By default, Tina parses markdown with MDX, this is a more strict parser
@@ -563,6 +580,23 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
563
580
  * If your site will be served at a sub-path like `my-domain.com/my-site`, provide `"my-site"`
564
581
  */
565
582
  basePath?: string;
583
+ /**
584
+ * Additional npm packages to externalize when bundling `tina/database.ts`.
585
+ *
586
+ * Tina automatically externalizes a known-good baseline (currently `better-sqlite3`).
587
+ * Use this list for native modules or packages outside that baseline that cannot be
588
+ * bundled by esbuild — for example, custom database adapters that ship native bindings.
589
+ *
590
+ * Externalized packages must be installed in your project's `node_modules` so Node can
591
+ * resolve them at runtime.
592
+ *
593
+ * @example
594
+ * build: {
595
+ * // ...other build options
596
+ * externalDependencies: ['my-custom-native-adapter'],
597
+ * }
598
+ */
599
+ externalDependencies?: string[];
566
600
  };
567
601
  /**
568
602
  * Configuration for the local development server (`tinacms dev`).
@@ -0,0 +1,14 @@
1
+ import { type HeadingLevel } from '../types/index';
2
+ /**
3
+ * Cast-free type guard for HeadingLevel. The exhaustive switch lets TS
4
+ * narrow `string` → `HeadingLevel` without an `as` cast, so it doubles
5
+ * as a runtime validator for untrusted (pure-JS) schema input.
6
+ */
7
+ export declare const isHeadingLevel: (value: string) => value is HeadingLevel;
8
+ /**
9
+ * Filters out values that aren't real HeadingLevels (a JS schema can
10
+ * declare anything at runtime), dedupes, and preserves the order the
11
+ * user wrote. Returns an empty array when no valid levels remain — an
12
+ * explicit `[]` therefore means "no headings", not "fall back to all".
13
+ */
14
+ export declare const normalizeHeadingLevels: (configured: readonly string[]) => readonly HeadingLevel[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tinacms/schema-tools",
3
3
  "type": "module",
4
- "version": "2.7.4",
4
+ "version": "2.8.1",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [