jg-publishing-guides 0.0.0-stage → 1.0.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.
- package/API.md +190 -0
- package/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +30 -2
- package/RECIPES.md +32 -0
- package/dist/guide/controls.d.ts +7 -0
- package/dist/guide/controls.js +177 -0
- package/dist/guide/controls.js.map +1 -0
- package/dist/guide/guide.d.ts +25 -0
- package/dist/guide/guide.js +33 -0
- package/dist/guide/guide.js.map +1 -0
- package/dist/guide/index.d.ts +3 -0
- package/dist/guide/index.js +5 -0
- package/dist/guide/index.js.map +1 -0
- package/dist/guide/presentation.d.ts +5 -0
- package/dist/guide/presentation.js +291 -0
- package/dist/guide/presentation.js.map +1 -0
- package/dist/guide/styles.d.ts +1 -0
- package/dist/guide/styles.js +80 -0
- package/dist/guide/styles.js.map +1 -0
- package/dist/guide/types.d.ts +45 -0
- package/dist/guide/types.js +2 -0
- package/dist/guide/types.js.map +1 -0
- package/dist/guide/validations.d.ts +16 -0
- package/dist/guide/validations.js +167 -0
- package/dist/guide/validations.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -3
package/API.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# <a id="api-reference"></a>jg-publishing-guides API reference
|
|
2
|
+
|
|
3
|
+
Every export of `jg-publishing-guides@1.0.1`, 9 in all, with its signature, its errors, and an example. It's generated from the package's TSDoc.
|
|
4
|
+
|
|
5
|
+
- Functions: [`renderPublishingGuide`](#api-renderPublishingGuide)
|
|
6
|
+
- Constants: [`ERRORS`](#api-ERRORS)
|
|
7
|
+
- Types: [`IPublishingChannel`](#api-IPublishingChannel), [`IPublishingGuide`](#api-IPublishingGuide), [`IPublishingGuideFile`](#api-IPublishingGuideFile), [`IPublishingGuideLocale`](#api-IPublishingGuideLocale), [`IPublishingGuideOptions`](#api-IPublishingGuideOptions), [`IPublishingGuideResult`](#api-IPublishingGuideResult), [`IPublishingGuideStep`](#api-IPublishingGuideStep)
|
|
8
|
+
|
|
9
|
+
## <a id="api-functions"></a>Functions
|
|
10
|
+
|
|
11
|
+
### <a id="api-renderPublishingGuide"></a>`renderPublishingGuide`
|
|
12
|
+
|
|
13
|
+
*Function*
|
|
14
|
+
|
|
15
|
+
Renders a caller-approved selection into a self-contained HTML guide and a plain-text README. The HTML uses local relative file links and an inline script permitted by its exact CSP hash.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
renderPublishingGuide(
|
|
19
|
+
guide: IPublishingGuide,
|
|
20
|
+
copy?: ReadonlyMap<string, string>,
|
|
21
|
+
options?: IPublishingGuideOptions,
|
|
22
|
+
): IPublishingGuideResult
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Parameters**
|
|
26
|
+
|
|
27
|
+
- `guide` `IPublishingGuide`: The title, selected files and optional channel steps.
|
|
28
|
+
- `copy?` `ReadonlyMap<string, string>`: Reviewed literal text keyed by selected local filename. Defaults to `...`.
|
|
29
|
+
- `options?` `IPublishingGuideOptions`: The guide interface locale. Defaults to `{}`.
|
|
30
|
+
|
|
31
|
+
**Returns** `IPublishingGuideResult`: The HTML and plain-text documents.
|
|
32
|
+
|
|
33
|
+
**Throws**
|
|
34
|
+
|
|
35
|
+
- `INVALID_PUBLISHING_GUIDE`: The publishing guide input is invalid.
|
|
36
|
+
|
|
37
|
+
**Example**
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { renderPublishingGuide } from 'jg-publishing-guides';
|
|
41
|
+
|
|
42
|
+
const { html, readme } = renderPublishingGuide(
|
|
43
|
+
{
|
|
44
|
+
title: 'Reviewed caption',
|
|
45
|
+
summary: 'Selected copy for manual publication.',
|
|
46
|
+
files: [{ path: 'caption.txt', label: 'Caption', details: 'Reviewed text.', kind: 'file' }],
|
|
47
|
+
},
|
|
48
|
+
new Map([['caption.txt', 'Copy for the published post.']]),
|
|
49
|
+
);
|
|
50
|
+
// write html to start-here.html and readme to readme.txt beside caption.txt
|
|
51
|
+
void [html, readme];
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## <a id="api-constants"></a>Constants
|
|
55
|
+
|
|
56
|
+
### <a id="api-ERRORS"></a>`ERRORS`
|
|
57
|
+
|
|
58
|
+
*Constant*
|
|
59
|
+
|
|
60
|
+
stable public code for presentation input failures
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
const ERRORS: { INVALID_PUBLISHING_GUIDE: "INVALID_PUBLISHING_GUIDE" }
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## <a id="api-types"></a>Types
|
|
67
|
+
|
|
68
|
+
### <a id="api-IPublishingChannel"></a>`IPublishingChannel`
|
|
69
|
+
|
|
70
|
+
*Type*
|
|
71
|
+
|
|
72
|
+
manual destinations already supported by offline publishing packets
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
type IPublishingChannel = 'x' | 'linkedin' | 'instagram' | 'tiktok' | 'facebook' | 'threads' | 'bluesky' | 'youtube' | 'github' | 'post';
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### <a id="api-IPublishingGuide"></a>`IPublishingGuide`
|
|
79
|
+
|
|
80
|
+
*Type*
|
|
81
|
+
|
|
82
|
+
the caller-approved presentation records for one publishing packet
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
type IPublishingGuide = {
|
|
86
|
+
title: string;
|
|
87
|
+
summary: string;
|
|
88
|
+
files: IPublishingGuideFile[];
|
|
89
|
+
walkthrough?: IPublishingGuideStep[];
|
|
90
|
+
};
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Members**
|
|
94
|
+
|
|
95
|
+
- `title: string` (property)
|
|
96
|
+
- `summary: string` (property)
|
|
97
|
+
- `files: IPublishingGuideFile[]` (property)
|
|
98
|
+
- `walkthrough: IPublishingGuideStep[]` (property)
|
|
99
|
+
|
|
100
|
+
### <a id="api-IPublishingGuideFile"></a>`IPublishingGuideFile`
|
|
101
|
+
|
|
102
|
+
*Type*
|
|
103
|
+
|
|
104
|
+
one portable file selected by the caller, with preview dimensions for images and video
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
type IPublishingGuideFile = {
|
|
108
|
+
path: string;
|
|
109
|
+
label: string;
|
|
110
|
+
details: string;
|
|
111
|
+
} & ({
|
|
112
|
+
kind: 'file';
|
|
113
|
+
} | {
|
|
114
|
+
kind: 'image' | 'video';
|
|
115
|
+
width: number;
|
|
116
|
+
height: number;
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### <a id="api-IPublishingGuideLocale"></a>`IPublishingGuideLocale`
|
|
121
|
+
|
|
122
|
+
*Type*
|
|
123
|
+
|
|
124
|
+
supported interface languages
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
type IPublishingGuideLocale = 'en' | 'es';
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### <a id="api-IPublishingGuideOptions"></a>`IPublishingGuideOptions`
|
|
131
|
+
|
|
132
|
+
*Type*
|
|
133
|
+
|
|
134
|
+
the interface locale is independent of the authored copy
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
type IPublishingGuideOptions = {
|
|
138
|
+
locale?: IPublishingGuideLocale;
|
|
139
|
+
};
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Members**
|
|
143
|
+
|
|
144
|
+
- `locale: IPublishingGuideLocale` (property)
|
|
145
|
+
|
|
146
|
+
### <a id="api-IPublishingGuideResult"></a>`IPublishingGuideResult`
|
|
147
|
+
|
|
148
|
+
*Type*
|
|
149
|
+
|
|
150
|
+
offline formats for start-here.html and readme.txt, respectively
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
type IPublishingGuideResult = {
|
|
154
|
+
html: string;
|
|
155
|
+
readme: string;
|
|
156
|
+
};
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Members**
|
|
160
|
+
|
|
161
|
+
- `html: string` (property)
|
|
162
|
+
- `readme: string` (property)
|
|
163
|
+
|
|
164
|
+
### <a id="api-IPublishingGuideStep"></a>`IPublishingGuideStep`
|
|
165
|
+
|
|
166
|
+
*Type*
|
|
167
|
+
|
|
168
|
+
one channel's caption and upload order, or a repost of an earlier Instagram step
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
type IPublishingGuideStep = ({
|
|
172
|
+
channel: IPublishingChannel;
|
|
173
|
+
id?: string;
|
|
174
|
+
caption: string;
|
|
175
|
+
media: string[];
|
|
176
|
+
documentTitle?: string;
|
|
177
|
+
postTitle?: string;
|
|
178
|
+
repostOf?: undefined;
|
|
179
|
+
} | {
|
|
180
|
+
channel: 'instagram';
|
|
181
|
+
id: string;
|
|
182
|
+
caption?: string;
|
|
183
|
+
media: [];
|
|
184
|
+
documentTitle?: undefined;
|
|
185
|
+
postTitle?: undefined;
|
|
186
|
+
repostOf: string;
|
|
187
|
+
}) & {
|
|
188
|
+
label?: string;
|
|
189
|
+
};
|
|
190
|
+
```
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Allow a channel ID ending in `-title` or `-title-status` when the corresponding title field is absent.
|
|
8
|
+
|
|
9
|
+
## 1.0.0
|
|
10
|
+
|
|
11
|
+
- Render offline manual publishing guides and matching plain text in English and Spanish.
|
|
12
|
+
- Preserve ordered media, literal copy, document titles, TikTok title variants and Instagram reposts.
|
|
13
|
+
- Include keyboard navigation, clipboard fallback and stable CSP-protected controls.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jesus Graterol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
-
#
|
|
1
|
+
# jg-publishing-guides
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Render a reviewed file selection into an offline publishing guide and its plain-text fallback. Runs on Node.js 22.17 or later.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install jg-publishing-guides
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
`renderPublishingGuide` takes a title, a summary, selected files, optional channel steps and literal copy keyed by selected path. It returns `html` for `start-here.html` and `readme` for `readme.txt`. Keep both files alongside the selected outputs. The English or Spanish interface follows the requested locale. Reviewed copy remains in its original language.
|
|
14
|
+
|
|
15
|
+
Use a file-only guide for a handoff without channel steps. Channel guides support ordered image uploads, document posts, TikTok captions with an optional separate title, and Instagram reposts of a preceding, explicitly identified original. The HTML offers keyboard navigation, file links and copy controls with manual selection on clipboard refusal. Its inline script is authorized by its exact CSP hash. The page uses system light and dark modes and needs no server or installation.
|
|
16
|
+
|
|
17
|
+
The renderer validates portable paths and presentation references. Your caller owns file access, selection and publication approval. The guide provides instructions for manual publication.
|
|
18
|
+
|
|
19
|
+
## Errors
|
|
20
|
+
|
|
21
|
+
| Code | Message |
|
|
22
|
+
| -------------------------- | -------------------------------------- |
|
|
23
|
+
| `INVALID_PUBLISHING_GUIDE` | The publishing guide input is invalid. |
|
|
24
|
+
|
|
25
|
+
## Documentation
|
|
26
|
+
|
|
27
|
+
See [API.md](API.md) for the contracts and [RECIPES.md](RECIPES.md) for an example.
|
|
28
|
+
|
|
29
|
+
## License
|
|
30
|
+
|
|
31
|
+
[MIT](LICENSE)
|
package/RECIPES.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# jg-publishing-guides recipes
|
|
2
|
+
|
|
3
|
+
Turn reviewed text, media, and channel steps into an offline Spanish publishing guide and a plain-text fallback.
|
|
4
|
+
|
|
5
|
+
## Render a bilingual workflow's Spanish guide
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { renderPublishingGuide } from 'jg-publishing-guides';
|
|
9
|
+
|
|
10
|
+
const { html, readme } = renderPublishingGuide(
|
|
11
|
+
{
|
|
12
|
+
title: 'Publicación revisada',
|
|
13
|
+
summary: 'Material preparado para publicación manual.',
|
|
14
|
+
files: [
|
|
15
|
+
{ path: 'caption.txt', label: 'Texto', details: 'Texto aprobado.', kind: 'file' },
|
|
16
|
+
{
|
|
17
|
+
path: 'post.png',
|
|
18
|
+
label: 'Imagen',
|
|
19
|
+
details: 'Diagrama de dos colaboradores revisando una publicación.',
|
|
20
|
+
kind: 'image',
|
|
21
|
+
width: 1080,
|
|
22
|
+
height: 1350,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
walkthrough: [{ channel: 'instagram', caption: 'caption.txt', media: ['post.png'] }],
|
|
26
|
+
},
|
|
27
|
+
new Map([['caption.txt', 'Texto que se copiará en la publicación.']]),
|
|
28
|
+
{ locale: 'es' },
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
void [html, readme]; // Write start-here.html and readme.txt beside the selected files.
|
|
32
|
+
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhances the exported guide using only its rendered controls and literal field values.
|
|
3
|
+
* This function is serialized into the offline page; keep it self-contained.
|
|
4
|
+
* Clipboard rejection stays local, preserves selectable copy, and exposes no raw error.
|
|
5
|
+
* @returns {void}
|
|
6
|
+
*/
|
|
7
|
+
export declare const initializeDeliveryControls: () => void;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhances the exported guide using only its rendered controls and literal field values.
|
|
3
|
+
* This function is serialized into the offline page; keep it self-contained.
|
|
4
|
+
* Clipboard rejection stays local, preserves selectable copy, and exposes no raw error.
|
|
5
|
+
* @returns {void}
|
|
6
|
+
*/
|
|
7
|
+
export const initializeDeliveryControls = () => {
|
|
8
|
+
const channels = [...document.querySelectorAll('details.channel')].filter((node) => node instanceof HTMLDetailsElement);
|
|
9
|
+
const networkNav = document.querySelector('[data-network-nav]');
|
|
10
|
+
const stepNav = document.querySelector('[data-step-nav]');
|
|
11
|
+
document.documentElement.dataset['guideControls'] = '';
|
|
12
|
+
/** @returns {void} Fits the navigation offset and visible copy to the current layout. */
|
|
13
|
+
const fitGuideLayout = () => {
|
|
14
|
+
const toolbar = networkNav?.closest('.toolbar');
|
|
15
|
+
if (toolbar instanceof HTMLElement)
|
|
16
|
+
document.documentElement.style.setProperty('--guide-nav-height', `${toolbar.getBoundingClientRect().height}px`);
|
|
17
|
+
for (const field of document.querySelectorAll('textarea[readonly]')) {
|
|
18
|
+
if (!(field instanceof HTMLTextAreaElement) || field.getClientRects().length === 0)
|
|
19
|
+
continue;
|
|
20
|
+
field.style.height = 'auto';
|
|
21
|
+
field.style.height = `${field.scrollHeight + field.offsetHeight - field.clientHeight}px`;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Keeps the persistent shortcuts aligned with the currently open network.
|
|
26
|
+
* @param {string | undefined} channel The open network identifier.
|
|
27
|
+
* @returns {void}
|
|
28
|
+
*/
|
|
29
|
+
const updateNavigation = (channel) => {
|
|
30
|
+
if (!(networkNav instanceof HTMLElement) || !(stepNav instanceof HTMLElement))
|
|
31
|
+
return;
|
|
32
|
+
for (const link of networkNav.querySelectorAll('a[data-channel]')) {
|
|
33
|
+
if (!(link instanceof HTMLAnchorElement))
|
|
34
|
+
continue;
|
|
35
|
+
if (link.dataset['channel'] === channel) {
|
|
36
|
+
link.setAttribute('aria-current', 'location');
|
|
37
|
+
const bounds = link.getBoundingClientRect(), container = networkNav.getBoundingClientRect();
|
|
38
|
+
if (bounds.left < container.left || bounds.right > container.right)
|
|
39
|
+
link.scrollIntoView({ block: 'nearest', inline: 'nearest', behavior: 'instant' });
|
|
40
|
+
}
|
|
41
|
+
else
|
|
42
|
+
link.removeAttribute('aria-current');
|
|
43
|
+
}
|
|
44
|
+
stepNav.hidden = !channel;
|
|
45
|
+
for (const link of stepNav.querySelectorAll('a[data-step]')) {
|
|
46
|
+
if (link instanceof HTMLAnchorElement && channel)
|
|
47
|
+
link.href = `#${channel}-${link.dataset['step']}`;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Opens one network without relying on exclusive-details support in the browser.
|
|
52
|
+
* @param {HTMLDetailsElement} selected The requested network section.
|
|
53
|
+
* @returns {void}
|
|
54
|
+
*/
|
|
55
|
+
const openChannel = (selected) => {
|
|
56
|
+
for (const channel of channels) {
|
|
57
|
+
channel.hidden = channel !== selected;
|
|
58
|
+
channel.open = channel === selected;
|
|
59
|
+
}
|
|
60
|
+
updateNavigation(selected.id);
|
|
61
|
+
fitGuideLayout();
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Repositions after changing section heights, including repeat selections.
|
|
65
|
+
* @param {HTMLDetailsElement} selected The requested network section.
|
|
66
|
+
* @returns {void}
|
|
67
|
+
*/
|
|
68
|
+
const navigateToStart = (selected) => {
|
|
69
|
+
openChannel(selected);
|
|
70
|
+
const heading = document.getElementById(`${selected.id}-start`);
|
|
71
|
+
if (!(heading instanceof HTMLElement))
|
|
72
|
+
return;
|
|
73
|
+
location.hash = heading.id;
|
|
74
|
+
heading.focus({ preventScroll: true });
|
|
75
|
+
heading.scrollIntoView({ block: 'start', behavior: 'instant' });
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Opens a known section for direct links and browser Back/Forward.
|
|
79
|
+
* @param {boolean} [restoreStart] Restore focus for history returning to the initial network.
|
|
80
|
+
* @returns {void}
|
|
81
|
+
*/
|
|
82
|
+
const followFragment = (restoreStart = false) => {
|
|
83
|
+
const fragment = location.hash.slice(1);
|
|
84
|
+
const target = document.getElementById(fragment || `${channels[0]?.id}-start`);
|
|
85
|
+
const channel = target?.closest('details.channel');
|
|
86
|
+
if (channel instanceof HTMLDetailsElement && target instanceof HTMLElement) {
|
|
87
|
+
// Native in-panel links already move focus; do not race the user's next Tab.
|
|
88
|
+
const needsFocus = channel.hidden || !channel.open || (!fragment && restoreStart);
|
|
89
|
+
openChannel(channel);
|
|
90
|
+
if (needsFocus) {
|
|
91
|
+
target.focus({ preventScroll: true });
|
|
92
|
+
target.scrollIntoView({ block: 'start', behavior: 'instant' });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
for (const link of document.querySelectorAll('a[data-channel]')) {
|
|
97
|
+
if (!(link instanceof HTMLAnchorElement))
|
|
98
|
+
continue;
|
|
99
|
+
link.addEventListener('click', (event) => {
|
|
100
|
+
if (event instanceof MouseEvent &&
|
|
101
|
+
(event.button !== 0 || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey))
|
|
102
|
+
return;
|
|
103
|
+
const selected = channels.find((channel) => channel.id === link.dataset['channel']);
|
|
104
|
+
if (!selected)
|
|
105
|
+
return;
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
navigateToStart(selected);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
for (const channel of channels) {
|
|
111
|
+
channel.querySelector('summary')?.addEventListener('click', (event) => {
|
|
112
|
+
if (channel.open)
|
|
113
|
+
return;
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
navigateToStart(channel);
|
|
116
|
+
});
|
|
117
|
+
channel.addEventListener('toggle', () => {
|
|
118
|
+
if (channel.open)
|
|
119
|
+
openChannel(channel);
|
|
120
|
+
else
|
|
121
|
+
updateNavigation(channels.find((node) => node.open)?.id);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
window.addEventListener('hashchange', () => followFragment(true));
|
|
125
|
+
window.addEventListener('resize', fitGuideLayout);
|
|
126
|
+
document.addEventListener('toggle', fitGuideLayout, true);
|
|
127
|
+
followFragment();
|
|
128
|
+
updateNavigation(channels.find((channel) => channel.open)?.id);
|
|
129
|
+
for (const button of document.querySelectorAll('[data-copy-target]')) {
|
|
130
|
+
if (!(button instanceof HTMLButtonElement))
|
|
131
|
+
continue;
|
|
132
|
+
const field = document.getElementById(button.dataset['copyTarget'] ?? '');
|
|
133
|
+
const status = document.getElementById(button.dataset['copyStatus'] ?? '');
|
|
134
|
+
const block = button.closest('.copy-block');
|
|
135
|
+
if (!(field instanceof HTMLTextAreaElement) ||
|
|
136
|
+
!(status instanceof HTMLElement) ||
|
|
137
|
+
!(block instanceof HTMLElement))
|
|
138
|
+
continue;
|
|
139
|
+
/** @returns {void} Keeps manual copy available when clipboard access is unavailable. */
|
|
140
|
+
const selectForManualCopy = () => {
|
|
141
|
+
field.focus({ preventScroll: true });
|
|
142
|
+
field.select();
|
|
143
|
+
status.textContent =
|
|
144
|
+
button.dataset['copyFallback'] ?? "Text selected. Use your device's Copy command.";
|
|
145
|
+
};
|
|
146
|
+
const writeCopy = async () => {
|
|
147
|
+
if (button.getAttribute('aria-disabled') === 'true')
|
|
148
|
+
return;
|
|
149
|
+
button.setAttribute('aria-disabled', 'true');
|
|
150
|
+
block.setAttribute('aria-busy', 'true');
|
|
151
|
+
try {
|
|
152
|
+
if (typeof navigator.clipboard?.writeText !== 'function') {
|
|
153
|
+
selectForManualCopy();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
// Start inside the activation handler, before the first await.
|
|
157
|
+
const writing = navigator.clipboard.writeText(field.value);
|
|
158
|
+
status.textContent = button.dataset['copyPending'] ?? 'Copying...';
|
|
159
|
+
await writing;
|
|
160
|
+
status.textContent = button.dataset['copySuccess'] ?? 'Copied.';
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
selectForManualCopy();
|
|
164
|
+
}
|
|
165
|
+
finally {
|
|
166
|
+
button.removeAttribute('aria-disabled');
|
|
167
|
+
block.removeAttribute('aria-busy');
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
button.addEventListener('click', () => {
|
|
171
|
+
void writeCopy();
|
|
172
|
+
});
|
|
173
|
+
button.hidden = false;
|
|
174
|
+
}
|
|
175
|
+
fitGuideLayout();
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controls.js","sourceRoot":"","sources":["../../src/guide/controls.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAS,EAAE;IACnD,MAAM,QAAQ,GAAG,CAAC,GAAG,QAAQ,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CACvE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,YAAY,kBAAkB,CAC7C,CAAC;IACF,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;IAChE,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vF,CAAC,CAAC;QAEF,MAAM,SAAS,GAAG,KAAK,IAAmB,EAAE;YAC1C,IAAI,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,MAAM;gBAAE,OAAO;YAC5D,MAAM,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;YAC7C,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;YACxC,IAAI,CAAC;gBACH,IAAI,OAAO,SAAS,CAAC,SAAS,EAAE,SAAS,KAAK,UAAU,EAAE,CAAC;oBACzD,mBAAmB,EAAE,CAAC;oBACtB,OAAO;gBACT,CAAC;gBACD,+DAA+D;gBAC/D,MAAM,OAAO,GAAG,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC3D,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,YAAY,CAAC;gBACnE,MAAM,OAAO,CAAC;gBACd,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,SAAS,CAAC;YAClE,CAAC;YAAC,MAAM,CAAC;gBACP,mBAAmB,EAAE,CAAC;YACxB,CAAC;oBAAS,CAAC;gBACT,MAAM,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;gBACxC,KAAK,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;YACrC,CAAC;QACH,CAAC,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YACpC,KAAK,SAAS,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IACD,cAAc,EAAE,CAAC;AACnB,CAAC,CAAC","sourcesContent":["/**\n * Enhances the exported guide using only its rendered controls and literal field values.\n * This function is serialized into the offline page; keep it self-contained.\n * Clipboard rejection stays local, preserves selectable copy, and exposes no raw error.\n * @returns {void}\n */\nexport const initializeDeliveryControls = (): void => {\n const channels = [...document.querySelectorAll('details.channel')].filter(\n (node) => node instanceof HTMLDetailsElement,\n );\n const networkNav = document.querySelector('[data-network-nav]');\n const stepNav = document.querySelector('[data-step-nav]');\n document.documentElement.dataset['guideControls'] = '';\n\n /** @returns {void} Fits the navigation offset and visible copy to the current layout. */\n const fitGuideLayout = () => {\n const toolbar = networkNav?.closest('.toolbar');\n if (toolbar instanceof HTMLElement)\n document.documentElement.style.setProperty(\n '--guide-nav-height',\n `${toolbar.getBoundingClientRect().height}px`,\n );\n for (const field of document.querySelectorAll('textarea[readonly]')) {\n if (!(field instanceof HTMLTextAreaElement) || field.getClientRects().length === 0) continue;\n field.style.height = 'auto';\n field.style.height = `${field.scrollHeight + field.offsetHeight - field.clientHeight}px`;\n }\n };\n\n /**\n * Keeps the persistent shortcuts aligned with the currently open network.\n * @param {string | undefined} channel The open network identifier.\n * @returns {void}\n */\n const updateNavigation = (channel: string | undefined) => {\n if (!(networkNav instanceof HTMLElement) || !(stepNav instanceof HTMLElement)) return;\n for (const link of networkNav.querySelectorAll('a[data-channel]')) {\n if (!(link instanceof HTMLAnchorElement)) continue;\n if (link.dataset['channel'] === channel) {\n link.setAttribute('aria-current', 'location');\n const bounds = link.getBoundingClientRect(),\n container = networkNav.getBoundingClientRect();\n if (bounds.left < container.left || bounds.right > container.right)\n link.scrollIntoView({ block: 'nearest', inline: 'nearest', behavior: 'instant' });\n } else link.removeAttribute('aria-current');\n }\n stepNav.hidden = !channel;\n for (const link of stepNav.querySelectorAll('a[data-step]')) {\n if (link instanceof HTMLAnchorElement && channel)\n link.href = `#${channel}-${link.dataset['step']}`;\n }\n };\n\n /**\n * Opens one network without relying on exclusive-details support in the browser.\n * @param {HTMLDetailsElement} selected The requested network section.\n * @returns {void}\n */\n const openChannel = (selected: HTMLDetailsElement) => {\n for (const channel of channels) {\n channel.hidden = channel !== selected;\n channel.open = channel === selected;\n }\n updateNavigation(selected.id);\n fitGuideLayout();\n };\n\n /**\n * Repositions after changing section heights, including repeat selections.\n * @param {HTMLDetailsElement} selected The requested network section.\n * @returns {void}\n */\n const navigateToStart = (selected: HTMLDetailsElement) => {\n openChannel(selected);\n const heading = document.getElementById(`${selected.id}-start`);\n if (!(heading instanceof HTMLElement)) return;\n location.hash = heading.id;\n heading.focus({ preventScroll: true });\n heading.scrollIntoView({ block: 'start', behavior: 'instant' });\n };\n\n /**\n * Opens a known section for direct links and browser Back/Forward.\n * @param {boolean} [restoreStart] Restore focus for history returning to the initial network.\n * @returns {void}\n */\n const followFragment = (restoreStart = false) => {\n const fragment = location.hash.slice(1);\n const target = document.getElementById(fragment || `${channels[0]?.id}-start`);\n const channel = target?.closest('details.channel');\n if (channel instanceof HTMLDetailsElement && target instanceof HTMLElement) {\n // Native in-panel links already move focus; do not race the user's next Tab.\n const needsFocus = channel.hidden || !channel.open || (!fragment && restoreStart);\n openChannel(channel);\n if (needsFocus) {\n target.focus({ preventScroll: true });\n target.scrollIntoView({ block: 'start', behavior: 'instant' });\n }\n }\n };\n\n for (const link of document.querySelectorAll('a[data-channel]')) {\n if (!(link instanceof HTMLAnchorElement)) continue;\n link.addEventListener('click', (event) => {\n if (\n event instanceof MouseEvent &&\n (event.button !== 0 || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey)\n )\n return;\n const selected = channels.find((channel) => channel.id === link.dataset['channel']);\n if (!selected) return;\n event.preventDefault();\n navigateToStart(selected);\n });\n }\n for (const channel of channels) {\n channel.querySelector('summary')?.addEventListener('click', (event) => {\n if (channel.open) return;\n event.preventDefault();\n navigateToStart(channel);\n });\n channel.addEventListener('toggle', () => {\n if (channel.open) openChannel(channel);\n else updateNavigation(channels.find((node) => node.open)?.id);\n });\n }\n window.addEventListener('hashchange', () => followFragment(true));\n window.addEventListener('resize', fitGuideLayout);\n document.addEventListener('toggle', fitGuideLayout, true);\n followFragment();\n updateNavigation(channels.find((channel) => channel.open)?.id);\n\n for (const button of document.querySelectorAll('[data-copy-target]')) {\n if (!(button instanceof HTMLButtonElement)) continue;\n const field = document.getElementById(button.dataset['copyTarget'] ?? '');\n const status = document.getElementById(button.dataset['copyStatus'] ?? '');\n const block = button.closest('.copy-block');\n if (\n !(field instanceof HTMLTextAreaElement) ||\n !(status instanceof HTMLElement) ||\n !(block instanceof HTMLElement)\n )\n continue;\n\n /** @returns {void} Keeps manual copy available when clipboard access is unavailable. */\n const selectForManualCopy = () => {\n field.focus({ preventScroll: true });\n field.select();\n status.textContent =\n button.dataset['copyFallback'] ?? \"Text selected. Use your device's Copy command.\";\n };\n\n const writeCopy = async (): Promise<void> => {\n if (button.getAttribute('aria-disabled') === 'true') return;\n button.setAttribute('aria-disabled', 'true');\n block.setAttribute('aria-busy', 'true');\n try {\n if (typeof navigator.clipboard?.writeText !== 'function') {\n selectForManualCopy();\n return;\n }\n // Start inside the activation handler, before the first await.\n const writing = navigator.clipboard.writeText(field.value);\n status.textContent = button.dataset['copyPending'] ?? 'Copying...';\n await writing;\n status.textContent = button.dataset['copySuccess'] ?? 'Copied.';\n } catch {\n selectForManualCopy();\n } finally {\n button.removeAttribute('aria-disabled');\n block.removeAttribute('aria-busy');\n }\n };\n button.addEventListener('click', () => {\n void writeCopy();\n });\n button.hidden = false;\n }\n fitGuideLayout();\n};\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IPublishingGuide, IPublishingGuideOptions, IPublishingGuideResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Renders a caller-approved selection into a self-contained HTML guide and a plain-text README.
|
|
4
|
+
* The HTML uses local relative file links and an inline script permitted by its exact CSP hash.
|
|
5
|
+
* @param guide The title, selected files and optional channel steps.
|
|
6
|
+
* @param copy Reviewed literal text keyed by selected local filename.
|
|
7
|
+
* @param options The guide interface locale.
|
|
8
|
+
* @returns The HTML and plain-text documents.
|
|
9
|
+
* @example
|
|
10
|
+
* import { renderPublishingGuide } from 'jg-publishing-guides';
|
|
11
|
+
*
|
|
12
|
+
* const { html, readme } = renderPublishingGuide(
|
|
13
|
+
* {
|
|
14
|
+
* title: 'Reviewed caption',
|
|
15
|
+
* summary: 'Selected copy for manual publication.',
|
|
16
|
+
* files: [{ path: 'caption.txt', label: 'Caption', details: 'Reviewed text.', kind: 'file' }],
|
|
17
|
+
* },
|
|
18
|
+
* new Map([['caption.txt', 'Copy for the published post.']]),
|
|
19
|
+
* );
|
|
20
|
+
* // write html to start-here.html and readme to readme.txt beside caption.txt
|
|
21
|
+
* void [html, readme];
|
|
22
|
+
* @throws
|
|
23
|
+
* - INVALID_PUBLISHING_GUIDE: The publishing guide input is invalid.
|
|
24
|
+
*/
|
|
25
|
+
export declare const renderPublishingGuide: (guide: IPublishingGuide, copy?: ReadonlyMap<string, string>, { locale }?: IPublishingGuideOptions) => IPublishingGuideResult;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { renderGuideHtml, renderGuideReadme } from './presentation.js';
|
|
2
|
+
import { validateGuide } from './validations.js';
|
|
3
|
+
/**
|
|
4
|
+
* Renders a caller-approved selection into a self-contained HTML guide and a plain-text README.
|
|
5
|
+
* The HTML uses local relative file links and an inline script permitted by its exact CSP hash.
|
|
6
|
+
* @param guide The title, selected files and optional channel steps.
|
|
7
|
+
* @param copy Reviewed literal text keyed by selected local filename.
|
|
8
|
+
* @param options The guide interface locale.
|
|
9
|
+
* @returns The HTML and plain-text documents.
|
|
10
|
+
* @example
|
|
11
|
+
* import { renderPublishingGuide } from 'jg-publishing-guides';
|
|
12
|
+
*
|
|
13
|
+
* const { html, readme } = renderPublishingGuide(
|
|
14
|
+
* {
|
|
15
|
+
* title: 'Reviewed caption',
|
|
16
|
+
* summary: 'Selected copy for manual publication.',
|
|
17
|
+
* files: [{ path: 'caption.txt', label: 'Caption', details: 'Reviewed text.', kind: 'file' }],
|
|
18
|
+
* },
|
|
19
|
+
* new Map([['caption.txt', 'Copy for the published post.']]),
|
|
20
|
+
* );
|
|
21
|
+
* // write html to start-here.html and readme to readme.txt beside caption.txt
|
|
22
|
+
* void [html, readme];
|
|
23
|
+
* @throws
|
|
24
|
+
* - INVALID_PUBLISHING_GUIDE: The publishing guide input is invalid.
|
|
25
|
+
*/
|
|
26
|
+
export const renderPublishingGuide = (guide, copy = new Map(), { locale = 'en' } = {}) => {
|
|
27
|
+
validateGuide(guide, copy, locale);
|
|
28
|
+
return {
|
|
29
|
+
html: renderGuideHtml(guide, copy, locale),
|
|
30
|
+
readme: renderGuideReadme(guide, copy, locale),
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=guide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guide.js","sourceRoot":"","sources":["../../src/guide/guide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,KAAuB,EACvB,OAAoC,IAAI,GAAG,EAAE,EAC7C,EAAE,MAAM,GAAG,IAAI,KAA8B,EAAE,EACvB,EAAE;IAC1B,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO;QACL,IAAI,EAAE,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC;QAC1C,MAAM,EAAE,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC;KAC/C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { renderGuideHtml, renderGuideReadme } from './presentation.js';\nimport type { IPublishingGuide, IPublishingGuideOptions, IPublishingGuideResult } from './types.js';\nimport { validateGuide } from './validations.js';\n\n/**\n * Renders a caller-approved selection into a self-contained HTML guide and a plain-text README.\n * The HTML uses local relative file links and an inline script permitted by its exact CSP hash.\n * @param guide The title, selected files and optional channel steps.\n * @param copy Reviewed literal text keyed by selected local filename.\n * @param options The guide interface locale.\n * @returns The HTML and plain-text documents.\n * @example\n * import { renderPublishingGuide } from 'jg-publishing-guides';\n *\n * const { html, readme } = renderPublishingGuide(\n * {\n * title: 'Reviewed caption',\n * summary: 'Selected copy for manual publication.',\n * files: [{ path: 'caption.txt', label: 'Caption', details: 'Reviewed text.', kind: 'file' }],\n * },\n * new Map([['caption.txt', 'Copy for the published post.']]),\n * );\n * // write html to start-here.html and readme to readme.txt beside caption.txt\n * void [html, readme];\n * @throws\n * - INVALID_PUBLISHING_GUIDE: The publishing guide input is invalid.\n */\nexport const renderPublishingGuide = (\n guide: IPublishingGuide,\n copy: ReadonlyMap<string, string> = new Map(),\n { locale = 'en' }: IPublishingGuideOptions = {},\n): IPublishingGuideResult => {\n validateGuide(guide, copy, locale);\n return {\n html: renderGuideHtml(guide, copy, locale),\n readme: renderGuideReadme(guide, copy, locale),\n };\n};\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { IPublishingChannel, IPublishingGuide, IPublishingGuideFile, IPublishingGuideLocale, IPublishingGuideOptions, IPublishingGuideResult, IPublishingGuideStep, } from './types.js';
|
|
2
|
+
export { ERRORS } from './validations.js';
|
|
3
|
+
export { renderPublishingGuide } from './guide.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/guide/index.ts"],"names":[],"mappings":"AAWA,SAAS;AACT,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,mBAAmB;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC","sourcesContent":["// types\nexport type {\n IPublishingChannel,\n IPublishingGuide,\n IPublishingGuideFile,\n IPublishingGuideLocale,\n IPublishingGuideOptions,\n IPublishingGuideResult,\n IPublishingGuideStep,\n} from './types.js';\n\n// errors\nexport { ERRORS } from './validations.js';\n\n// publishing guide\nexport { renderPublishingGuide } from './guide.js';\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IPublishingGuide, IPublishingGuideLocale } from './types.js';
|
|
2
|
+
/** Renders the responsive offline page from the validated guide. */
|
|
3
|
+
export declare const renderGuideHtml: (manifest: IPublishingGuide, copy: ReadonlyMap<string, string>, locale: IPublishingGuideLocale) => string;
|
|
4
|
+
/** Renders the matching plain-text guide. */
|
|
5
|
+
export declare const renderGuideReadme: (manifest: IPublishingGuide, copy: ReadonlyMap<string, string>, locale: IPublishingGuideLocale) => string;
|