@erudit-js/prose 4.0.0-dev.1 → 4.0.0-dev.2

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.
Files changed (57) hide show
  1. package/dist/app/shared/invert.d.ts +2 -2
  2. package/dist/app/shared/invert.js +2 -2
  3. package/dist/elements/accent/Accent.vue +2 -2
  4. package/dist/elements/accent/AccentColumnSection.vue +2 -2
  5. package/dist/elements/accent/AccentRowSections.vue +1 -1
  6. package/dist/elements/accent/core.d.ts +2 -2
  7. package/dist/elements/callout/Callout.vue +6 -9
  8. package/dist/elements/callout/core.d.ts +3 -3
  9. package/dist/elements/details/Details.vue +1 -2
  10. package/dist/elements/diagram/core.d.ts +3 -3
  11. package/dist/elements/emphasis/Emphasis.vue +1 -1
  12. package/dist/elements/emphasis/core.d.ts +6 -6
  13. package/dist/elements/flex/Flex.vue +8 -2
  14. package/dist/elements/flex/core.d.ts +7 -3
  15. package/dist/elements/flex/core.js +4 -0
  16. package/dist/elements/gallery/core.d.ts +3 -3
  17. package/dist/elements/heading/Heading.vue +1 -1
  18. package/dist/elements/heading/core.d.ts +9 -9
  19. package/dist/elements/heading/core.js +14 -10
  20. package/dist/elements/horizontalLine/HorizontalLine.vue +1 -1
  21. package/dist/elements/image/core.d.ts +3 -3
  22. package/dist/elements/link/BlockLink.vue +1 -2
  23. package/dist/elements/link/Link.vue +4 -2
  24. package/dist/elements/list/List.vue +3 -6
  25. package/dist/elements/list/core.d.ts +3 -3
  26. package/dist/elements/math/block.d.ts +9 -9
  27. package/dist/elements/math/block.js +3 -3
  28. package/dist/elements/math/components/BlockMath.vue +1 -1
  29. package/dist/elements/math/components/MathGroup.vue +4 -4
  30. package/dist/elements/math/core.d.ts +2 -2
  31. package/dist/elements/math/inliner.d.ts +2 -2
  32. package/dist/elements/paragraph/Paragraph.vue +1 -1
  33. package/dist/elements/paragraph/core.d.ts +3 -3
  34. package/dist/elements/problem/components/ProblemButton.vue +2 -2
  35. package/dist/elements/problem/components/ProblemContainer.vue +1 -2
  36. package/dist/elements/problem/components/ProblemExpander.vue +1 -1
  37. package/dist/elements/problem/components/ProblemExpanderSection.vue +2 -3
  38. package/dist/elements/problem/components/ProblemHeader.vue +2 -6
  39. package/dist/elements/problem/components/Problems.vue +3 -3
  40. package/dist/elements/problem/components/expanders/Check.vue +2 -3
  41. package/dist/elements/problem/components/expanders/Checks.vue +1 -1
  42. package/dist/elements/problem/core.d.ts +44 -8
  43. package/dist/elements/problem/problem.d.ts +3 -3
  44. package/dist/elements/problem/problem.js +3 -2
  45. package/dist/elements/problem/problemContent.d.ts +42 -37
  46. package/dist/elements/problem/problemContent.js +86 -2
  47. package/dist/elements/problem/problems.d.ts +3 -3
  48. package/dist/elements/problem/problems.js +3 -2
  49. package/dist/elements/table/Table.vue +2 -4
  50. package/dist/elements/table/core.d.ts +3 -3
  51. package/dist/elements/video/core.d.ts +3 -3
  52. package/dist/include.js +0 -1
  53. package/dist/snippet.d.ts +24 -34
  54. package/dist/snippet.js +60 -31
  55. package/dist/tag.d.ts +3 -3
  56. package/dist/tag.js +1 -1
  57. package/package.json +2 -2
