confluence-md-sync 0.8.4 → 0.8.6
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.
- package/README.md +10 -0
- package/dist/export/to-markdown.js +1 -0
- package/dist/macros/index.d.ts +6 -0
- package/dist/macros/index.js +13 -1
- package/dist/macros/plugins/csv-table.d.ts +21 -0
- package/dist/macros/plugins/csv-table.js +53 -0
- package/dist/macros/plugins/portfolio-for-jira-plan.d.ts +17 -0
- package/dist/macros/plugins/portfolio-for-jira-plan.js +40 -0
- package/dist/markdown/native.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -336,6 +336,10 @@ that doesn't fit falls back to markers/fenced blocks automatically.
|
|
|
336
336
|
| `status` | `{{status:Текст\|colour=Green\|subtle=true}}` |
|
|
337
337
|
| `anchor` | `{{anchor:name}}` |
|
|
338
338
|
| `detailssummary` (Page Properties Report) | `{{properties-report:cql=…\|firstcolumn=…}}` |
|
|
339
|
+
| `portfolio-for-jira-plan` (Portfolio/Advanced Roadmaps plan) | `{{portfolio-for-jira-plan:url=…\|planHeight=900}}` |
|
|
340
|
+
|
|
341
|
+
Adding a macro is a single folder: `src/macros/plugins/` (one file per macro) —
|
|
342
|
+
see [`src/macros/plugins/README.md`](src/macros/plugins/README.md).
|
|
339
343
|
|
|
340
344
|
Inside fenced code blocks the syntax is left untouched. The machine-readable
|
|
341
345
|
list is exported as `nativeMacroList()`; the md→markers pass is
|
|
@@ -370,6 +374,12 @@ macros.tableExcerptInclude('name', 'Source Page');
|
|
|
370
374
|
macros.tableExcerpt(md, 'name', /* hide */ true);
|
|
371
375
|
macros.tableFilter(md, { totalrow: ',,Sum' });
|
|
372
376
|
macros.tableJoiner(includesMd, "SELECT * FROM T1 LEFT JOIN T2 ON …"); // multiline SQL ok
|
|
377
|
+
|
|
378
|
+
// CSV Table app — render a table from an attached CSV (page body stays tiny;
|
|
379
|
+
// ideal for large datasets that would blow the Confluence storage-size limit
|
|
380
|
+
// as an inline table). Wrap in tableFilter for in-header filtering/pagination.
|
|
381
|
+
macros.csvTable('data.csv');
|
|
382
|
+
macros.tableFilter(macros.csvTable('data.csv'), { totalrow: ',,,,,,,,Sum' });
|
|
373
383
|
```
|
|
374
384
|
|
|
375
385
|
Or write markers by hand right in Markdown:
|
|
@@ -307,6 +307,7 @@ class Converter {
|
|
|
307
307
|
static NATIVE_PLACEHOLDER_NAME = {
|
|
308
308
|
toc: 'toc', children: 'children', jira: 'jira', status: 'status',
|
|
309
309
|
anchor: 'anchor', detailssummary: 'properties-report',
|
|
310
|
+
'portfolio-for-jira-plan': 'portfolio-for-jira-plan',
|
|
310
311
|
};
|
|
311
312
|
tryNativeMd(el, name) {
|
|
312
313
|
const parts = this.macroParts(el);
|
package/dist/macros/index.d.ts
CHANGED
|
@@ -4,9 +4,13 @@ export { MacroRegistry, processMacros } from './registry.js';
|
|
|
4
4
|
export { escapeXmlAttr, generateMacroId, structuredMacro, pageLinkValue, type StructuredMacroOptions, } from './xml.js';
|
|
5
5
|
export { coreMacrosPlugin, extractPlainText } from './plugins/core.js';
|
|
6
6
|
export { tableFilterPlugin, TABLE_FILTER_DEFAULTS } from './plugins/table-filter.js';
|
|
7
|
+
export { csvTablePlugin, CSV_TABLE_DEFAULTS } from './plugins/csv-table.js';
|
|
8
|
+
export { portfolioForJiraPlanPlugin } from './plugins/portfolio-for-jira-plan.js';
|
|
7
9
|
import { MacroRegistry } from './registry.js';
|
|
8
10
|
import { anchor, children, codeBlock, excerpt, excerptInclude, expand, includePage, jiraIssue, panel, status, toc } from './plugins/core.js';
|
|
9
11
|
import { tableExcerpt, tableExcerptInclude, tableFilter, tableJoiner } from './plugins/table-filter.js';
|
|
12
|
+
import { csvTable } from './plugins/csv-table.js';
|
|
13
|
+
import { portfolioForJiraPlan } from './plugins/portfolio-for-jira-plan.js';
|
|
10
14
|
/** Creates a registry pre-loaded with all built-in plugins. */
|
|
11
15
|
export declare function createDefaultRegistry(): MacroRegistry;
|
|
12
16
|
/**
|
|
@@ -42,4 +46,6 @@ export declare const macros: {
|
|
|
42
46
|
tableFilter: typeof tableFilter;
|
|
43
47
|
tableExcerptInclude: typeof tableExcerptInclude;
|
|
44
48
|
tableJoiner: typeof tableJoiner;
|
|
49
|
+
csvTable: typeof csvTable;
|
|
50
|
+
portfolioForJiraPlan: typeof portfolioForJiraPlan;
|
|
45
51
|
};
|
package/dist/macros/index.js
CHANGED
|
@@ -4,14 +4,24 @@ export { MacroRegistry, processMacros } from './registry.js';
|
|
|
4
4
|
export { escapeXmlAttr, generateMacroId, structuredMacro, pageLinkValue, } from './xml.js';
|
|
5
5
|
export { coreMacrosPlugin, extractPlainText } from './plugins/core.js';
|
|
6
6
|
export { tableFilterPlugin, TABLE_FILTER_DEFAULTS } from './plugins/table-filter.js';
|
|
7
|
+
export { csvTablePlugin, CSV_TABLE_DEFAULTS } from './plugins/csv-table.js';
|
|
8
|
+
export { portfolioForJiraPlanPlugin } from './plugins/portfolio-for-jira-plan.js';
|
|
7
9
|
import { MacroRegistry } from './registry.js';
|
|
8
10
|
import { coreMacrosPlugin } from './plugins/core.js';
|
|
9
11
|
import { tableFilterPlugin } from './plugins/table-filter.js';
|
|
12
|
+
import { csvTablePlugin } from './plugins/csv-table.js';
|
|
13
|
+
import { portfolioForJiraPlanPlugin } from './plugins/portfolio-for-jira-plan.js';
|
|
10
14
|
import { anchor, children, codeBlock, excerpt, excerptInclude, expand, includePage, info, jiraIssue, note, panel, status, tip, toc, warning, } from './plugins/core.js';
|
|
11
15
|
import { tableExcerpt, tableExcerptInclude, tableFilter, tableJoiner } from './plugins/table-filter.js';
|
|
16
|
+
import { csvTable } from './plugins/csv-table.js';
|
|
17
|
+
import { portfolioForJiraPlan } from './plugins/portfolio-for-jira-plan.js';
|
|
12
18
|
/** Creates a registry pre-loaded with all built-in plugins. */
|
|
13
19
|
export function createDefaultRegistry() {
|
|
14
|
-
return new MacroRegistry()
|
|
20
|
+
return new MacroRegistry()
|
|
21
|
+
.use(coreMacrosPlugin)
|
|
22
|
+
.use(tableFilterPlugin)
|
|
23
|
+
.use(csvTablePlugin)
|
|
24
|
+
.use(portfolioForJiraPlanPlugin);
|
|
15
25
|
}
|
|
16
26
|
/**
|
|
17
27
|
* Глобальный реестр по умолчанию (core + table-filter). Используется,
|
|
@@ -48,4 +58,6 @@ export const macros = {
|
|
|
48
58
|
tableFilter,
|
|
49
59
|
tableExcerptInclude,
|
|
50
60
|
tableJoiner,
|
|
61
|
+
csvTable,
|
|
62
|
+
portfolioForJiraPlan,
|
|
51
63
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin for the "CSV Table" Confluence macro (csv-table): renders a table
|
|
3
|
+
* from a CSV — most usefully from a page attachment (`source=attachment`),
|
|
4
|
+
* so the page body stays tiny while the data lives in the attached CSV.
|
|
5
|
+
* Large datasets that would blow the Confluence storage-size limit as an
|
|
6
|
+
* inline table are published as a CSV attachment and rendered by this macro
|
|
7
|
+
* (optionally wrapped in table-filter for in-header filtering/pagination).
|
|
8
|
+
*/
|
|
9
|
+
import { Markdown } from '../../markdown/markdown.js';
|
|
10
|
+
import { type MacroPlugin } from '../types.js';
|
|
11
|
+
export declare const CSV_TABLE_DEFAULTS: Record<string, string>;
|
|
12
|
+
export declare const csvTablePlugin: MacroPlugin;
|
|
13
|
+
/**
|
|
14
|
+
* Строит макрос "CSV Table" из вложения. По умолчанию `source=attachment`.
|
|
15
|
+
* Опции перекрывают дефолты (например `header`, `source`).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* csvTable('worklogs_summary.csv')
|
|
19
|
+
* macros.tableFilter(csvTable('worklogs_summary.csv'), { totalrow: ',,,,,,,,Sum' })
|
|
20
|
+
*/
|
|
21
|
+
export declare function csvTable(attachment: string, opts?: Record<string, string | undefined>): Markdown;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin for the "CSV Table" Confluence macro (csv-table): renders a table
|
|
3
|
+
* from a CSV — most usefully from a page attachment (`source=attachment`),
|
|
4
|
+
* so the page body stays tiny while the data lives in the attached CSV.
|
|
5
|
+
* Large datasets that would blow the Confluence storage-size limit as an
|
|
6
|
+
* inline table are published as a CSV attachment and rendered by this macro
|
|
7
|
+
* (optionally wrapped in table-filter for in-header filtering/pagination).
|
|
8
|
+
*/
|
|
9
|
+
import { macro } from '../builder.js';
|
|
10
|
+
import { paramMap } from '../types.js';
|
|
11
|
+
import { structuredMacro } from '../xml.js';
|
|
12
|
+
// Дефолты csv-table, какие сохраняет редактор Confluence. Пустые-присутствие
|
|
13
|
+
// (password/header/login) — чтобы редактор не «терял» контролы при следующем
|
|
14
|
+
// открытии и сохранении страницы. source=attachment — данные из вложения.
|
|
15
|
+
export const CSV_TABLE_DEFAULTS = {
|
|
16
|
+
isFirstTimeEnter: 'true',
|
|
17
|
+
password: '',
|
|
18
|
+
header: '',
|
|
19
|
+
source: 'attachment',
|
|
20
|
+
login: '',
|
|
21
|
+
};
|
|
22
|
+
// Порядок параметров как у редактора (стабильный вывод, дружелюбно к hash-diff).
|
|
23
|
+
const CSV_TABLE_PARAM_ORDER = ['isFirstTimeEnter', 'password', 'attachment', 'header', 'source', 'login'];
|
|
24
|
+
export const csvTablePlugin = {
|
|
25
|
+
name: 'csv-table',
|
|
26
|
+
macros: [
|
|
27
|
+
{
|
|
28
|
+
// Макрос «CSV Table». Рендерит таблицу из CSV. Обычный режим —
|
|
29
|
+
// source=attachment + attachment=<имя.csv>: CSV берётся из вложения
|
|
30
|
+
// страницы, тело страницы не пухнет от данных. Все переданные параметры
|
|
31
|
+
// накладываются поверх дефолтов; вывод — в каноничном порядке редактора.
|
|
32
|
+
name: 'csv-table',
|
|
33
|
+
render: (ctx) => {
|
|
34
|
+
const merged = { ...CSV_TABLE_DEFAULTS, ...paramMap(ctx.params) };
|
|
35
|
+
const keys = [...CSV_TABLE_PARAM_ORDER, ...Object.keys(merged).filter((k) => !CSV_TABLE_PARAM_ORDER.includes(k))];
|
|
36
|
+
const params = keys.filter((k) => merged[k] !== undefined).map((k) => ({ name: k, value: merged[k] }));
|
|
37
|
+
return structuredMacro('csv-table', ctx.macroId, { params });
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
// ── Convenience builder ─────────────────────────────────────────────────
|
|
43
|
+
/**
|
|
44
|
+
* Строит макрос "CSV Table" из вложения. По умолчанию `source=attachment`.
|
|
45
|
+
* Опции перекрывают дефолты (например `header`, `source`).
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* csvTable('worklogs_summary.csv')
|
|
49
|
+
* macros.tableFilter(csvTable('worklogs_summary.csv'), { totalrow: ',,,,,,,,Sum' })
|
|
50
|
+
*/
|
|
51
|
+
export function csvTable(attachment, opts = {}) {
|
|
52
|
+
return macro('csv-table').param('attachment', attachment).withParams(opts).toMarkdown();
|
|
53
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin for the "Portfolio for Jira — Plan" macro (portfolio-for-jira-plan):
|
|
3
|
+
* embeds an Advanced Roadmaps / Portfolio plan roadmap on a Confluence page.
|
|
4
|
+
* Bodyless macro; the plan is addressed by `url`, height by `planHeight`.
|
|
5
|
+
*
|
|
6
|
+
* Native md syntax (see native.ts + README): `{{portfolio-for-jira-plan:url=…|planHeight=900}}`.
|
|
7
|
+
*/
|
|
8
|
+
import { Markdown } from '../../markdown/markdown.js';
|
|
9
|
+
import { type MacroPlugin } from '../types.js';
|
|
10
|
+
export declare const portfolioForJiraPlanPlugin: MacroPlugin;
|
|
11
|
+
/**
|
|
12
|
+
* Строит макрос «Portfolio for Jira — Plan».
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* portfolioForJiraPlan('https://jira/secure/PortfolioRoadmapConfluence.jspa?r=abc', { planHeight: '900' })
|
|
16
|
+
*/
|
|
17
|
+
export declare function portfolioForJiraPlan(url: string, opts?: Record<string, string | undefined>): Markdown;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin for the "Portfolio for Jira — Plan" macro (portfolio-for-jira-plan):
|
|
3
|
+
* embeds an Advanced Roadmaps / Portfolio plan roadmap on a Confluence page.
|
|
4
|
+
* Bodyless macro; the plan is addressed by `url`, height by `planHeight`.
|
|
5
|
+
*
|
|
6
|
+
* Native md syntax (see native.ts + README): `{{portfolio-for-jira-plan:url=…|planHeight=900}}`.
|
|
7
|
+
*/
|
|
8
|
+
import { macro } from '../builder.js';
|
|
9
|
+
import { paramMap } from '../types.js';
|
|
10
|
+
import { structuredMacro } from '../xml.js';
|
|
11
|
+
// Порядок параметров как у редактора Confluence (стабильный вывод под hash-diff).
|
|
12
|
+
const PORTFOLIO_PARAM_ORDER = ['planHeight', 'url'];
|
|
13
|
+
export const portfolioForJiraPlanPlugin = {
|
|
14
|
+
name: 'portfolio-for-jira-plan',
|
|
15
|
+
macros: [
|
|
16
|
+
{
|
|
17
|
+
// Макрос «Portfolio for Jira — Plan». Bodyless; параметры пробрасываются
|
|
18
|
+
// как есть, в каноничном порядке редактора. url — ссылка на план-роадмап,
|
|
19
|
+
// planHeight — высота встраивания в пикселях.
|
|
20
|
+
name: 'portfolio-for-jira-plan',
|
|
21
|
+
render: (ctx) => {
|
|
22
|
+
const m = paramMap(ctx.params);
|
|
23
|
+
const keys = [...PORTFOLIO_PARAM_ORDER.filter((k) => m[k] !== undefined),
|
|
24
|
+
...Object.keys(m).filter((k) => !PORTFOLIO_PARAM_ORDER.includes(k))];
|
|
25
|
+
const params = keys.map((k) => ({ name: k, value: m[k] }));
|
|
26
|
+
return structuredMacro('portfolio-for-jira-plan', ctx.macroId, { params });
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
// ── Convenience builder ─────────────────────────────────────────────────
|
|
32
|
+
/**
|
|
33
|
+
* Строит макрос «Portfolio for Jira — Plan».
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* portfolioForJiraPlan('https://jira/secure/PortfolioRoadmapConfluence.jspa?r=abc', { planHeight: '900' })
|
|
37
|
+
*/
|
|
38
|
+
export function portfolioForJiraPlan(url, opts = {}) {
|
|
39
|
+
return macro('portfolio-for-jira-plan').param('url', url).withParams(opts).toMarkdown();
|
|
40
|
+
}
|
package/dist/markdown/native.js
CHANGED
|
@@ -51,6 +51,7 @@ export const NATIVE_PLACEHOLDERS = {
|
|
|
51
51
|
status: 'status',
|
|
52
52
|
anchor: 'anchor',
|
|
53
53
|
'properties-report': 'detailssummary',
|
|
54
|
+
'portfolio-for-jira-plan': 'portfolio-for-jira-plan',
|
|
54
55
|
};
|
|
55
56
|
/** Полный перечень макросов с нативной md-разметкой (для документации/UI). */
|
|
56
57
|
export function nativeMacroList() {
|
|
@@ -68,12 +69,13 @@ export function nativeMacroList() {
|
|
|
68
69
|
{ macro: 'status', syntax: '{{status:Текст|colour=Green|subtle=true}}' },
|
|
69
70
|
{ macro: 'anchor', syntax: '{{anchor:имя}}' },
|
|
70
71
|
{ macro: 'detailssummary', syntax: '{{properties-report:cql=…|firstcolumn=…}}' },
|
|
72
|
+
{ macro: 'portfolio-for-jira-plan', syntax: '{{portfolio-for-jira-plan:url=…|planHeight=900}}' },
|
|
71
73
|
];
|
|
72
74
|
}
|
|
73
75
|
const ADMONITION_FIRST_RE = /^>\s*\[!([A-Za-z]+)\]\s*(.*)$/;
|
|
74
76
|
const DIRECTIVE_OPEN_RE = /^:::\s+([a-z-]+)(?:\s+(.*?))?\s*$/;
|
|
75
77
|
const DIRECTIVE_CLOSE_RE = /^:::\s*$/;
|
|
76
|
-
const PLACEHOLDER_INLINE_RE = /\{\{(toc|children|jira|status|anchor|properties-report)(?::((?:[^{}]|\{[^{])*?))?\}\}/g;
|
|
78
|
+
const PLACEHOLDER_INLINE_RE = /\{\{(toc|children|jira|status|anchor|properties-report|portfolio-for-jira-plan)(?::((?:[^{}]|\{[^{])*?))?\}\}/g;
|
|
77
79
|
const FENCE_RE = /^\s*(`{3,}|~{3,})/;
|
|
78
80
|
/** Компактная пара маркеров без тела — для строчного контекста. */
|
|
79
81
|
function inlineMarker(macroName, params) {
|
package/package.json
CHANGED