danoniplus 42.0.0 → 42.1.0
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/js/danoni_main.js +26 -4
- package/package.json +1 -1
package/js/danoni_main.js
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Source by tickle
|
|
6
6
|
* Created : 2018/10/08
|
|
7
|
-
* Revised : 2025/
|
|
7
|
+
* Revised : 2025/06/07
|
|
8
8
|
*
|
|
9
9
|
* https://github.com/cwtickle/danoniplus
|
|
10
10
|
*/
|
|
11
|
-
const g_version = `Ver 42.
|
|
12
|
-
const g_revisedDate = `2025/
|
|
11
|
+
const g_version = `Ver 42.1.0`;
|
|
12
|
+
const g_revisedDate = `2025/06/07`;
|
|
13
13
|
|
|
14
14
|
// カスタム用バージョン (danoni_custom.js 等で指定可)
|
|
15
15
|
let g_localVersion = ``;
|
|
@@ -66,7 +66,7 @@ const g_referenceDomains = [
|
|
|
66
66
|
Object.freeze(g_referenceDomains);
|
|
67
67
|
|
|
68
68
|
const g_rootPath = current().match(/(^.*\/)/)[0];
|
|
69
|
-
|
|
69
|
+
let g_workPath;
|
|
70
70
|
const hasRemoteDomain = _path => g_referenceDomains.some(domain => _path.match(`^https://${domain}/`) !== null);
|
|
71
71
|
const g_remoteFlg = hasRemoteDomain(g_rootPath);
|
|
72
72
|
|
|
@@ -821,6 +821,26 @@ const unEscapeHtml = _str => unEscapeEmoji(replaceStr(_str, g_escapeStr.unEscape
|
|
|
821
821
|
*/
|
|
822
822
|
const escapeHtmlForArray = _array => _array.map(str => escapeHtml(str));
|
|
823
823
|
|
|
824
|
+
/**
|
|
825
|
+
* URLのパスを検証し、絶対URLまたは相対パスであればその値を返す
|
|
826
|
+
* @param {string} _input
|
|
827
|
+
* @param {string} _defaultUrl
|
|
828
|
+
* @returns {string}
|
|
829
|
+
*/
|
|
830
|
+
const validatePath = (_input, _defaultUrl = ``) => {
|
|
831
|
+
// 絶対 URL(http, https, ftp, fileなど)
|
|
832
|
+
const absoluteUrlPattern = /^(https?:\/\/|ftp:\/\/|file:\/\/)/;
|
|
833
|
+
|
|
834
|
+
// 相対パス(ルート相対 `/path/to/file` もしくは `./file`, `../file` )
|
|
835
|
+
const relativePathPattern = /^\/|^\.{1,2}\//;
|
|
836
|
+
|
|
837
|
+
const raw = _input && (absoluteUrlPattern.test(_input) || relativePathPattern.test(_input))
|
|
838
|
+
? encodeURI(_input) : _defaultUrl;
|
|
839
|
+
|
|
840
|
+
// URL または相対パスが合致すればその値を返し、そうでなければデフォルト URL を返す
|
|
841
|
+
return raw.endsWith(`/`) ? raw : raw + `/`;
|
|
842
|
+
};
|
|
843
|
+
|
|
824
844
|
/**
|
|
825
845
|
* 次のカーソルへ移動
|
|
826
846
|
* @param {number} _basePos
|
|
@@ -2454,6 +2474,8 @@ const initialControl = async () => {
|
|
|
2454
2474
|
|
|
2455
2475
|
const stage = document.getElementById(`canvas-frame`);
|
|
2456
2476
|
const divRoot = createEmptySprite(stage, `divRoot`, g_windowObj.divRoot);
|
|
2477
|
+
g_workPath = validatePath(document.getElementById(`jsRootUrl`)?.value,
|
|
2478
|
+
new URL(location.href).href.match(/(^.*\/)/)[0]);
|
|
2457
2479
|
|
|
2458
2480
|
// 背景の表示
|
|
2459
2481
|
if (document.getElementById(`layer0`) !== null) {
|