@@ -127,7 +127,7 @@ export declare const Problems: import("@jsprose/core").Tag<"Problems", {
127
127
  applied?: true | undefined;
128
128
  method?: true | undefined;
129
129
  inter?: true | undefined;
130
- } & TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet & import("../../snippet.js").ObjPropSearch & import("../../snippet.js").ObjPropQuick & import("../../snippet.js").ObjPropSeo>;
130
+ } & TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
131
131
  export declare const problemsRegistryItem: import("@jsprose/core").RegistryItem<{
132
132
  name: "problems";
133
133
  type: "block";
@@ -166,7 +166,7 @@ export declare const problemsRegistryItem: import("@jsprose/core").RegistryItem<
166
166
  applied?: true | undefined;
167
167
  method?: true | undefined;
168
168
  inter?: true | undefined;
169
- } & TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet & import("../../snippet.js").ObjPropSearch & import("../../snippet.js").ObjPropQuick & import("../../snippet.js").ObjPropSeo>;
169
+ } & TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
170
170
  }, undefined>;
171
171
  export declare const problemsCoreElement: {
172
172
  registryItem: import("@jsprose/core").RegistryItem<{
@@ -207,6 +207,6 @@ export declare const problemsCoreElement: {
207
207
  applied?: true | undefined;
208
208
  method?: true | undefined;
209
209
  inter?: true | undefined;
210
- } & TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet & import("../../snippet.js").ObjPropSearch & import("../../snippet.js").ObjPropQuick & import("../../snippet.js").ObjPropSeo>;
210
+ } & TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
211
211
  }, undefined>;
212
212
  };
@@ -62,8 +62,9 @@ export const Problems = defineEruditTag({
62
62
  throw new ProseError(`<${tagName}> must have at least one <SubProblem> child!`);
63
63
  }
64
64
  element.children = [...otherChildren, ...subProblemChildren];
65
- element.data = problemProps2Info(props);
66
- element.title = element.data.title;
65
+ const problemInfo = problemProps2Info(props);
66
+ element.data = problemInfo;
67
+ element.title = problemInfo.title;
67
68
  });
