@pushword/js-helper 0.0.56 → 0.0.60

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushword/js-helper",
3
- "version": "0.0.56",
3
+ "version": "0.0.60",
4
4
  "description": "Pushword front end helpers. ",
5
5
  "author": "Robin@PiedWeb <contact@piedweb.com>",
6
6
  "license": "MIT",
package/src/app.css ADDED
@@ -0,0 +1,4 @@
1
+ @import "tailwindcss/base";
2
+ @import "tailwindcss/components";
3
+ @import "tailwindcss/utilities";
4
+ @import "@pushword/js-helper/src/tailwind.prose.scss";
package/src/app.js ADDED
@@ -0,0 +1,27 @@
1
+ require("fslightbox");
2
+ import {
3
+ uncloakLinks,
4
+ readableEmail,
5
+ convertImageLinkToWebPLink,
6
+ replaceOn,
7
+ liveBlock,
8
+ } from "@pushword/js-helper/src/helpers.js";
9
+ import { allClickable } from "@pushword/js-helper/src/clickable.js";
10
+
11
+ function onDomChanged() {
12
+ liveBlock();
13
+ convertImageLinkToWebPLink();
14
+ uncloakLinks();
15
+ readableEmail(".cea");
16
+ replaceOn();
17
+ refreshFsLightbox();
18
+ allClickable(".clickable");
19
+ }
20
+
21
+ function onPageLoaded() {
22
+ onDomChanged();
23
+ new FsLightbox();
24
+ }
25
+
26
+ document.addEventListener("DOMContentLoaded", onPageLoaded());
27
+ document.addEventListener("DOMChanged", onDomChanged);
package/src/encore.js CHANGED
@@ -2,15 +2,15 @@ const WatchExternalFilesPlugin = require("webpack-watch-files-plugin").default;
2
2
  const Encore = require("@symfony/webpack-encore");
3
3
  const tailwindcss = require("tailwindcss");
4
4
 
5
- function getFilesToWatch() {
5
+ function getFilesToWatch(basePath = "./..") {
6
6
  return [
7
- "./../vendor/pushword/core/src/templates/**/*.html.twig",
8
- "./../vendor/pushword/core/src/templates/*.html.twig",
9
- "./../vendor/pushword/conversation/src/templates/*.html.twig",
10
- "./../vendor/pushword/admin-block-editor/src/templates/page/*.html.twig",
11
- "./../templates/*.html.twig",
12
- "./../templates/**/*.html.twig",
13
- "./../templates/**/**/*.html.twig",
7
+ basePath + "/vendor/pushword/core/src/templates/**/*.html.twig",
8
+ basePath + "/vendor/pushword/core/src/templates/*.html.twig",
9
+ basePath + "/vendor/pushword/conversation/src/templates/*.html.twig",
10
+ basePath + "/vendor/pushword/admin-block-editor/src/templates/page/*.html.twig",
11
+ basePath + "/templates/*.html.twig",
12
+ basePath + "/templates/**/*.html.twig",
13
+ basePath + "/templates/**/**/*.html.twig",
14
14
  ];
15
15
  }
16
16
  function getTailwindConfig(watchFiles = null) {
@@ -30,23 +30,13 @@ module.exports = {
30
30
  publicPath = "/assets",
31
31
  manifestKeyPrefix = null,
32
32
  filesToCopy = [
33
- {
34
- from: "./media/", // todo explain
35
- to: "[name].[ext]",
36
- pattern: /svg$/,
37
- },
38
- {
39
- from: "./img/",
40
- to: "[name].[ext]",
41
- pattern: /header.jpg$/,
42
- },
43
33
  {
44
34
  from: "./favicons",
45
35
  to: "[name].[ext]",
46
36
  },
47
37
  ],
48
- entries = [{ name: "app", file: "./app.js" }],
49
- styleEntries = [{ name: "style", file: "./app.css" }]
38
+ entries = null,
39
+ styleEntries = null
50
40
  ) {
51
41
  if (watchFiles === null) {
52
42
  watchFiles = getFilesToWatch();
@@ -56,6 +46,18 @@ module.exports = {
56
46
  tailwindConfig = getTailwindConfig(watchFiles);
57
47
  }
58
48
 
49
+ if (entries === null) {
50
+ entries = [{ name: "app", file: __dirname + "/app.js" }];
51
+ } else if (typeof entries === "string") {
52
+ entries = [{ name: "app", file: entries }];
53
+ }
54
+
55
+ if (styleEntries === null) {
56
+ styleEntries = [{ name: "style", file: __dirname + "/app.css" }];
57
+ } else if (typeof styleEntries === "string") {
58
+ styleEntries = [{ name: "style", file: styleEntries }];
59
+ }
60
+
59
61
  Encore.setOutputPath(outputPath)
60
62
  .setPublicPath(publicPath)
61
63
  .cleanupOutputBeforeBuild()
package/src/helpers.js CHANGED
@@ -199,7 +199,7 @@ export async function uncloakLinks(attribute = "data-rot", when = "onEvent") {
199
199
  if (element.getAttribute(attribute) === null) {
200
200
  var element = element.closest("[" + attribute + "]");
201
201
  }
202
- if (element.getAttribute(attribute) === null) return;
202
+ if (element === null || element.getAttribute(attribute) === null) return;
203
203
  var link = document.createElement("a");
204
204
  var href = element.getAttribute(attribute);
205
205
  element.removeAttribute(attribute);
@@ -233,7 +233,7 @@ export async function uncloakLinks(attribute = "data-rot", when = "onEvent") {
233
233
  } else {
234
234
  var element = convertLink(event.target);
235
235
  }
236
- fireEventLinksBuilt(element, event);
236
+ if (element) fireEventLinksBuilt(element, event);
237
237
  };
238
238
 
239
239
  if (when == "onEvent") {
@@ -51,8 +51,3 @@ html {
51
51
  max-height: 100vh;
52
52
  padding-top: 1rem;
53
53
  }
54
-
55
- /*
56
- * Special full-width from everywhere alias .w-full-vw:
57
- w-screen relative left-[49%] ml-[-50vw] my-6
58
- */