article-content-renderer-vue2 0.3.0 → 0.4.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.
@@ -1,19 +1,13 @@
1
1
  import Vue from 'vue';
2
- import type { ResolvedCustomSlot } from '../protocols/types.js';
3
- import type { CustomSlot, RenderIssue, ResolveArticleButtonLink, ValidationResult } from '../types.js';
4
- declare const _default: import("vue/types/vue").ExtendedVue<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue>, {
5
- reportedRuntimeIssues: Set<string>;
6
- }, {
7
- resolveCustomSlots(): ResolvedCustomSlot[];
8
- reportRuntimeIssue(issue: RenderIssue): void;
9
- }, {
10
- validation: ValidationResult;
11
- }, {
2
+ import type { CustomSlot, ResolveArticleButtonLink, ResolveCustomLink } from '../types.js';
3
+ interface ArticleContentRendererProps {
12
4
  document: unknown;
13
5
  protocolVersion: number;
14
6
  strict: boolean;
15
7
  customSlots: CustomSlot[];
16
8
  imageBaseUrl: string;
17
- resolveArticleButtonLink: ResolveArticleButtonLink;
18
- }, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin>;
9
+ resolveArticleButtonLink?: ResolveArticleButtonLink;
10
+ resolveCustomLink?: ResolveCustomLink;
11
+ }
12
+ declare const _default: import("vue/types/vue").ExtendedVue<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue>, {}, {}, {}, ArticleContentRendererProps, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin>;
19
13
  export default _default;
@@ -5,4 +5,4 @@ export default ArticleContentRenderer;
5
5
  export declare const ArticleContentRendererPlugin: PluginObject<never>;
6
6
  export { CURRENT_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, validateArticleDocument, } from './protocols/registry.js';
7
7
  export { ARTICLE_CONTENT_PROTOCOL_V1 } from './protocols/v1/metadata.js';
8
- export type { ArticleButtonAttrs, ArticleButtonActionAttrs, ArticleButtonActionNode, ArticleButtonClickPayload, ArticleButtonLink, ArticleButtonLinkAttrs, ArticleButtonLinkDescriptor, ArticleButtonLinkNode, ArticleButtonNode, ArticleButtonStyle, ArticleContentNode, ArticleDocument, ArticleMark, BlockNode, BlockquoteNode, BoldMark, BulletListNode, CodeBlockNode, CodeBlockTextNode, CodeMark, CustomSlot, HeadingNode, HorizontalRuleNode, ImageAlign, ImageNode, ItalicMark, LinkMark, LinkTarget, ListItemNode, OrderedListNode, ParagraphNode, ProtocolVersion, RenderIssue, RenderIssueCode, ResolveArticleButtonLink, StrikeMark, TableCellNode, TableNode, TableRowNode, TextAlign, TextNode, UnderlineMark, ValidationResult, } from './types.js';
8
+ export type { ArticleButtonAttrs, ArticleButtonActionAttrs, ArticleButtonActionNode, ArticleButtonClickPayload, ArticleButtonLink, ArticleButtonLinkAttrs, ArticleButtonLinkDescriptor, ArticleButtonLinkNode, ArticleButtonNode, ArticleButtonStyle, ArticleContentNode, ArticleDocument, ArticleMark, BlockNode, BlockquoteNode, BoldMark, BulletListNode, CodeBlockNode, CodeBlockTextNode, CodeMark, CustomLink, CustomLinkDescriptor, CustomLinkMark, CustomLinkMarkAttrs, CustomSlot, HeadingNode, HorizontalRuleNode, ImageAlign, ImageNode, ItalicMark, HrefLinkMark, HrefLinkMarkAttrs, LinkMark, LinkTarget, ListItemNode, OrderedListNode, ParagraphNode, ProtocolVersion, RenderIssue, RenderIssueCode, ResolveArticleButtonLink, ResolveCustomLink, StrikeMark, TableCellNode, TableNode, TableRowNode, TextAlign, TextNode, UnderlineMark, ValidationResult, } from './types.js';
@@ -1,10 +1,11 @@
1
1
  import type { CreateElement, VNode } from 'vue';
