Skip to content

Commit b4a97e3

Browse files
committed
EN,CZ : pExport plugin description
1 parent 244c0c3 commit b4a97e3

File tree

8 files changed

+178
-0
lines changed

8 files changed

+178
-0
lines changed

cs/files.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ pServicePlugin.md|pServicePlugin
4545
milestones.md|Milníky
4646
puiButtonSelect.md|puiButtonSelect
4747
custPackage.md|Vlastní balíček
48+
pExport.md|pExport

cs/firstPlugin.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Plugins.catalogize(pMinPlugin);
7979
| Název | Popis |
8080
|---|---|
8181
| 🖼️ [pTRPhasePlugin][pTRPhasePlugin] | Plugin přijímá událost ⚡ [ShowChapterResolutions][ShowChapterResolutions] od pluginu 🖼️ [pTopicRenderer][pTopicRenderer] a provede jednotlivý krok procesního zpracování. Jednou z jeho aplikací je například parsování md souboru pro výpis do textu kapitoly. |
82+
| 🖼️ [pExport][pExport] | Plugin přijímá událost ⚡ [PrepareExport][PrepareExport] od pluginu 🖥️ [puiButtonExport][puiButtonExport] a provede export textu kapitoly do formátu podle implementace pluginu - potomka. |
8283

8384
## Příklady implementací
8485

@@ -88,7 +89,9 @@ Plugins.catalogize(pMinPlugin);
8889
[IPlugin]: :_plg:IPlugin.md "IPlugin"
8990
[pConvertSysEventToEvent]: pConvertSysEventToEvent.md "pConvertSysEventToEvent"
9091
[pTRPhasePlugin]: pTRPhasePlugin.md "pTRPhasePlugin"
92+
[pExport]: pExport.md "pExport"
9193
[ShowChapterResolutions]: :_evt:ShowChapterResolutions.md "ShowChapterResolutions"
94+
[PrepareExport]: :_evt:PrepareExport.md "PrepareExport"
9295
[pTopicRenderer]: pTopicRenderer.md "pTopicRenderer"
9396
[puiButton]: puiButton.md "puiButton"
9497
[puiButtonTab]:puiButtonTab.md "puiButtonTab"
@@ -97,3 +100,4 @@ Plugins.catalogize(pMinPlugin);
97100
[plugins]: plugins.lst.md "Seznam pluginů"
98101
[pServicePlugin]: pServicePlugin.md "pServicePlugin"
99102
[pPluginManagement]: :_plg:pPluginManagement.md "pPluginManagement"
103+
[puiButtonExport]: :_plg:puiButtonExport.md "puiButtonExport"

cs/pExport.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# 🖼️ pExport
2+
3+
## Účel pluginu
4+
5+
Tento plugin definuje základní rozhraní pro export zobrazeného textu kapitoly.
6+
7+
Odvozený plugin je obvykle zapouzdřením mezi:
8+
9+
- **HelpViewer** (🖥️ [puiButtonExport][puiButtonExport]) a
10+
- převodníkem z **HTML** na požadovaný formát, který je obvykle řešen externím skriptem.
11+
12+
Načtení převodníku v případě potřeby zajistí plugin 📦 [Zdroj][resource].
13+
14+
## Implementace
15+
16+
1. Nový plugin vždy bude mít 🖼️ [pExport][pExport] jako svou bázovou třídu.
17+
2. Implementace bude vypadat přibližně takto:
18+
19+
```javascript
20+
class pExportNEW extends pExport {
21+
constructor(aliasName, data) {
22+
super(aliasName, data);
23+
24+
this.RES_HTMLTONEW = new Resource('HTMLTONEW', undefined, STO_DATA, 'HTMLToNEW/HTMLToNEW.js;HTMLToNEW/LICENSE;HTMLToNEW/README.md');
25+
}
26+
27+
async onETPrepareExport(evt) {
28+
let promise = Promise.resolve(true);
29+
30+
if (typeof HTMLTONEW !== 'function')
31+
promise = this.RES_HTMLTONEW?.init(promise);
32+
33+
promise = promise.then(async() => {
34+
const ctx = { listStack: [], i_img: 0, i_svg: 0, embeds: evt.embeds };
35+
const converted = HTMLTONEW(evt.parent, ctx);
36+
evt.output.file('output.txt', converted);
37+
38+
if (evt.doneHandler)
39+
evt.doneHandler();
40+
41+
});
42+
}
43+
}
44+
45+
Plugins.catalogize(pExportNEW);
46+
```
47+
48+
3. Nový plugin musí být zaveden do 📄 [seznamu pluginů][pluginslst] :
49+
50+
```
51+
pExportNEW:NEW
52+
```
53+
54+
v pořadí, které je v seznamu níže než **pExport**.
55+
56+
ID za dvojtečkou (zde NEW) se nabídne ve výběrovém seznamu tlačítka 📥 Export.
57+
58+
## Popis funkčnosti
59+
60+
- Uživatel klikne na tlačítko 📥 Export
61+
- Obsluha tlačítka založí ZIP archiv a shromáždí do něj obrázky a další vnořené prvky, které v textu najde a pošle data jako odkaz na plochu pro text kapitoly nebo handler **doneHandler**, který zajistí vystavení ZIP souboru pro uživatele
62+
- Obsluha tlačítka odešle událost ⚡ [PrepareExport][PrepareExport]
63+
- Odvozený plugin (**pExportNEW**) definuje obsluhu 👂 **onETPrepareExport**, která převezme připravený mezivýsledek
64+
- Obsluha exportu (může být asynchronní) pracuje především s:
65+
- **evt.embeds** - vnořené prvky, obrázky, SVG
66+
- **evt.parent** - nadřízený HTML objekt (zobrazovací plocha pro text kapitoly)
67+
- Obsluha exportu provolá funkci převodníku, které předá potřebný objekt kontextu s prázdnými nebo výchozími hodnotami, odkaz na HTML objekt, který obsahuje úplný vstup, případně další vstup podle implementace
68+
- Obsluha exportu převezme výsledek převodu a provolá **evt.output.file('name.txt', result);**, pro zápis do ZIP výstupu
69+
- Obsluha exportu nakonec provolá **evt.doneHandler();**. Tímto vydá ZIP soubor uživateli do prohlížeče pro standardní stažení
70+
71+
## Příklady implementací
72+
73+
- 🖼️ [pExportHTM][pExportHTM] a další potomci třídy 🖼️ [pExport][pExport], kteří svým jménem začínají na **pExport**.
74+
- Převodníky: [HTMLToTeX][HTMLToTeX], [HTMLToMD][HTMLToMD]
75+
76+
[puiButtonExport]: :_plg:puiButtonExport.md "puiButtonExport"
77+
[pExportHTM]: :_plg:pExportHTM.md "pExportHTM"
78+
[PrepareExport]: :_evt:PrepareExport.md "PrepareExport"
79+
[pExport]: :_plg:pExport.md "pExport"
80+
[resource]: resource.md "Zdroj"
81+
[pluginslst]: plugins.lst.md "Seznam pluginů (plugins.lst)"
82+
[HTMLToTeX]: https://github.com/HelpViewer/HTMLToTeX "HTML -> TeX"
83+
[HTMLToMD]: https://github.com/HelpViewer/HTMLToMD "HTML -> md"

