@shower/core 3.2.0 → 3.3.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/lib/slide.js CHANGED
@@ -1,99 +1,99 @@
1
- import { defineReadOnly, ShowerError } from './utils';
1
+ import { defineReadOnly, ShowerError } from './utils.js';
2
2
 
3
3
  class Slide extends EventTarget {
4
- /**
5
- * @param {Shower} shower
6
- * @param {HTMLElement} element
7
- */
8
- constructor(shower, element) {
9
- super();
10
-
11
- defineReadOnly(this, {
12
- shower,
13
- element,
14
- state: {
15
- visitCount: 0,
16
- innerStepCount: 0,
17
- },
18
- });
19
-
20
- this._isActive = false;
21
- this._options = this.shower.options;
22
-
23
- this.element.addEventListener('click', (event) => {
24
- if (event.defaultPrevented) return;
25
-
26
- this.activate();
27
- this.shower.enterFullMode();
28
- });
29
- }
30
-
31
- get isActive() {
32
- return this._isActive;
33
- }
34
-
35
- get isVisited() {
36
- return this.state.visitCount > 0;
37
- }
38
-
39
- get id() {
40
- return this.element.id;
41
- }
42
-
43
- get title() {
44
- const titleElement = this.element.querySelector(this._options.slideTitleSelector);
45
- return titleElement ? titleElement.innerText : '';
46
- }
47
-
48
- /**
49
- * Deactivates currently active slide (if any) and activates itself.
50
- * @emits Slide#deactivate
51
- * @emits Slide#activate
52
- * @emits Shower#slidechange
53
- */
54
- activate() {
55
- if (this._isActive) return;
56
-
57
- const prev = this.shower.activeSlide;
58
- if (prev) {
59
- prev._deactivate();
60
- }
61
-
62
- this.state.visitCount++;
63
- this.element.classList.add(this._options.activeSlideClass);
64
-
65
- this._isActive = true;
66
- this.dispatchEvent(new Event('activate'));
67
- this.shower.dispatchEvent(
68
- new CustomEvent('slidechange', {
69
- detail: { prev },
70
- }),
71
- );
72
- }
73
-
74
- /**
75
- * @throws {ShowerError}
76
- * @emits Slide#deactivate
77
- */
78
- deactivate() {
79
- if (this.shower.isFullMode) {
80
- throw new ShowerError('In full mode, another slide should be activated instead.');
81
- }
82
-
83
- if (this._isActive) {
84
- this._deactivate();
85
- }
86
- }
87
-
88
- _deactivate() {
89
- this.element.classList.replace(
90
- this._options.activeSlideClass,
91
- this._options.visitedSlideClass,
92
- );
93
-
94
- this._isActive = false;
95
- this.dispatchEvent(new Event('deactivate'));
96
- }
4
+ /**
5
+ * @param {Shower} shower
6
+ * @param {HTMLElement} element
7
+ */
8
+ constructor(shower, element) {
9
+ super();
10
+
11
+ defineReadOnly(this, {
12
+ shower,
13
+ element,
14
+ state: {
15
+ visitCount: 0,
16
+ innerStepCount: 0,
17
+ },
18
+ });
19
+
20
+ this._isActive = false;
21
+ this._options = this.shower.options;
22
+
23
+ this.element.addEventListener('click', (event) => {
24
+ if (event.defaultPrevented) return;
25
+
26
+ this.activate();
27
+ this.shower.enterFullMode();
28
+ });
29
+ }
30
+
31
+ get isActive() {
32
+ return this._isActive;
33
+ }
34
+
35
+ get isVisited() {
36
+ return this.state.visitCount > 0;
37
+ }
38
+
39
+ get id() {
40
+ return this.element.id;
41
+ }
42
+
43
+ get title() {
44
+ const titleElement = this.element.querySelector(this._options.slideTitleSelector);
45
+ return titleElement ? titleElement.innerText : '';
46
+ }
47
+
48
+ /**
49
+ * Deactivates currently active slide (if any) and activates itself.
50
+ * @emits Slide#deactivate
51
+ * @emits Slide#activate
52
+ * @emits Shower#slidechange
53
+ */
54
+ activate() {
55
+ if (this._isActive) return;
56
+
57
+ const prev = this.shower.activeSlide;
58
+ if (prev) {
59
+ prev._deactivate();
60
+ }
61
+
62
+ this.state.visitCount++;
63
+ this.element.classList.add(this._options.activeSlideClass);
64
+
65
+ this._isActive = true;
66
+ this.dispatchEvent(new Event('activate'));
67
+ this.shower.dispatchEvent(
68
+ new CustomEvent('slidechange', {
69
+ detail: { prev },
70
+ }),
71
+ );
72
+ }
73
+
74
+ /**
75
+ * @throws {ShowerError}
76
+ * @emits Slide#deactivate
77
+ */
78
+ deactivate() {
79
+ if (this.shower.isFullMode) {
80
+ throw new ShowerError('In full mode, another slide should be activated instead.');
81
+ }
82
+
83
+ if (this._isActive) {
84
+ this._deactivate();
85
+ }
86
+ }
87
+
88
+ _deactivate() {
89
+ this.element.classList.replace(
90
+ this._options.activeSlideClass,
91
+ this._options.visitedSlideClass,
92
+ );
93
+
94
+ this._isActive = false;
95
+ this.dispatchEvent(new Event('deactivate'));
96
+ }
97
97
  }
98
98
 
99
99
  export default Slide;
package/lib/utils.js CHANGED
@@ -1,22 +1,22 @@
1
- export const isInteractiveElement = (element) => element.tabIndex !== -1;
1
+ export const isInteractiveElement = (element) => element.tabIndex !== -1 || element.isContentEditable;
2
2
 
