adf-builder
Advanced tools
Comparing version 1.3.0 to 2.0.1
import { TopLevelNode, Typed } from './index'; | ||
export interface Icon { | ||
url: string; | ||
label: string; | ||
} | ||
export interface DetailLozenge { | ||
@@ -7,6 +11,2 @@ text: string; | ||
} | ||
export interface DetailIcon { | ||
url: string; | ||
label: string; | ||
} | ||
export interface DetailBadge { | ||
@@ -19,4 +19,17 @@ value: number; | ||
id?: string; | ||
icon: DetailIcon; | ||
icon: Icon; | ||
} | ||
export interface ActionTarget { | ||
app?: string; | ||
key: string; | ||
} | ||
export declare class Action { | ||
private actionTitle; | ||
private actionTarget; | ||
private actionParameters?; | ||
title(title: string): this; | ||
target(target: ActionTarget): this; | ||
parameters(parameters: object): this; | ||
toJSON(): any; | ||
} | ||
export declare class Detail { | ||
@@ -32,3 +45,3 @@ private detailTitle; | ||
lozenge(lozenge: DetailLozenge): this; | ||
icon(icon: DetailIcon): this; | ||
icon(icon: Icon): this; | ||
badge(badge: DetailBadge): this; | ||
@@ -38,2 +51,9 @@ user(user: DetailUser): this; | ||
} | ||
export declare class Context { | ||
private text; | ||
private contextIcon; | ||
constructor(text: string); | ||
icon(icon: Icon): this; | ||
toJSON(): Partial<Typed>; | ||
} | ||
export declare class ApplicationCard extends TopLevelNode { | ||
@@ -48,2 +68,4 @@ private readonly title; | ||
private details; | ||
private actions; | ||
private cardContext; | ||
constructor(title: string, text?: string | undefined); | ||
@@ -56,3 +78,5 @@ link(url: string): this; | ||
detail(): Detail; | ||
action(): Action; | ||
context(text: string): Context; | ||
toJSON(): Typed; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const index_1 = require("./index"); | ||
class Action { | ||
title(title) { | ||
this.actionTitle = title; | ||
return this; | ||
} | ||
target(target) { | ||
if (!target.key) { | ||
throw new Error('Action target key is required'); | ||
} | ||
this.actionTarget = target; | ||
return this; | ||
} | ||
parameters(parameters) { | ||
this.actionParameters = parameters; | ||
return this; | ||
} | ||
toJSON() { | ||
const action = {}; | ||
if (this.actionTitle) { | ||
action.title = this.actionTitle; | ||
} | ||
if (this.actionTarget) { | ||
action.target = this.actionTarget; | ||
} | ||
if (this.actionParameters) { | ||
action.parameters = this.actionParameters; | ||
} | ||
if (Object.keys(action).length < 2) { | ||
throw new Error('Must set title and target attributes for action'); | ||
} | ||
return action; | ||
} | ||
} | ||
exports.Action = Action; | ||
class Detail { | ||
@@ -59,2 +93,21 @@ constructor() { | ||
exports.Detail = Detail; | ||
class Context { | ||
constructor(text) { | ||
this.text = text; | ||
} | ||
icon(icon) { | ||
this.contextIcon = icon; | ||
return this; | ||
} | ||
toJSON() { | ||
const context = { | ||
text: this.text | ||
}; | ||
if (this.contextIcon) { | ||
context.icon = this.contextIcon; | ||
} | ||
return context; | ||
} | ||
} | ||
exports.Context = Context; | ||
class ApplicationCard extends index_1.TopLevelNode { | ||
@@ -67,2 +120,3 @@ constructor(title, text) { | ||
this.details = []; | ||
this.actions = []; | ||
} | ||
@@ -94,2 +148,11 @@ link(url) { | ||
} | ||
action() { | ||
const action = new Action(); | ||
this.actions.push(action); | ||
return action; | ||
} | ||
context(text) { | ||
this.cardContext = new Context(text); | ||
return this.cardContext; | ||
} | ||
toJSON() { | ||
@@ -130,2 +193,8 @@ const card = { | ||
} | ||
if (this.actions.length > 0) { | ||
card.attrs.actions = this.actions.map(action => action.toJSON()); | ||
} | ||
if (this.cardContext) { | ||
card.attrs.context = this.cardContext.toJSON(); | ||
} | ||
return card; | ||
@@ -132,0 +201,0 @@ } |
@@ -14,3 +14,3 @@ import { Marks } from '../marks/index'; | ||
mention(id: string, text: string): this; | ||
emoji(shortName: string, id?: string, fallBack?: string): this; | ||
emoji(shortName: string, id?: string, text?: string): this; | ||
hardBreak(): this; | ||
@@ -17,0 +17,0 @@ add(node: InlineNode): this; |
@@ -32,4 +32,4 @@ "use strict"; | ||
} | ||
emoji(shortName, id, fallBack) { | ||
return this.add(new emoji_1.Emoji({ shortName, id, fallBack })); | ||
emoji(shortName, id, text) { | ||
return this.add(new emoji_1.Emoji({ shortName, id, text })); | ||
} | ||
@@ -36,0 +36,0 @@ hardBreak() { |
import { InlineNode, Typed } from './index'; | ||
export declare function emoji(shortName: string, id?: string, fallBack?: string): Emoji; | ||
export declare function emoji(shortName: string, id?: string, text?: string): Emoji; | ||
export interface EmojiAttributes { | ||
shortName: string; | ||
id?: string; | ||
fallBack?: string; | ||
text?: string; | ||
} | ||
@@ -8,0 +8,0 @@ export declare class Emoji extends InlineNode { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const index_1 = require("./index"); | ||
function emoji(shortName, id, fallBack) { | ||
return new Emoji({ shortName, id, fallBack }); | ||
function emoji(shortName, id, text) { | ||
return new Emoji({ shortName, id, text }); | ||
} | ||
@@ -23,4 +23,4 @@ exports.emoji = emoji; | ||
} | ||
if (this.attrs.fallBack) { | ||
emojiNode.attrs.fallback = this.attrs.fallBack; | ||
if (this.attrs.text) { | ||
emojiNode.attrs.text = this.attrs.text; | ||
} | ||
@@ -27,0 +27,0 @@ return emojiNode; |
@@ -11,3 +11,3 @@ import { Marks } from '../marks/index'; | ||
mention(id: string, text: string): this; | ||
emoji(shortName: string, id?: string, fallBack?: string): this; | ||
emoji(shortName: string, id?: string, text?: string): this; | ||
hardBreak(): this; | ||
@@ -14,0 +14,0 @@ add(node: InlineNode): this; |
@@ -31,4 +31,4 @@ "use strict"; | ||
} | ||
emoji(shortName, id, fallBack) { | ||
return this.add(new emoji_1.Emoji({ shortName, id, fallBack })); | ||
emoji(shortName, id, text) { | ||
return this.add(new emoji_1.Emoji({ shortName, id, text })); | ||
} | ||
@@ -35,0 +35,0 @@ hardBreak() { |
{ | ||
"name": "adf-builder", | ||
"version": "1.3.0", | ||
"version": "2.0.1", | ||
"description": "Atlassian Document Format Builder", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73193
1387