cs/tree.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Implementace pluginů|Implementace pluginů||implPlug.md
2222
🔌 pConvertSysEventToEvent|pConvertSysEventToEvent||pConvertSysEventToEvent.md
2323
🖼️ pTRPhasePlugin|pTRPhasePlugin||pTRPhasePlugin.md
2424
🖼️ pTopicRenderer|pTopicRenderer||pTopicRenderer.md
25+
🖼️ pExport|pExport||pExport.md
2526
🔌 pServicePlugin|pServicePlugin||pServicePlugin.md
2627
Definice objektů|Definice objektů||objDef.md
2728
⚙️ Konfigurační volba|Konfigurační volba||cfgopt.md

en/files.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ pServicePlugin.md|pServicePlugin
4545
milestones.md|Milestones
4646
puiButtonSelect.md|puiButtonSelect
4747
custPackage.md|Custom package
48+
pExport.md|pExport

en/firstPlugin.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Plugins.catalogize(pMinPlugin);
7979
| Name | Description |
8080
|---|---|
8181
| 🖼️ [pTRPhasePlugin][pTRPhasePlugin] | The plugin receives the ⚡ [ShowChapterResolutions][ShowChapterResolutions] event from the 🖼️ [pTopicRenderer][pTopicRenderer] plugin and performs a single step of process handling. One of its applications is, for example, parsing an md file for listing into chapter text. |
82+
| 🖼️ [pExport][pExport] | The plugin receives the event ⚡ [PrepareExport][PrepareExport] from the plugin 🖥️ [puiButtonExport][puiButtonExport] and exports the chapter text to the format according to the implementation of the plugin - descendant. |
8283

8384
## Implementation examples
8485

@@ -88,7 +89,9 @@ Plugins.catalogize(pMinPlugin);
8889
[IPlugin]: :_plg:IPlugin.md "IPlugin"
8990
[pConvertSysEventToEvent]: pConvertSysEventToEvent.md "pConvertSysEventToEvent"
9091
[pTRPhasePlugin]: pTRPhasePlugin.md "pTRPhasePlugin"
92+
[pExport]: pExport.md "pExport"
9193
[ShowChapterResolutions]: :_evt:ShowChapterResolutions.md "ShowChapterResolutions"
94+
[PrepareExport]: :_evt:PrepareExport.md "PrepareExport"
9295
[pTopicRenderer]: pTopicRenderer.md "pTopicRenderer"
9396
[puiButton]: puiButton.md "puiButton"
9497
[puiButtonTab]:puiButtonTab.md "puiButtonTab"
@@ -97,3 +100,4 @@ Plugins.catalogize(pMinPlugin);
97100
[plugins]: plugins.lst.md "List of plugins"
98101
[pServicePlugin]: pServicePlugin.md "pServicePlugin"
99102
[pPluginManagement]: :_plg:pPluginManagement.md "pPluginManagement"
103+
[puiButtonExport]: :_plg:puiButtonExport.md "puiButtonExport"