3
3
  export const contentLoaded = (callback) => {
4
- if (document.currentScript.async) {
5
- callback();
6
- } else {
7
- document.addEventListener('DOMContentLoaded', callback);
8
- }
4
+ if (document.currentScript.async) {
5
+ callback();
6
+ } else {
7
+ document.addEventListener('DOMContentLoaded', callback);
8
+ }
9
9
  };
10
10
 
11
11
  export const defineReadOnly = (target, props) => {
12
- for (const [key, value] of Object.entries(props)) {
13
- Object.defineProperty(target, key, {
14
- value,
15
- writable: false,
16
- enumerable: true,
17
- configurable: true,
18
- });
19
- }
12
+ for (const [key, value] of Object.entries(props)) {
13
+ Object.defineProperty(target, key, {
14
+ value,
15
+ writable: false,
16
+ enumerable: true,
17
+ configurable: true,
18
+ });
19
+ }
20
20
  };
21
21
 
22
22
  export class ShowerError extends Error {}
package/package.json CHANGED
@@ -1,63 +1,40 @@
1
1
  {
2
- "name": "@shower/core",
3
- "description": "Core for Shower HTML presentation engine",
4
- "version": "3.2.0",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
- "author": {
9
- "name": "Vadim Makeev",
10
- "email": "pepelsbey@gmail.com",
11
- "url": "https://pepelsbey.net"
12
- },
13
- "homepage": "https://github.com/shower/core",
14
- "repository": "shower/core",
15
- "bugs": "https://github.com/shower/shower/issues",
16
- "license": "MIT",
17
- "keywords": [
18
- "shower",
19
- "presentation",
20
- "core"
21
- ],
22
- "main": "lib/shower.js",
23
- "files": [
24
- "lib",
25
- "dist/shower.js"
26
- ],
27
- "devDependencies": {
28
- "chai": "^4.3.4",
29
- "chromedriver": "^83.0.1",
30
- "eslint": "^7.29.0",
31
- "eslint-config-airbnb-base": "^14.2.1",
32
- "eslint-config-prettier": "^6.15.0",
33
- "eslint-plugin-import": "^2.23.4",
34
- "eslint-plugin-prettier": "^3.4.0",
35
- "husky": "^4.3.8",
36
- "lint-staged": "^10.5.4",
37
- "mocha": "^7.2.0",
38
- "nightwatch": "^1.7.6",
39
- "prettier": "^2.3.1",
40
- "puppeteer": "^3.3.0",
41
- "rollup": "^2.52.2",
42
- "sauce-connect-launcher": "^1.3.2",
43
- "serve": "^11.3.2",
44
- "serve-handler": "^6.1.3"
45
- },
46
- "scripts": {
47
- "build": "rollup --config",
48
- "build:watch": "rollup --config --watch",
49
- "serve": "serve dist",
50
- "lint": "eslint '**/*.{js,mjs}'",
51
- "lint:fix": "eslint '**/*.{js,mjs}' --fix",
52
- "format": "npm run format:js && npm run format:etc",
53
- "format:js": "prettier '**/*.{js,mjs}' --write",
54
- "format:etc": "prettier '**/*.{json,md,yml}' --write",
55
- "test": "npm run lint && npm run test:unit && npm run test:local",
56
- "test:unit": "mocha test/unit --require chai/register-should",
57
- "test:local": "nightwatch --env chrome-local --timeout 500",
58
- "test:sauce": "nightwatch --env chrome,firefox,safari"
59
- },
60
- "config": {
61
- "test_port": 8031
62
- }
2
+ "type": "module",
3
+ "name": "@shower/core",
4
+ "description": "Core for Shower HTML presentation engine",
5
+ "version": "3.3.1",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "author": {
10
+ "name": "Vadim Makeev",
11
+ "email": "hi@pepelsbey.dev",
12
+ "url": "https://pepelsbey.dev"
13
+ },
14
+ "homepage": "https://github.com/shower/shower/tree/main/packages/core",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git://github.com/shower/shower.git",
18
+ "directory": "packages/core"
19
+ },
20
+ "bugs": "https://github.com/shower/shower/issues",
21
+ "license": "MIT",
22
+ "keywords": [
23
+ "shower",
24
+ "presentation",
25
+ "core"
26
+ ],
27
+ "main": "lib/index.js",
28
+ "files": [
29
+ "lib",
30
+ "dist/index.js",
31
+ "LICENSE.md",
32
+ "README.md"
33
+ ],
34
+ "scripts": {
35
+ "build": "rollup --config",
36
+ "build:watch": "rollup --config --watch",
37
+ "test": "npm run test:e2e",
38
+ "test:e2e": "playwright test"
39
+ }
63
40
  }
package/CHANGELOG.md DELETED
@@ -1,13 +0,0 @@
1
- # 3.0.0 (Unreleased)
2
-
3
- - Fix `data-timing` interop with inner navigation
4
- - Add new duration format for `data-timing`
5
- - Fix triggering inner navigation on `prev` when in list mode
6
- - Prevent `#` from being appended to URL in `list` mode in Firefox
7
- - `next` plugin now uses `slide_active_classname` option for classes of active items
8
-
9
- # 2.1.0 (Feb 1, 2017)
10
-
11
- - Allow asynchronous loading of Shower ([#118](https://github.com/shower/core/pull/118))
12
- - Add `N` and `P` hotkeys for next/prev slides ([a1567ac](https://github.com/shower/core/commit/a1567acfd14959222c277bdd7702305d183dc60c))
13
- - Require `Shift` for `Shift+F5` shortcut ([6f911ed](https://github.com/shower/core/commit/6f911ededc2b6d7de4bcf6b95808ff8f067d54c1))