68
69
  export const problemsRegistryItem = defineRegistryItem({
69
70
  schema: problemsSchema,
@@ -31,16 +31,14 @@ const rows = computed(() =>
31
31
  :class="[
32
32
  $style.table,
33
33
  `text-main-sm bg-bg-main m-auto max-w-full border-separate
34
- border-spacing-[3px] rounded border border-(--tableBorder)
35
- transition-[background,border]`,
34
+ border-spacing-[3px] rounded border border-(--tableBorder)`,
36
35
  ]"
37
36
  >
38
37
  <tbody>
39
38
  <tr
40
39
  v-for="row in rows"
41
40
  :key="row.id"
42
- class="transition-[background] odd:bg-(--oddCellBg)
43
- even:bg-(--evenCellBg)"
41
+ class="odd:bg-(--oddCellBg) even:bg-(--evenCellBg)"
44
42
  >
45
43
  <td
46
44
  v-for="cell in row.children"
@@ -150,7 +150,7 @@ export declare const Table: import("@jsprose/core").Tag<"Table", {
150
150
  Children: InlinerSchema[];
151
151
  }[];
152
152
  })[];
153
- }, TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet & import("../../snippet.js").ObjPropSearch & import("../../snippet.js").ObjPropQuick & import("../../snippet.js").ObjPropSeo>;
153
+ }, TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
154
154
  export declare const tableRegistryItem: import("@jsprose/core").RegistryItem<{
155
155
  name: "table";
156
156
  type: "block";
@@ -208,7 +208,7 @@ export declare const tableRegistryItem: import("@jsprose/core").RegistryItem<{
208
208
  Children: InlinerSchema[];
209
209
  }[];
210
210
  })[];
211
- }, TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet & import("../../snippet.js").ObjPropSearch & import("../../snippet.js").ObjPropQuick & import("../../snippet.js").ObjPropSeo>;
211
+ }, TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
212
212
  }, undefined>;
213
213
  declare const _default: [{
214
214
  registryItem: import("@jsprose/core").RegistryItem<{
@@ -318,7 +318,7 @@ declare const _default: [{
318
318
  Children: InlinerSchema[];
319
319
  }[];
320
320
  })[];
321
- }, TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet & import("../../snippet.js").ObjPropSearch & import("../../snippet.js").ObjPropQuick & import("../../snippet.js").ObjPropSeo>;
321
+ }, TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
322
322
  }, undefined>;
323
323
  }];
324
324
  export default _default;
@@ -43,7 +43,7 @@ export declare const Video: import("@jsprose/core").Tag<"Video", {
43
43
  invert?: Invert;
44
44
  width?: string;
45
45
  children?: {};
46
- } & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet & import("../../snippet.js").ObjPropSearch & import("../../snippet.js").ObjPropQuick & import("../../snippet.js").ObjPropSeo>;
46
+ } & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
47
47
  export declare const videoRegistryItem: import("@jsprose/core").RegistryItem<{
48
48
  name: "video";
49
49
  type: "block";
@@ -79,7 +79,7 @@ export declare const videoRegistryItem: import("@jsprose/core").RegistryItem<{
79
79
  invert?: Invert;
80
80
  width?: string;
81
81
  children?: {};
82
- } & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet & import("../../snippet.js").ObjPropSearch & import("../../snippet.js").ObjPropQuick & import("../../snippet.js").ObjPropSeo>;
82
+ } & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
83
83
  }, undefined>;
84
84
  declare const _default: {
85
85
  registryItem: import("@jsprose/core").RegistryItem<{
@@ -117,7 +117,7 @@ declare const _default: {
117
117
  invert?: Invert;
118
118
  width?: string;
119
119
  children?: {};
120
- } & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet & import("../../snippet.js").ObjPropSearch & import("../../snippet.js").ObjPropQuick & import("../../snippet.js").ObjPropSeo>;
120
+ } & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
121
121
  }, undefined>;
122
122
  };
123
123
  export default _default;
package/dist/include.js CHANGED
@@ -25,7 +25,6 @@ export function Include(props) {
25
25
  delete element.toc;
26
26
  }
27
27
  delete element.snippet;
28
- delete element.snippetFlags;
29
28
  delete element.uniqueName;
30
29
  element[includedKey] = true;
31
30
  if (element.children) {
package/dist/snippet.d.ts CHANGED
@@ -4,60 +4,50 @@ import type { EruditRawElement } from './rawElement.js';
4
4
  /**
5
5
  * Snippet attribute - only contains title and description
6
6
  */
7
- export interface SnippetProp {
7
+ export interface SnippetData {
8
+ /** General snippet title. Used as fallback value for flags. */
8
9
  title?: string;
10
+ /** General snippet description. Used as fallback value for flags. */
9
11
  description?: string;
10
- }
11
- export type ObjPropSnippet = {
12
- /**
13
- * Compact summary of the element with title and description.
14
- */
15
- snippet?: SnippetProp;
16
- };
17
- export type ObjPropSearch = {
18
12
  /**
19
13
  * Show element in search results.
20
- * Can be a boolean to enable/disable, or an object with synonyms.
21
14
  */
22
- search?: boolean | {
23
- synonyms: string[];
15
+ search?: boolean | string | string[] | {
16
+ title?: string;
17
+ description?: string;
18
+ synonyms?: string[];
24
19
  };
25
- };
26
- export type ObjPropQuick = {
27
20
  /**
28
21
  * Show element in "Quick Links" sections at start of the page and also in TOC.
29
22
  */
30
- quick?: boolean;
31
- };
32
- export type ObjPropSeo = {
23
+ quick?: boolean | string | {
24
+ title?: string;
25
+ description?: string;
26
+ };
33
27
  /**
34
28
  * When targeting this element with '#' anchor, adjust SEO metadata (like title and description).
35
29
  * Search engines should treat it as a different "page" and therefore show it as a standalone search result.
36
30
  */
37
- seo?: boolean;
31
+ seo?: boolean | string | {
32
+ title?: string;
33
+ description?: string;
34
+ };
35
+ }
36
+ export type ObjPropSnippet = {
37
+ /**
38
+ * Compact summary of the element and where to show it (search, quick links, SEO).
39
+ */
40
+ snippet?: SnippetData;
38
41
  };
39
42
  export type ObjRawElementSnippet = {
40
- snippet?: SnippetProp;
41
- snippetFlags?: {
42
- quick?: boolean;
43
- search?: boolean | {
44
- synonyms: string[];
45
- };
46
- seo?: boolean;
47
- };
43
+ snippet?: SnippetData;
48
44
  };
49
- export declare function finalizeSnippet(processTagArgs: EruditProcessTagArgs): SnippetProp | undefined;
45
+ export declare function finalizeSnippet(processTagArgs: EruditProcessTagArgs): SnippetData | undefined;
50
46
  export interface ResolvedSnippet {
51
- title: string;
52
- description?: string;
53
- quick?: boolean;
54
- search?: boolean | {
55
- synonyms: string[];
56
- };
57
- seo?: boolean;
58
47
  schemaName: string;
59
48
  isUnique: boolean;
60
49
  elementId: string;
50
+ snippetData: SnippetData;
61
51
  }
62
52
  export declare const snippetStep: ({ rawElement, proseElement }: {
63
53
  context: import("./context.js").EruditProseContext;
package/dist/snippet.js CHANGED
@@ -1,56 +1,85 @@
1
1
  import { ProseError } from "@jsprose/core";
2
2
  import { defineResolveStep } from "./resolveStep.js";
3
3
  export function finalizeSnippet(processTagArgs) {
4
- const quick = processTagArgs.props.quick ?? processTagArgs.element.snippetFlags?.quick;
5
- const search = processTagArgs.props.search ?? processTagArgs.element.snippetFlags?.search;
6
- let seo = processTagArgs.props.seo ?? processTagArgs.element.snippetFlags?.seo;
4
+ const finalSnippet = {};
5
+ const propsSnippet = processTagArgs.props.snippet;
6
+ const builtinSnippet = processTagArgs.element.snippet;
7
+ //
8
+ const quick = propsSnippet?.quick ?? builtinSnippet?.quick;
9
+ if (quick) {
10
+ finalSnippet.quick = quick;
11
+ }
12
+ //
13
+ const search = propsSnippet?.search ?? builtinSnippet?.search;
14
+ if (search) {
15
+ finalSnippet.search = search;
16
+ }
17
+ //
18
+ let seo = propsSnippet?.seo ?? builtinSnippet?.seo;
7
19
  // If none of the flags are set to true, no snippet is created
8
20
  if (!quick && !search && !seo) {
9
21
  return undefined;
10
22
  }
11
23
  // Enable SEO if either quick or search is enabled unless SEO is explicitly disabled
12
24
  // Check both element defaults and props - if either explicitly disables seo, don't auto-enable
13
- const seoExplicitlyDisabled = processTagArgs.element.snippetFlags?.seo === false || processTagArgs.props.seo === false;
14
- if (!seoExplicitlyDisabled) {
15
- if (quick || search) {
16
- seo = true;
25
+ const seoExplicitlyDisabled = builtinSnippet?.seo === false || propsSnippet?.seo === false;
26
+ if (!seo) {
27
+ if (!seoExplicitlyDisabled) {
28
+ if (quick || search) {
29
+ seo = true;
30
+ }
17
31
  }
18
32
  }
19
- const title = finalizeTitle(processTagArgs);
20
- const description = finalizeDescription(processTagArgs);
21
- const snippet = { title };
33
+ if (seo) {
34
+ finalSnippet.seo = seo;
35
+ }
36
+ //
37
+ const title = getGenericTitle(processTagArgs);
38
+ if (title) {
39
+ finalSnippet.title = title;
40
+ }
41
+ const description = getGenericDescription(processTagArgs);
22
42
  if (description) {
23
- snippet.description = description;
24
- }
25
- // Store flags on element for later resolution
26
- processTagArgs.element.snippetFlags = {
27
- quick,
28
- search,
29
- seo
30
- };
31
- return snippet;
43
+ finalSnippet.description = description;
44
+ }
45
+ //
46
+ if (!finalSnippet.title) {
47
+ let titlessFlags = [];
48
+ if (quick && typeof quick !== "string") {
49
+ if (quick === true || !quick.title) {
50
+ titlessFlags.push("quick");
51
+ }
52
+ }
53
+ if (search && typeof search !== "string") {
54
+ if (search === true || Array.isArray(search) || !search.title) {
55
+ titlessFlags.push("search");
56
+ }
57
+ }
58
+ if (seo && typeof seo !== "string") {
59
+ if (seo === true || !seo.title) {
60
+ titlessFlags.push("seo");
61
+ }
62
+ }
63
+ throw new ProseError(`Unable to get title for snippet flags (${titlessFlags.join(", ")}) because no explicit, general inherited title was provided!`);
64
+ }
65
+ //
66
+ processTagArgs.element.snippet = finalSnippet;
67
+ return finalSnippet;
32
68
  }
33
- function finalizeTitle(processTagArgs) {
69
+ function getGenericTitle(processTagArgs) {
34
70
  const title = processTagArgs.props.snippet?.title?.trim() || processTagArgs.element.snippet?.title?.trim() || processTagArgs.element.title?.trim();
35
- if (!title) {
36
- throw new ProseError(`Unable to finalize snippet title!`);
37
- }
38
71
  return title;
39
72
  }
40
- function finalizeDescription(processTagArgs) {
73
+ function getGenericDescription(processTagArgs) {
41
74
  return processTagArgs.props.snippet?.description?.trim() || processTagArgs.element.snippet?.description?.trim();
42
75
  }
43
76
  export const snippetStep = defineResolveStep(({ rawElement, proseElement }) => {
44
- if (rawElement.snippet && proseElement.id && rawElement.snippet.title) {
77
+ if (rawElement.snippet && proseElement.id) {
45
78
  const resolvedSnippet = {
46
- title: rawElement.snippet.title,
47
- description: rawElement.snippet.description,
48
- quick: rawElement.snippetFlags?.quick,
49
- search: rawElement.snippetFlags?.search,
50
- seo: rawElement.snippetFlags?.seo,
51
79
  schemaName: rawElement.schemaName,
52
80
  isUnique: Boolean(rawElement.uniqueName),
53
- elementId: proseElement.id
81
+ elementId: proseElement.id,
82
+ snippetData: rawElement.snippet
54
83
  };
55
84
  return resolvedSnippet;
56
85
  }
package/dist/tag.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Registry, type AnySchema, type ConfigurableTagProps, type NormalizedChildren, type ProcessTagFunction, type TagDefinition } from '@jsprose/core';
2
2
  import type { EruditRawElement } from './rawElement.js';
3
- import { type ObjPropSnippet, type ObjPropSearch, type ObjPropQuick, type ObjPropSeo } from './snippet.js';
3
+ import { type ObjPropSnippet } from './snippet.js';
4
4
  import { type ObjPropToc } from './toc.js';
5
5
  declare const NoTocSymbol: unique symbol;
6
6
  declare const NoSnippetSymbol: unique symbol;
@@ -10,11 +10,11 @@ export type NoToc = {
10
10
  export type NoSnippet = {
11
11
  readonly [NoSnippetSymbol]?: never;
12
12
  };
13
- export type EruditTagProps<TProps extends Record<string, unknown>> = (TProps extends NoToc ? {} : ObjPropToc) & (TProps extends NoSnippet ? {} : ObjPropSnippet & ObjPropSearch & ObjPropQuick & ObjPropSeo);
13
+ export type EruditTagProps<TProps extends Record<string, unknown>> = (TProps extends NoToc ? {} : ObjPropToc) & (TProps extends NoSnippet ? {} : ObjPropSnippet);
14
14
  export type EruditProcessTagArgs = {
15
15
  tagName: string;
16
16
  element: EruditRawElement<AnySchema>;
17
- props: ConfigurableTagProps & ObjPropSnippet & ObjPropToc & ObjPropSearch & ObjPropQuick & ObjPropSeo;
17
+ props: ConfigurableTagProps & ObjPropSnippet & ObjPropToc;
18
18
  children: NormalizedChildren;
19
19
  registry: Registry;
20
20
  };
package/dist/tag.js CHANGED
@@ -12,7 +12,7 @@ export function defineEruditTag(definition) {
12
12
  args.element.snippet = finalizeSnippet(args);
13
13
  args.element.toc = finalizeToc(args);
14
14
  // Use every possibility to get human-readable slug whether it is set manually or taken from snippet or toc
15
- args.element.slug ||= args.element.snippet?.title || args.element.toc?.title;
15
+ args.element.slug ||= args.element.snippet?.title || args.element.toc?.title || args.element.title;
16
16
  });
17
17
  return eruditTag;
18
18
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@erudit-js/prose",
4
- "version": "4.0.0-dev.1",
4
+ "version": "4.0.0-dev.2",
5
5
  "description": "📝 JSX prose subsystem for Erudit sites",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "prepack": "bun run build"
33
33
  },
34
34
  "dependencies": {
35
- "@erudit-js/core": "4.0.0-dev.1",
35
+ "@erudit-js/core": "4.0.0-dev.2",
36
36
  "@jsprose/core": "^1.0.0",
37
37
  "vue": "latest",
38
38
  "@floating-ui/vue": "^1.1.9",