@valiantys/atlassian-app 3.2.0-alpha-9 → 3.2.0-alpha-10

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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(n,t){var r,e;for(const o of n)if(o.text!==void 0&&o.text.includes(t)||(e=(r=o.attrs)==null?void 0:r.text)!=null&&e.includes(t)||o.content&&c(o.content,t))return!0;return!1}function a(n,t){return c(n.content,t)}function u(n,t,r){return n.map(e=>{var o;return e.text!==void 0?{...e,text:e.text.replaceAll(t,r)}:((o=e.attrs)==null?void 0:o.text)!==void 0?{...e,attrs:{...e.attrs,text:e.attrs.text.replaceAll(t,r)}}:e.content?{...e,content:u(e.content,t,r)}:e})}function f(n,t,r){return{...n,content:u(n.content,t,r)}}function i(n,t){const r={type:"text",text:t};return{...n,content:[...n.content,{type:"paragraph",content:[r]}]}}function p(n){return{type:"doc",version:1,content:[{type:"paragraph",content:[{type:"text",text:n}]}]}}exports.appendParagraph=i;exports.replaceInAdf=f;exports.searchAdf=a;exports.toAdfDoc=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(t,n){var e,r;for(const a of t)if(a.text!==void 0&&a.text.includes(n)||(r=(e=a.attrs)==null?void 0:e.text)!=null&&r.includes(n)||a.content&&o(a.content,n))return!0;return!1}function p(t,n){return o(t.content,n)}function i(t,n,e){return t.map(r=>{var a;return r.text!==void 0?{...r,text:r.text.replaceAll(n,e)}:((a=r.attrs)==null?void 0:a.text)!==void 0?{...r,attrs:{...r.attrs,text:r.attrs.text.replaceAll(n,e)}}:r.content?{...r,content:i(r.content,n,e)}:r})}function f(t,n,e){return{...t,content:i(t.content,n,e)}}function $(t,n){const e={type:"text",text:n};return{...t,content:[...t.content,{type:"paragraph",content:[e]}]}}function s(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function g(t,n){return n?n.reduce((e,r)=>{var a,c,l;switch(r.type){case"strong":return`<strong>${e}</strong>`;case"em":return`<em>${e}</em>`;case"code":return`<code>${e}</code>`;case"strike":return`<s>${e}</s>`;case"underline":return`<u>${e}</u>`;case"link":return`<a href="${s(String(((a=r.attrs)==null?void 0:a.href)??""))}">${e}</a>`;case"textColor":return`<span style="color:${s(String(((c=r.attrs)==null?void 0:c.color)??""))}">${e}</span>`;case"subsup":return((l=r.attrs)==null?void 0:l.type)==="sub"?`<sub>${e}</sub>`:`<sup>${e}</sup>`;default:return e}},t):t}function u(t){return(t==null?void 0:t.map(b).join(""))??""}function b(t){var n,e,r,a;switch(t.type){case"text":return g(s(t.text??""),t.marks);case"hardBreak":return"<br>";case"rule":return"<hr>";case"paragraph":return`<p>${u(t.content)}</p>`;case"heading":{const c=Number(((n=t.attrs)==null?void 0:n.level)??1);return`<h${c}>${u(t.content)}</h${c}>`}case"blockquote":return`<blockquote>${u(t.content)}</blockquote>`;case"bulletList":return`<ul>${u(t.content)}</ul>`;case"orderedList":return`<ol>${u(t.content)}</ol>`;case"listItem":return`<li>${u(t.content)}</li>`;case"codeBlock":return`<pre${(e=t.attrs)!=null&&e.language?` data-language="${s(String(t.attrs.language))}"`:""}><code>${u(t.content)}</code></pre>`;case"emoji":case"mention":case"status":return s(String(((r=t.attrs)==null?void 0:r.text)??""));case"inlineCard":{const c=s(String(((a=t.attrs)==null?void 0:a.url)??""));return`<a href="${c}">${c}</a>`}case"table":return`<table>${u(t.content)}</table>`;case"tableRow":return`<tr>${u(t.content)}</tr>`;case"tableHeader":return`<th>${u(t.content)}</th>`;case"tableCell":return`<td>${u(t.content)}</td>`;default:return u(t.content)}}function h(t){return u(t.content)}function x(t){return{type:"doc",version:1,content:[{type:"paragraph",content:[{type:"text",text:t}]}]}}exports.adfToHtml=h;exports.appendParagraph=$;exports.replaceInAdf=f;exports.searchAdf=p;exports.toAdfDoc=x;
@@ -1,42 +1,121 @@
1
- function c(e, t) {
2
- var r, n;
3
- for (const o of e)
4
- if (o.text !== void 0 && o.text.includes(t) || (n = (r = o.attrs) == null ? void 0 : r.text) != null && n.includes(t) || o.content && c(o.content, t))
1
+ function o(t, n) {
2
+ var e, r;
3
+ for (const u of t)
4
+ if (u.text !== void 0 && u.text.includes(n) || (r = (e = u.attrs) == null ? void 0 : e.text) != null && r.includes(n) || u.content && o(u.content, n))
5
5
  return !0;
6
6
  return !1;
7
7
  }
8
- function f(e, t) {
9
- return c(e.content, t);
8
+ function $(t, n) {
9
+ return o(t.content, n);
10
10
  }
11
- function u(e, t, r) {
12
- return e.map((n) => {
13
- var o;
14
- return n.text !== void 0 ? { ...n, text: n.text.replaceAll(t, r) } : ((o = n.attrs) == null ? void 0 : o.text) !== void 0 ? {
15
- ...n,
11
+ function i(t, n, e) {
12
+ return t.map((r) => {
13
+ var u;
14
+ return r.text !== void 0 ? { ...r, text: r.text.replaceAll(n, e) } : ((u = r.attrs) == null ? void 0 : u.text) !== void 0 ? {
15
+ ...r,
16
16
  attrs: {
17
- ...n.attrs,
18
- text: n.attrs.text.replaceAll(t, r)
17
+ ...r.attrs,
18
+ text: r.attrs.text.replaceAll(n, e)
19
19
  }
20
- } : n.content ? {
21
- ...n,
22
- content: u(n.content, t, r)
23
- } : n;
20
+ } : r.content ? {
21
+ ...r,
22
+ content: i(r.content, n, e)
23
+ } : r;
24
24
  });
25
25
  }
26
- function i(e, t, r) {
26
+ function g(t, n, e) {
27
27
  return {
28
- ...e,
29
- content: u(e.content, t, r)
28
+ ...t,
29
+ content: i(t.content, n, e)
30
30
  };
31
31
  }
32
- function a(e, t) {
33
- const r = { type: "text", text: t };
32
+ function b(t, n) {
33
+ const e = { type: "text", text: n };
34
34
  return {
35
- ...e,
36
- content: [...e.content, { type: "paragraph", content: [r] }]
35
+ ...t,
36
+ content: [...t.content, { type: "paragraph", content: [e] }]
37
37
  };
38
38
  }
39
- function p(e) {
39
+ function s(t) {
40
+ return t.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;");
41
+ }
42
+ function p(t, n) {
43
+ return n ? n.reduce((e, r) => {
44
+ var u, c, l;
45
+ switch (r.type) {
46
+ case "strong":
47
+ return `<strong>${e}</strong>`;
48
+ case "em":
49
+ return `<em>${e}</em>`;
50
+ case "code":
51
+ return `<code>${e}</code>`;
52
+ case "strike":
53
+ return `<s>${e}</s>`;
54
+ case "underline":
55
+ return `<u>${e}</u>`;
56
+ case "link":
57
+ return `<a href="${s(String(((u = r.attrs) == null ? void 0 : u.href) ?? ""))}">${e}</a>`;
58
+ case "textColor":
59
+ return `<span style="color:${s(String(((c = r.attrs) == null ? void 0 : c.color) ?? ""))}">${e}</span>`;
60
+ case "subsup":
61
+ return ((l = r.attrs) == null ? void 0 : l.type) === "sub" ? `<sub>${e}</sub>` : `<sup>${e}</sup>`;
62
+ default:
63
+ return e;
64
+ }
65
+ }, t) : t;
66
+ }
67
+ function a(t) {
68
+ return (t == null ? void 0 : t.map(f).join("")) ?? "";
69
+ }
70
+ function f(t) {
71
+ var n, e, r, u;
72
+ switch (t.type) {
73
+ case "text":
74
+ return p(s(t.text ?? ""), t.marks);
75
+ case "hardBreak":
76
+ return "<br>";
77
+ case "rule":
78
+ return "<hr>";
79
+ case "paragraph":
80
+ return `<p>${a(t.content)}</p>`;
81
+ case "heading": {
82
+ const c = Number(((n = t.attrs) == null ? void 0 : n.level) ?? 1);
83
+ return `<h${c}>${a(t.content)}</h${c}>`;
84
+ }
85
+ case "blockquote":
86
+ return `<blockquote>${a(t.content)}</blockquote>`;
87
+ case "bulletList":
88
+ return `<ul>${a(t.content)}</ul>`;
89
+ case "orderedList":
90
+ return `<ol>${a(t.content)}</ol>`;
91
+ case "listItem":
92
+ return `<li>${a(t.content)}</li>`;
93
+ case "codeBlock":
94
+ return `<pre${(e = t.attrs) != null && e.language ? ` data-language="${s(String(t.attrs.language))}"` : ""}><code>${a(t.content)}</code></pre>`;
95
+ case "emoji":
96
+ case "mention":
97
+ case "status":
98
+ return s(String(((r = t.attrs) == null ? void 0 : r.text) ?? ""));
99
+ case "inlineCard": {
100
+ const c = s(String(((u = t.attrs) == null ? void 0 : u.url) ?? ""));
101
+ return `<a href="${c}">${c}</a>`;
102
+ }
103
+ case "table":
104
+ return `<table>${a(t.content)}</table>`;
105
+ case "tableRow":
106
+ return `<tr>${a(t.content)}</tr>`;
107
+ case "tableHeader":
108
+ return `<th>${a(t.content)}</th>`;
109
+ case "tableCell":
110
+ return `<td>${a(t.content)}</td>`;
111
+ default:
112
+ return a(t.content);
113
+ }
114
+ }
115
+ function x(t) {
116
+ return a(t.content);
117
+ }
118
+ function h(t) {
40
119
  return {
41
120
  type: "doc",
42
121
  version: 1,
@@ -45,15 +124,16 @@ function p(e) {
45
124
  type: "paragraph",
46
125
  content: [{
47
126
  type: "text",
48
- text: e
127
+ text: t
49
128
  }]
50
129
  }
51
130
  ]
52
131
  };
53
132
  }
54
133
  export {
55
- a as appendParagraph,
56
- i as replaceInAdf,
57
- f as searchAdf,
58
- p as toAdfDoc
134
+ x as adfToHtml,
135
+ b as appendParagraph,
136
+ g as replaceInAdf,
137
+ $ as searchAdf,
138
+ h as toAdfDoc
59
139
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valiantys/atlassian-app",
3
- "version": "3.2.0-alpha-9",
3
+ "version": "3.2.0-alpha-10",
4
4
  "description": "This library provides Atlassian Forge components, wrappers, and utilities to support writing Forge apps that can run deployed or in standalone mode",
5
5
  "exports": {
6
6
  "./frontend-app": {
@@ -746,6 +746,52 @@
746
746
  }
747
747
  ]
748
748
  },
749
+ {
750
+ "kind": "Function",
751
+ "canonicalReference": "@valiantys/atlassian-app!adfToHtml:function(1)",
752
+ "docComment": "",
753
+ "excerptTokens": [
754
+ {
755
+ "kind": "Content",
756
+ "text": "export declare function adfToHtml(doc: "
757
+ },
758
+ {
759
+ "kind": "Reference",
760
+ "text": "AdfDoc",
761
+ "canonicalReference": "@valiantys/atlassian-app!AdfDoc:interface"
762
+ },
763
+ {
764
+ "kind": "Content",
765
+ "text": "): "
766
+ },
767
+ {
768
+ "kind": "Content",
769
+ "text": "string"
770
+ },
771
+ {
772
+ "kind": "Content",
773
+ "text": ";"
774
+ }
775
+ ],
776
+ "fileUrlPath": "../../shared/util-adf/src/lib/adf.d.ts",
777
+ "returnTypeTokenRange": {
778
+ "startIndex": 3,
779
+ "endIndex": 4
780
+ },
781
+ "releaseTag": "Public",
782
+ "overloadIndex": 1,
783
+ "parameters": [
784
+ {
785
+ "parameterName": "doc",
786
+ "parameterTypeTokenRange": {
787
+ "startIndex": 1,
788
+ "endIndex": 2
789
+ },
790
+ "isOptional": false
791
+ }
792
+ ],
793
+ "name": "adfToHtml"
794
+ },
749
795
  {
750
796
  "kind": "Function",
751
797
  "canonicalReference": "@valiantys/atlassian-app!appendParagraph:function(1)",
@@ -56,6 +56,9 @@ export interface AdfTextNode extends AdfNode {
56
56
  type: 'text';
57
57
  }
58
58
 
59
+ // @public (undocumented)
60
+ export function adfToHtml(doc: AdfDoc): string;
61
+
59
62
  // @public (undocumented)
60
63
  export function appendParagraph(doc: AdfDoc, value: string): AdfDoc;
61
64
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../atlassian/shared/util-adf/src/lib/adf/index.cjs.js");exports.appendParagraph=e.appendParagraph;exports.replaceInAdf=e.replaceInAdf;exports.searchAdf=e.searchAdf;exports.toAdfDoc=e.toAdfDoc;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../atlassian/shared/util-adf/src/lib/adf/index.cjs.js");exports.adfToHtml=a.adfToHtml;exports.appendParagraph=a.appendParagraph;exports.replaceInAdf=a.replaceInAdf;exports.searchAdf=a.searchAdf;exports.toAdfDoc=a.toAdfDoc;
@@ -46,6 +46,8 @@ export declare interface AdfTextNode extends AdfNode {
46
46
  attrs?: never;
47
47
  }
48
48
 
49
+ export declare function adfToHtml(doc: AdfDoc): string;
50
+
49
51
  export declare function appendParagraph(doc: AdfDoc, value: string): AdfDoc;
50
52
 
51
53
  export declare function replaceInAdf(doc: AdfDoc, searchText: string, replacement: string): AdfDoc;
@@ -1,7 +1,8 @@
1
- import { appendParagraph as e, replaceInAdf as p, searchAdf as d, toAdfDoc as f } from "../atlassian/shared/util-adf/src/lib/adf/index.es.js";
1
+ import { adfToHtml as d, appendParagraph as e, replaceInAdf as f, searchAdf as o, toAdfDoc as p } from "../atlassian/shared/util-adf/src/lib/adf/index.es.js";
2
2
  export {
3
+ d as adfToHtml,
3
4
  e as appendParagraph,
4
- p as replaceInAdf,
5
- d as searchAdf,
6
- f as toAdfDoc
5
+ f as replaceInAdf,
6
+ o as searchAdf,
7
+ p as toAdfDoc
7
8
  };