2
- import type { ArticleButtonClickPayload, RenderIssue, ResolveArticleButtonLink, ValidationResult } from '../types.js';
2
+ import type { ArticleButtonClickPayload, RenderIssue, ResolveArticleButtonLink, ResolveCustomLink, ValidationResult } from '../types.js';
3
3
  export interface RenderContext {
4
4
  createElement: CreateElement;
5
5
  customSlots: readonly ResolvedCustomSlot[];
6
6
  imageBaseUrl: string;
7
7
  resolveArticleButtonLink?: ResolveArticleButtonLink;
8
+ resolveCustomLink?: ResolveCustomLink;
8
9
  emitArticleButtonClick: (payload: ArticleButtonClickPayload) => void;
9
10
  reportIssue: (issue: RenderIssue) => void;
10
11
  }
@@ -22,13 +22,29 @@ export interface UnderlineMark {
22
22
  export interface CodeMark {
23
23
  type: 'code';
24
24
  }
25
- export interface LinkMark {
25
+ export interface HrefLinkMarkAttrs {
26
+ type?: 'href';
27
+ href: string;
28
+ id?: never;
29
+ title?: never;
30
+ target?: LinkTarget;
31
+ }
32
+ export interface CustomLinkMarkAttrs {
33
+ type: 'custom';
34
+ id: string;
35
+ title: string;
36
+ href?: never;
37
+ target?: LinkTarget;
38
+ }
39
+ export interface HrefLinkMark {
26
40
  type: 'link';
27
- attrs: {
28
- href: string;
29
- target?: LinkTarget;
30
- };
41
+ attrs: HrefLinkMarkAttrs;
42
+ }
43
+ export interface CustomLinkMark {
44
+ type: 'link';
45
+ attrs: CustomLinkMarkAttrs;
31
46
  }
47
+ export type LinkMark = HrefLinkMark | CustomLinkMark;
32
48
  export type ArticleMark = BoldMark | ItalicMark | StrikeMark | UnderlineMark | CodeMark | LinkMark;
33
49
  export interface TextNode {
34
50
  type: 'text';
@@ -143,6 +159,13 @@ export interface ArticleButtonLinkDescriptor {
143
159
  }
144
160
  export type ArticleButtonLink = string | ArticleButtonLinkDescriptor | null;
145
161
  export type ResolveArticleButtonLink = (attrs: Readonly<ArticleButtonActionAttrs>, node: Readonly<ArticleButtonActionNode>) => ArticleButtonLink;
162
+ export interface CustomLinkDescriptor {
163
+ href: string;
164
+ target?: LinkTarget;
165
+ rel?: string;
166
+ }
167
+ export type CustomLink = string | CustomLinkDescriptor | null;
168
+ export type ResolveCustomLink = (attrs: Readonly<CustomLinkMarkAttrs>, mark: Readonly<CustomLinkMark>) => CustomLink;
146
169
  export type RenderIssueCode = 'INVALID_ROOT' | 'INVALID_TYPE' | 'INVALID_CONTENT' | 'INVALID_VALUE' | 'MISSING_PROPERTY' | 'UNKNOWN_PROPERTY' | 'UNKNOWN_NODE' | 'UNKNOWN_MARK' | 'TABLE_COLUMN_MISMATCH' | 'UNSAFE_URL' | 'LINK_RESOLUTION_FAILED' | 'UNSUPPORTED_PROTOCOL';
147
170
  export interface RenderIssue {
148
171
  code: RenderIssueCode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "article-content-renderer-vue2",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "A safe Vue 2.7 renderer for the Article Content Protocol ProseMirror JSON format.",
5
5
  "author": "NovaVoyager",
6
6
  "license": "MIT",
@@ -422,13 +422,36 @@
422
422
  },
423
423
  {
424
424
  "type": "link",
425
- "description": "A hyperlink. Renderers must validate and escape the URL.",
425
+ "description": "An href or application-defined custom link.",
426
426
  "attributes": [
427
+ {
428
+ "name": "type",
429
+ "type": "string",
430
+ "required": false,
431
+ "description": "Link destination type. Omission means href for legacy documents.",
432
+ "defaultValue": "href",
433
+ "allowedValues": [
434
+ "href",
435
+ "custom"
436
+ ]
437
+ },
427
438
  {
428
439
  "name": "href",
429
440
  "type": "string",
430
- "required": true,
431
- "description": "Non-empty URI reference; fragment-only links such as # are valid."
441
+ "required": false,
442
+ "description": "Required only for href links. Renderers must validate and escape this URI reference."
443
+ },
444
+ {
445
+ "name": "id",
446
+ "type": "string",
447
+ "required": false,
448
+ "description": "Application-defined identifier required only for custom links."
449
+ },
450
+ {
451
+ "name": "title",
452
+ "type": "string",
453
+ "required": false,
454
+ "description": "Application-defined title required only for custom links."
432
455
  },
433
456
  {
434
457
  "name": "target",
@@ -442,11 +465,24 @@
442
465
  ]
443
466
  }
444
467
  ],
468
+ "constraints": [
469
+ {
470
+ "name": "href-link-fields",
471
+ "description": "An href link requires href and must not contain id or title. A missing type is treated as href."
472
+ },
473
+ {
474
+ "name": "custom-link-fields",
475
+ "description": "A custom link requires type=custom, id, and title, and must not contain href."
476
+ }
477
+ ],
445
478
  "render": {
446
479
  "mode": "element",
447
480
  "element": "a",
448
481
  "attributeBindings": {
482
+ "type": "data-link-type",
449
483
  "href": "href",
484
+ "id": "data-link-id",
485
+ "title": "title",
450
486
  "target": "target"
451
487
  }
452
488
  }
@@ -979,25 +1015,63 @@
979
1015
  "const": "link"
980
1016
  },
981
1017
  "attrs": {
982
- "type": "object",
983
- "additionalProperties": false,
984
- "required": [
985
- "href",
986
- "target"
987
- ],
988
- "properties": {
989
- "href": {
990
- "type": "string",
991
- "minLength": 1,
992
- "description": "Non-empty URI reference; fragment-only links such as # are valid."
1018
+ "oneOf": [
1019
+ {
1020
+ "type": "object",
1021
+ "additionalProperties": false,
1022
+ "required": [
1023
+ "href",
1024
+ "target"
1025
+ ],
1026
+ "properties": {
1027
+ "type": {
1028
+ "const": "href",
1029
+ "default": "href",
1030
+ "description": "May be omitted in legacy documents; omission means href."
1031
+ },
1032
+ "href": {
1033
+ "type": "string",
1034
+ "minLength": 1,
1035
+ "description": "Non-empty URI reference; fragment-only links such as # are valid."
1036
+ },
1037
+ "target": {
1038
+ "enum": [
1039
+ "_blank",
1040
+ "_self"
1041
+ ]
1042
+ }
1043
+ }
993
1044
  },
994
- "target": {
995
- "enum": [
996
- "_blank",
997
- "_self"
998
- ]
1045
+ {
1046
+ "type": "object",
1047
+ "additionalProperties": false,
1048
+ "required": [
1049
+ "type",
1050
+ "id",
1051
+ "title",
1052
+ "target"
1053
+ ],
1054
+ "properties": {
1055
+ "type": {
1056
+ "const": "custom"
1057
+ },
1058
+ "id": {
1059
+ "type": "string",
1060
+ "minLength": 1
1061
+ },
1062
+ "title": {
1063
+ "type": "string",
1064
+ "minLength": 1
1065
+ },
1066
+ "target": {
1067
+ "enum": [
1068
+ "_blank",
1069
+ "_self"
1070
+ ]
1071
+ }
1072
+ }
999
1073
  }
1000
- }
1074
+ ]
1001
1075
  }
1002
1076
  }
1003
1077
  }