article-content-renderer-vue2 0.2.0 → 0.3.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.
@@ -1,19 +1,12 @@
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 } 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
+ }
11
+ 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
12
  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, ArticleButtonClickPayload, ArticleButtonLink, ArticleButtonLinkDescriptor, 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, 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';
@@ -1,7 +1,7 @@
1
1
  export type ProtocolVersion = 1;
2
2
  export type TextAlign = 'left' | 'center' | 'right' | 'justify';
3
3
  export type ImageAlign = 'left' | 'center' | 'right';
4
- export type ArticleButtonStyle = 'text' | 'button';
4
+ export type ArticleButtonStyle = 'text' | 'button' | 'link';
5
5
  export type LinkTarget = '_blank' | '_self';
6
6
  export interface CustomSlot {
7
7
  id: string;
@@ -94,16 +94,30 @@ export interface ImageNode {
94
94
  imageAlign?: ImageAlign;
95
95
  };
96
96
  }
97
- export interface ArticleButtonAttrs {
98
- id: string;
97
+ interface ArticleButtonBaseAttrs {
99
98
  title?: string;
100
99
  text: string;
101
- style: ArticleButtonStyle;
102
100
  }
103
- export interface ArticleButtonNode {
101
+ export interface ArticleButtonActionAttrs extends ArticleButtonBaseAttrs {
102
+ id: string;
103
+ style: 'text' | 'button';
104
+ href?: never;
105
+ }
106
+ export interface ArticleButtonLinkAttrs extends ArticleButtonBaseAttrs {
107
+ id?: string;
108
+ style: 'link';
109
+ href?: string;
110
+ }
111
+ export type ArticleButtonAttrs = ArticleButtonActionAttrs | ArticleButtonLinkAttrs;
112
+ export interface ArticleButtonActionNode {
113
+ type: 'articleButton';
114
+ attrs: ArticleButtonActionAttrs;
115
+ }
116
+ export interface ArticleButtonLinkNode {
104
117
  type: 'articleButton';
105
- attrs: ArticleButtonAttrs;
118
+ attrs: ArticleButtonLinkAttrs;
106
119
  }
120
+ export type ArticleButtonNode = ArticleButtonActionNode | ArticleButtonLinkNode;
107
121
  export interface TableNode {
108
122
  type: 'table';
109
123
  content: TableRowNode[];
@@ -128,7 +142,7 @@ export interface ArticleButtonLinkDescriptor {
128
142
  rel?: string;
129
143
  }
130
144
  export type ArticleButtonLink = string | ArticleButtonLinkDescriptor | null;
131
- export type ResolveArticleButtonLink = (attrs: Readonly<ArticleButtonAttrs>, node: Readonly<ArticleButtonNode>) => ArticleButtonLink;
145
+ export type ResolveArticleButtonLink = (attrs: Readonly<ArticleButtonActionAttrs>, node: Readonly<ArticleButtonActionNode>) => ArticleButtonLink;
132
146
  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';
133
147
  export interface RenderIssue {
134
148
  code: RenderIssueCode;
@@ -146,3 +160,4 @@ export interface ArticleButtonClickPayload {
146
160
  href: string | null;
147
161
  event: MouseEvent;
148
162
  }
163
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "article-content-renderer-vue2",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
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",
@@ -257,14 +257,14 @@
257
257
  {
258
258
  "type": "articleButton",
259
259
  "kind": "block",
260
- "description": "An article action button identified by a business id and displayed with its text.",
260
+ "description": "An article action displayed with its text. Link actions may omit the business id.",
261
261
  "contentModel": "none",
262
262
  "attributes": [
263
263
  {
264
264
  "name": "id",
265
265
  "type": "string",
266
- "required": true,
267
- "description": "Business identifier used by the consuming application to handle the action."
266
+ "required": false,
267
+ "description": "Business identifier used by the consuming application. Required for text and button styles; optional for link style."
268
268
  },
269
269
  {
270
270
  "name": "title",
@@ -282,21 +282,45 @@
282
282
  "name": "style",
283
283
  "type": "string",
284
284
  "required": true,
285
- "description": "Controlled visual variant: text is rendered as a text-like action; button as a button-like action.",
285
+ "description": "Controlled variant: text is a text-like action, button is a button-like action, and link is a hyperlink action.",
286
286
  "allowedValues": [
287
287
  "text",
288
- "button"
288
+ "button",
289
+ "link"
289
290
  ]
291
+ },
292
+ {
293
+ "name": "href",
294
+ "type": "string",
295
+ "required": false,
296
+ "description": "Optional link destination. This attribute may only be present when style is link."
297
+ }
298
+ ],
299
+ "constraints": [
300
+ {
301
+ "name": "link-style-href",
302
+ "description": "The optional href attribute may only be present when style is link."
303
+ },
304
+ {
305
+ "name": "non-link-style-id",
306
+ "description": "The id attribute is required when style is text or button, and optional when style is link."
290
307
  }
291
308
  ],
292
309
  "render": {
293
310
  "mode": "element",
294
311
  "element": "button",
295
312
  "textBinding": "text",
313
+ "elementVariants": {
314
+ "attribute": "style",
315
+ "values": {
316
+ "link": "a"
317
+ }
318
+ },
296
319
  "attributeBindings": {
297
320
  "id": "data-article-button-id",
298
321
  "title": "title",
299
- "style": "data-article-button-style"
322
+ "style": "data-article-button-style",
323
+ "href": "href"
300
324
  }
301
325
  }
302
326
  },
@@ -404,7 +428,7 @@
404
428
  "name": "href",
405
429
  "type": "string",
406
430
  "required": true,
407
- "description": "Link destination."
431
+ "description": "Non-empty URI reference; fragment-only links such as # are valid."
408
432
  },
409
433
  {
410
434
  "name": "target",
@@ -753,7 +777,6 @@
753
777
  "type": "object",
754
778
  "additionalProperties": false,
755
779
  "required": [
756
- "id",
757
780
  "text",
758
781
  "style"
759
782
  ],
@@ -773,10 +796,57 @@
773
796
  "style": {
774
797
  "enum": [
775
798
  "text",
776
- "button"
799
+ "button",
800
+ "link"
777
801
  ]
802
+ },
803
+ "href": {
804
+ "type": "string",
805
+ "minLength": 1
778
806
  }
779
- }
807
+ },
808
+ "allOf": [
809
+ {
810
+ "if": {
811
+ "properties": {
812
+ "style": {
813
+ "enum": [
814
+ "text",
815
+ "button"
816
+ ]
817
+ }
818
+ },
819
+ "required": [
820
+ "style"
821
+ ]
822
+ },
823
+ "then": {
824
+ "properties": {
825
+ "id": {}
826
+ },
827
+ "required": [
828
+ "id"
829
+ ]
830
+ }
831
+ },
832
+ {
833
+ "if": {
834
+ "properties": {
835
+ "href": {}
836
+ },
837
+ "required": [
838
+ "href"
839
+ ]
840
+ },
841
+ "then": {
842
+ "properties": {
843
+ "style": {
844
+ "const": "link"
845
+ }
846
+ }
847
+ }
848
+ }
849
+ ]
780
850
  }
781
851
  }
782
852
  },
@@ -918,7 +988,8 @@
918
988
  "properties": {
919
989
  "href": {
920
990
  "type": "string",
921
- "minLength": 1
991
+ "minLength": 1,
992
+ "description": "Non-empty URI reference; fragment-only links such as # are valid."
922
993
  },
923
994
  "target": {
924
995
  "enum": [
@@ -935,5 +1006,3 @@
935
1006
  }
936
1007
  }
937
1008
  }
938
-
939
-