@canopycanopycanopy/b-ber-grammar-gallery 3.0.8-nav-memo.2 → 3.0.8-next.100
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 +15 -4
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -67
- package/package.json +16 -17
package/README.md
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# b-ber-grammar-gallery
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Handles the `gallery` / `exit` block directive pair. A `gallery` opening marker wraps its content in a build-target-aware container: for `reader` and `web` builds it emits a fullscreen gallery scaffold (`<section>` > `<div class="figure__gallery">` > `<figure>` > `<div class="figure__items">`); for EPUB, Mobi, PDF, and sample builds it emits a plain `<section>` that may be initialized as a slider by JavaScript if available. The exit marker (handled by `b-ber-grammar-section`) closes the open elements. Uses `b-ber-parser-gallery` as the MarkdownIt plugin and delegates open/close validation to `b-ber-grammar-renderer`.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Usage
|
|
6
6
|
|
|
7
|
+
Registered as a MarkdownIt plugin by the rendering engine:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import gallery from '@canopycanopycanopy/b-ber-grammar-gallery'
|
|
11
|
+
// { plugin, name: 'gallery', renderer }
|
|
7
12
|
```
|
|
8
|
-
|
|
13
|
+
|
|
14
|
+
## Dev
|
|
15
|
+
|
|
9
16
|
```
|
|
17
|
+
npm test
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Tests are in `__tests__/index.test.js`.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/index.d.ts
|
|
2
|
+
declare const _default: {
|
|
3
|
+
plugin: (md: any, name: string, options?: any) => void;
|
|
4
|
+
name: string;
|
|
5
|
+
renderer: (args: any) => {
|
|
6
|
+
render: any;
|
|
7
|
+
marker: string;
|
|
8
|
+
minMarkers: number;
|
|
9
|
+
markerOpen: any;
|
|
10
|
+
markerClose: any;
|
|
11
|
+
validateOpen(params: any, line: any): boolean | undefined;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export = _default;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -1,74 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
let _canopycanopycanopy_b_ber_grammar_attributes = require("@canopycanopycanopy/b-ber-grammar-attributes");
|
|
24
|
+
let _canopycanopycanopy_b_ber_grammar_renderer = require("@canopycanopycanopy/b-ber-grammar-renderer");
|
|
25
|
+
_canopycanopycanopy_b_ber_grammar_renderer = __toESM(_canopycanopycanopy_b_ber_grammar_renderer);
|
|
26
|
+
let _canopycanopycanopy_b_ber_lib = require("@canopycanopycanopy/b-ber-lib");
|
|
27
|
+
let _canopycanopycanopy_b_ber_parser_gallery = require("@canopycanopycanopy/b-ber-parser-gallery");
|
|
28
|
+
_canopycanopycanopy_b_ber_parser_gallery = __toESM(_canopycanopycanopy_b_ber_parser_gallery);
|
|
29
|
+
//#region src/index.ts
|
|
26
30
|
const MARKER_OPEN_RE = /^(gallery)(?::([^\s]+)(\s.*)?)?$/;
|
|
27
31
|
const MARKER_CLOSE_RE = /^(exit)(?::([^\s]+))?/;
|
|
28
|
-
|
|
29
|
-
// a simple `render` function that gets passed into our `createRenderer` is
|
|
30
|
-
// responsible for the HTML output.
|
|
31
32
|
const render = (tokens, idx) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// web: drop all assets (images, videos, etc) into a `fullscreen`
|
|
42
|
-
// container so that they can be positioned using custom CSS
|
|
43
|
-
|
|
44
|
-
// epub, mobi: drop all assets into a section.gallery container
|
|
45
|
-
// that is initialized as a slider via JS if available.
|
|
46
|
-
// defaults to a simple sequence of images
|
|
47
|
-
|
|
48
|
-
// pdf: sequence of images
|
|
49
|
-
|
|
50
|
-
switch (_State.default.build) {
|
|
51
|
-
case 'web':
|
|
52
|
-
case 'reader':
|
|
53
|
-
return `
|
|
54
|
-
<section id="${(0, _bBerGrammarAttributes.htmlId)(id)}" ${attrsString}>
|
|
33
|
+
const token = tokens[idx].info.trim().match(MARKER_OPEN_RE);
|
|
34
|
+
if (tokens[idx].nesting !== 1 || !token) return "";
|
|
35
|
+
const [, type, id, attrs] = token;
|
|
36
|
+
const attrsString = (0, _canopycanopycanopy_b_ber_grammar_attributes.attributesString)((0, _canopycanopycanopy_b_ber_grammar_attributes.attributesObject)(attrs, type));
|
|
37
|
+
switch (_canopycanopycanopy_b_ber_lib.State.build) {
|
|
38
|
+
case "web":
|
|
39
|
+
case "reader": return `
|
|
40
|
+
<section id="${(0, _canopycanopycanopy_b_ber_grammar_attributes.htmlId)(id)}" ${attrsString}>
|
|
55
41
|
<div class="figure__large figure__inline figure__fullbleed figure__gallery">
|
|
56
42
|
<figure>
|
|
57
43
|
<div class="figure__items">`;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
44
|
+
default: return `<section id="${(0, _canopycanopycanopy_b_ber_grammar_attributes.htmlId)(id)}" ${attrsString}>`;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var src_default = {
|
|
48
|
+
plugin: _canopycanopycanopy_b_ber_parser_gallery.default,
|
|
49
|
+
name: "gallery",
|
|
50
|
+
renderer: (args) => (0, _canopycanopycanopy_b_ber_grammar_renderer.default)({
|
|
51
|
+
...args,
|
|
52
|
+
markerOpen: MARKER_OPEN_RE,
|
|
53
|
+
markerClose: MARKER_CLOSE_RE,
|
|
54
|
+
render
|
|
55
|
+
})
|
|
65
56
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
name: 'gallery',
|
|
69
|
-
renderer: args => (0, _bBerGrammarRenderer.default)(_objectSpread(_objectSpread({}, args), {}, {
|
|
70
|
-
markerOpen: MARKER_OPEN_RE,
|
|
71
|
-
markerClose: MARKER_CLOSE_RE,
|
|
72
|
-
render
|
|
73
|
-
}))
|
|
74
|
-
};
|
|
57
|
+
//#endregion
|
|
58
|
+
module.exports = src_default;
|
package/package.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canopycanopycanopy/b-ber-grammar-gallery",
|
|
3
|
-
"version": "3.0.8-
|
|
3
|
+
"version": "3.0.8-next.100+20b74691",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"prepare": "npm run clean && npm run prepare:dist",
|
|
10
|
-
"build": "npm run prepare",
|
|
11
|
-
"watch": "BABEL_ENV=production babel --config-file ../../babel.config.js -d dist/ src/ --watch src",
|
|
7
|
+
"build": "tsdown",
|
|
8
|
+
"typecheck": "tsc --noEmit",
|
|
12
9
|
"test": "jest"
|
|
13
10
|
},
|
|
14
11
|
"author": "Triple Canopy <b-ber@canopycanopycanopy.com> (https://triplecanopy.github.io/)",
|
|
@@ -17,18 +14,19 @@
|
|
|
17
14
|
"access": "public"
|
|
18
15
|
},
|
|
19
16
|
"devDependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
17
|
+
"@swc/core": "^1.15.40",
|
|
18
|
+
"@swc/jest": "^0.2.39",
|
|
19
|
+
"jest": "^29.7.0",
|
|
20
|
+
"rimraf": "^2.7.1",
|
|
21
|
+
"tsdown": "^0.22.1",
|
|
22
|
+
"typescript": "^6.0.3"
|
|
26
23
|
},
|
|
27
24
|
"dependencies": {
|
|
28
|
-
"@canopycanopycanopy/b-ber-grammar-attributes": "3.0.8-
|
|
29
|
-
"@canopycanopycanopy/b-ber-grammar-renderer": "3.0.8-
|
|
30
|
-
"@canopycanopycanopy/b-ber-lib": "3.0.8-
|
|
31
|
-
"@canopycanopycanopy/b-ber-
|
|
25
|
+
"@canopycanopycanopy/b-ber-grammar-attributes": "3.0.8-next.100+20b74691",
|
|
26
|
+
"@canopycanopycanopy/b-ber-grammar-renderer": "3.0.8-next.100+20b74691",
|
|
27
|
+
"@canopycanopycanopy/b-ber-lib": "3.0.8-next.100+20b74691",
|
|
28
|
+
"@canopycanopycanopy/b-ber-logger": "3.0.8-next.100+20b74691",
|
|
29
|
+
"@canopycanopycanopy/b-ber-parser-gallery": "3.0.8-next.100+20b74691",
|
|
32
30
|
"lodash": "^4.17.21",
|
|
33
31
|
"tar": "^6.1.11"
|
|
34
32
|
},
|
|
@@ -49,5 +47,6 @@
|
|
|
49
47
|
"url": "https://maxwellsimmer.com"
|
|
50
48
|
}
|
|
51
49
|
],
|
|
52
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "20b746918e81513be00a2f04971b00b296850f61",
|
|
51
|
+
"types": "dist/index.d.ts"
|
|
53
52
|
}
|