en/pExport.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# 🖼️ pExport
2+
3+
## Purpose of the plugin
4+
5+
This plugin defines the basic interface for exporting the displayed text of a chapter.
6+
7+
The derived plugin is usually encapsulated logic between:
8+
9+
- **HelpViewer** (🖥️ [puiButtonExport][puiButtonExport]) and
10+
- a converter from **HTML** to the desired format, which is usually handled by an external script.
11+
12+
If necessary, the plugin 📦 [Resource][resource] will load the converter.
13+
14+
## Implementation
15+
16+
1. A new plugin will always have 🖼️ [pExport][pExport] as its base class.
17+
2. The implementation will look something like this:
18+
19+
```javascript
20+
class pExportNEW extends pExport {
21+
constructor(aliasName, data) {
22+
super(aliasName, data);
23+
24+
this.RES_HTMLTONEW = new Resource('HTMLTONEW', undefined, STO_DATA, 'HTMLToNEW/HTMLToNEW.js;HTMLToNEW/LICENSE;HTMLToNEW/README.md');
25+
}
26+
27+
async onETPrepareExport(evt) {
28+
let promise = Promise.resolve(true);
29+
30+
if (typeof HTMLTONEW !== 'function')
31+
promise = this.RES_HTMLTONEW?.init(promise);
32+
33+
promise = promise.then(async() => {
34+
const ctx = { listStack: [], i_img: 0, i_svg: 0, embeds: evt.embeds };
35+
const converted = HTMLTONEW(evt.parent, ctx);
36+
evt.output.file('output.txt', converted);
37+
38+
if (evt.doneHandler)
39+
evt.doneHandler();
40+
41+
});
42+
}
43+
}
44+
45+
Plugins.catalogize(pExportNEW);
46+
```
47+
48+
3. The new plugin must be added to the 📄 [list of plugins][pluginslst]:
49+
50+
```
51+
pExportNEW:NEW
52+
```
53+
54+
in an order that is lower than **pExport** in the list.
55+
56+
The ID after the colon (here NEW) will be offered in the drop-down list of the 📥 Export button.
57+
58+
## Functionality description
59+
60+
- The user clicks on the 📥 Export button
61+
- The button handler creates a ZIP archive and collects images and other nested elements found in the text into it and sends the data as a link to the chapter text or handler **doneHandler**, which ensures that the ZIP file is displayed to the user
62+
- The button handler sends the event ⚡ [PrepareExport][PrepareExport]
63+
- The derived plugin (**pExportNEW**) defines the handler 👂 **onETPrepareExport**, which takes over the prepared intermediate result
64+
- The export handler (which may be asynchronous) works primarily with:
65+
- **evt.embeds** - embedded elements, images, SVG
66+
- **evt.parent** - parent HTML object (display area for chapter text)
67+
- The export handler calls the converter function, which passes the necessary context object with empty or default values, a reference to the HTML object containing the complete input, or additional input depending on the implementation
68+
- The export handler takes the conversion result and calls **evt.output.file('name.txt', result);** to write to the ZIP output
69+
- Finally, the export handler calls **evt.doneHandler();**. This releases the ZIP file to the user's browser for standard download
70+
71+
## Implementation examples
72+
73+
- 🖼️ [pExportHTM][pExportHTM] and other descendants of the class 🖼️ [pExport][pExport] whose names begin with **pExport**.
74+
- Converters: [HTMLToTeX][HTMLToTeX], [HTMLToMD][HTMLToMD]
75+
76+
[puiButtonExport]: :_plg:puiButtonExport.md "puiButtonExport"
77+
[pExportHTM]: :_plg:pExportHTM.md "pExportHTM"
78+
[PrepareExport]: :_evt:PrepareExport.md "PrepareExport"
79+
[pExport]: :_plg:pExport.md "pExport"
80+
[resource]: resource.md "Resource"
81+
[pluginslst]: plugins.lst.md "List of plugins (plugins.lst)"
82+
[HTMLToTeX]: https://github.com/HelpViewer/HTMLToTeX "HTML -> TeX"
83+
[HTMLToMD]: https://github.com/HelpViewer/HTMLToMD "HTML -> md"

en/tree.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Plugin implementation|Plugin implementation||implPlug.md
2222
🔌 pConvertSysEventToEvent|pConvertSysEventToEvent||pConvertSysEventToEvent.md
2323
🖼️ pTRPhasePlugin|pTRPhasePlugin||pTRPhasePlugin.md
2424
🖼️ pTopicRenderer|pTopicRenderer||pTopicRenderer.md
25+
🖼️ pExport|pExport||pExport.md
2526
🔌 pServicePlugin|pServicePlugin||pServicePlugin.md
2627
Object definitions|Object definitions||objDef.md
2728
⚙️ Configuration option|Configuration option||cfgopt.md

0 commit comments

Comments
 (0)