@pushword/js-helper 0.0.117 → 0.0.118
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 +2 -2
- package/package.json +2 -3
- package/src/encore.js +35 -11
- package/src/helpers.js +8 -3
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Some js helpers for Pushword front end.
|
|
|
5
5
|
[](https://github.com/Pushword/Pushword/tags)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](https://github.com/Pushword/Pushword/actions)
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
[](https://codecov.io/gh/Pushword/Pushword/tree/main)
|
|
10
10
|
[](https://shepherd.dev/github/pushword/pushword)
|
|
11
11
|
[](https://packagist.org/packages/pushword/core)
|
|
@@ -27,6 +27,6 @@ If you're interested in contributing to Pushword, please read our [contributing
|
|
|
27
27
|
|
|
28
28
|
The MIT License (MIT). Please see [License File](https://pushword.piedweb.com/license#license) for more information.
|
|
29
29
|
|
|
30
|
-
<p align="center"><a href="https://dev.piedweb.com"
|
|
30
|
+
<p align="center"><a href="https://dev.piedweb.com">
|
|
31
31
|
<img src="https://raw.githubusercontent.com/Pushword/Pushword/f5021f4c5d5d3ab3f2858ec2e4bdd70818806c6a/packages/admin/src/Resources/assets/logo.svg" width="200" height="200" alt="PHP Packages Open Source" />
|
|
32
32
|
</a></p>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushword/js-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.118",
|
|
4
4
|
"description": "Pushword front end helpers. ",
|
|
5
5
|
"author": "Robin@PiedWeb <contact@piedweb.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,12 +10,11 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"140.css": "^1.0.1",
|
|
12
12
|
"@babel/core": "^7.23",
|
|
13
|
-
"@babel/preset-env": "^7.22
|
|
13
|
+
"@babel/preset-env": "^7.22",
|
|
14
14
|
"@symfony/webpack-encore": "^4.6",
|
|
15
15
|
"@tailwindcss/aspect-ratio": "^0.4",
|
|
16
16
|
"@tailwindcss/forms": "^0.5",
|
|
17
17
|
"@tailwindcss/typography": "^0.5",
|
|
18
|
-
"ace-builds": "^1.36",
|
|
19
18
|
"autoprefixer": "^10.4",
|
|
20
19
|
"babel-preset-stage-2": "^6.24.1",
|
|
21
20
|
"codemirror": "^6.0",
|
package/src/encore.js
CHANGED
|
@@ -2,6 +2,7 @@ const WatchExternalFilesPlugin = require('webpack-watch-files-plugin').default
|
|
|
2
2
|
const tailwindcss = require('tailwindcss')
|
|
3
3
|
const postcssImport = require('postcss-import')
|
|
4
4
|
const autoprefixer = require('autoprefixer')
|
|
5
|
+
const Encore = require('@symfony/webpack-encore')
|
|
5
6
|
|
|
6
7
|
function getFilesToWatch(basePath = './..') {
|
|
7
8
|
return [
|
|
@@ -22,6 +23,10 @@ function getTailwindConfig(watchFiles = null) {
|
|
|
22
23
|
return tailwindConfig
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param {Encore} Encore
|
|
29
|
+
*/
|
|
25
30
|
function getEncore(
|
|
26
31
|
Encore,
|
|
27
32
|
watchFiles = null, // default: getFilesToWatch()
|
|
@@ -32,6 +37,7 @@ function getEncore(
|
|
|
32
37
|
filesToCopy = null, // default :: ... from: /favicons. ...
|
|
33
38
|
entries = null, // [{ name: 'app', file: '/node_modules/@pushword/js-helper/src/app.js' }];
|
|
34
39
|
styleEntries = null, // [{ name: 'style', file: '/node_modules/@pushword/js-helper/src/app.css' }];
|
|
40
|
+
isLegacy = false,
|
|
35
41
|
) {
|
|
36
42
|
if (watchFiles === null) {
|
|
37
43
|
watchFiles = getFilesToWatch()
|
|
@@ -41,13 +47,14 @@ function getEncore(
|
|
|
41
47
|
tailwindConfig = getTailwindConfig(watchFiles)
|
|
42
48
|
}
|
|
43
49
|
|
|
50
|
+
const jsAppName = 'app' + (isLegacy ? '-legacy' : '')
|
|
44
51
|
if (entries === null) {
|
|
45
|
-
entries = [{ name:
|
|
52
|
+
entries = [{ name: jsAppName, file: __dirname + '/app.js' }]
|
|
46
53
|
} else if (typeof entries === 'string') {
|
|
47
|
-
entries = [{ name:
|
|
54
|
+
entries = [{ name: jsAppName, file: entries }]
|
|
48
55
|
}
|
|
49
56
|
|
|
50
|
-
if (styleEntries === null) {
|
|
57
|
+
if (styleEntries === null && !isLegacy) {
|
|
51
58
|
styleEntries = [{ name: 'style', file: __dirname + '/app.css' }]
|
|
52
59
|
} else if (typeof styleEntries === 'string') {
|
|
53
60
|
styleEntries = [{ name: 'style', file: styleEntries }]
|
|
@@ -59,7 +66,6 @@ function getEncore(
|
|
|
59
66
|
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev')
|
|
60
67
|
.setOutputPath(outputPath)
|
|
61
68
|
.setPublicPath(publicPath)
|
|
62
|
-
.cleanupOutputBeforeBuild()
|
|
63
69
|
.enableSassLoader()
|
|
64
70
|
.enableSourceMaps(false)
|
|
65
71
|
.enableVersioning(false)
|
|
@@ -75,7 +81,7 @@ function getEncore(
|
|
|
75
81
|
})
|
|
76
82
|
.disableSingleRuntimeChunk()
|
|
77
83
|
|
|
78
|
-
if (filesToCopy === null) {
|
|
84
|
+
if (filesToCopy === null && !isLegacy) {
|
|
79
85
|
filesToCopy = [
|
|
80
86
|
{
|
|
81
87
|
from: './favicons',
|
|
@@ -84,9 +90,10 @@ function getEncore(
|
|
|
84
90
|
]
|
|
85
91
|
}
|
|
86
92
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
if (filesToCopy)
|
|
94
|
+
filesToCopy.forEach(function (toCopy) {
|
|
95
|
+
Encore.copyFiles(toCopy)
|
|
96
|
+
})
|
|
90
97
|
|
|
91
98
|
if (manifestKeyPrefix !== null) Encore.setManifestKeyPrefix(manifestKeyPrefix)
|
|
92
99
|
|
|
@@ -94,9 +101,26 @@ function getEncore(
|
|
|
94
101
|
Encore.addEntry(entry.name, entry.file)
|
|
95
102
|
})
|
|
96
103
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
104
|
+
if (styleEntries)
|
|
105
|
+
styleEntries.forEach(function (entry) {
|
|
106
|
+
Encore.addStyleEntry(entry.name, entry.file)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
//if (!isLegacy) Encore.cleanupOutputBeforeBuild()
|
|
110
|
+
|
|
111
|
+
if (!isLegacy) {
|
|
112
|
+
Encore.configureBabelPresetEnv((config) => {
|
|
113
|
+
config.targets = {
|
|
114
|
+
browsers: ['Chrome >= 60', 'Safari >= 10.1', 'iOS >= 10.3', 'Firefox >= 54', 'Edge >= 15'],
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
} else {
|
|
118
|
+
Encore.configureBabelPresetEnv((config) => {
|
|
119
|
+
config.targets = {
|
|
120
|
+
browsers: ['> 1%', 'last 2 versions', 'Firefox ESR'],
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
}
|
|
100
124
|
|
|
101
125
|
return Encore
|
|
102
126
|
}
|
package/src/helpers.js
CHANGED
|
@@ -213,6 +213,11 @@ export function addClassForNormalUser(attribute = 'data-acinb') {
|
|
|
213
213
|
if (window.location.hash) {
|
|
214
214
|
const targetElement = document.querySelector(window.location.hash)
|
|
215
215
|
if (targetElement) {
|
|
216
|
+
// open show more block if exists
|
|
217
|
+
const showMoreTarget = targetElement.closest('.show-more')
|
|
218
|
+
if (showMoreTarget) {
|
|
219
|
+
showMoreTarget.querySelector('.show-more-btn label').click()
|
|
220
|
+
}
|
|
216
221
|
targetElement.scrollIntoView({
|
|
217
222
|
behavior: 'smooth',
|
|
218
223
|
})
|
|
@@ -366,10 +371,10 @@ export function testWebPSupport() {
|
|
|
366
371
|
*/
|
|
367
372
|
export function convertImageLinkToWebPLink() {
|
|
368
373
|
var switchToWebP = function () {
|
|
369
|
-
;[].forEach.call(document.querySelectorAll('a[dwl]'), function (element) {
|
|
370
|
-
var href = responsiveImage(element.getAttribute('dwl'))
|
|
374
|
+
;[].forEach.call(document.querySelectorAll('a[data-dwl]'), function (element) {
|
|
375
|
+
var href = responsiveImage(element.getAttribute('data-dwl'))
|
|
371
376
|
element.setAttribute('href', href)
|
|
372
|
-
element.removeAttribute('dwl')
|
|
377
|
+
element.removeAttribute('data-dwl')
|
|
373
378
|
})
|
|
374
379
|
}
|
|
375
380
|
|