single-file-core 1.10.1 → 1.12.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/core/constants.js +3 -1
- package/core/helper.js +2 -2
- package/core/index.js +40 -0
- package/core/lib/processor-helper-common.js +72 -46
- package/core/notes.js +943 -0
- package/modules/template-formatter.js +5 -0
- package/package.json +1 -1
- package/processors/hooks/content/content-hooks-frames-web.js +19 -0
- package/single-file-editor-helper.js +2 -0
- package/single-file-notes.js +43 -0
|
@@ -17024,6 +17024,11 @@ async function evalTemplate(template = "", options, content, doc, context = {})
|
|
|
17024
17024
|
"if-not-equals": (value, otherValue, trueValue, falseValue) => value != otherValue ? trueValue : falseValue,
|
|
17025
17025
|
"if-contains": (value, otherValue, trueValue, falseValue) => otherValue && value.includes(otherValue) ? trueValue : falseValue,
|
|
17026
17026
|
"if-not-contains": (value, otherValue, trueValue, falseValue) => otherValue && !value.includes(otherValue) ? trueValue : falseValue,
|
|
17027
|
+
"switch": (value, ...cases) => {
|
|
17028
|
+
const defaultValue = cases.length % 2 ? cases.pop() : undefined;
|
|
17029
|
+
const index = cases.findIndex((caseValue, caseIndex) => caseIndex % 2 == 0 && caseValue == value);
|
|
17030
|
+
return index == -1 ? defaultValue : cases[index + 1];
|
|
17031
|
+
},
|
|
17027
17032
|
"substring": (value, start, end) => value.substring(start, end),
|
|
17028
17033
|
"lowercase": value => value.toLowerCase(),
|
|
17029
17034
|
"uppercase": value => value.toUpperCase(),
|
package/package.json
CHANGED
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
const MutationObserver = globalThis.MutationObserver;
|
|
93
93
|
const URL = globalThis.URL;
|
|
94
94
|
const CSSStyleSheet = globalThis.CSSStyleSheet;
|
|
95
|
+
const DOMRect = globalThis.DOMRect;
|
|
95
96
|
|
|
96
97
|
const observers = new Map();
|
|
97
98
|
const observedElements = new Map();
|
|
@@ -188,6 +189,10 @@
|
|
|
188
189
|
document.documentElement.style.removeProperty("-sf-transform");
|
|
189
190
|
document.documentElement.style.removeProperty("-sf-transform-origin");
|
|
190
191
|
document.documentElement.style.removeProperty("-sf-min-height");
|
|
192
|
+
if (globalThis._singleFile_getBoundingClientRect) {
|
|
193
|
+
Element.prototype.getBoundingClientRect = globalThis._singleFile_getBoundingClientRect;
|
|
194
|
+
delete globalThis._singleFile_getBoundingClientRect;
|
|
195
|
+
}
|
|
191
196
|
resetScreenSize();
|
|
192
197
|
}
|
|
193
198
|
|
|
@@ -351,6 +356,20 @@
|
|
|
351
356
|
document.documentElement.style.setProperty("transform-origin", horizontalOrigin + " 0 0", "important");
|
|
352
357
|
document.documentElement.style.setProperty("transform", translation + "scale3d(" + zoomFactor + ", " + zoomFactor + ", 1)", "important");
|
|
353
358
|
document.documentElement.style.setProperty("min-height", (100 / zoomFactor) + "vh", "important");
|
|
359
|
+
if (keepZoomLevel && !globalThis._singleFile_getBoundingClientRect) {
|
|
360
|
+
const originX = horizontalOrigin == "0" ? 0 : document.documentElement.offsetWidth / 2;
|
|
361
|
+
const translationX = horizontalOrigin == "0" ? scrollPosition.x : 0;
|
|
362
|
+
const translationY = scrollPosition.y;
|
|
363
|
+
globalThis._singleFile_getBoundingClientRect = Element.prototype.getBoundingClientRect;
|
|
364
|
+
Element.prototype.getBoundingClientRect = function () {
|
|
365
|
+
const boundingRect = globalThis._singleFile_getBoundingClientRect.call(this);
|
|
366
|
+
const x = originX + (boundingRect.x + globalThis.scrollX - originX - translationX) / zoomFactor - globalThis.scrollX;
|
|
367
|
+
const y = (boundingRect.y + globalThis.scrollY - translationY) / zoomFactor - globalThis.scrollY;
|
|
368
|
+
return new DOMRect(x, y, boundingRect.width / zoomFactor, boundingRect.height / zoomFactor);
|
|
369
|
+
};
|
|
370
|
+
Element.prototype.getBoundingClientRect.toString = function () { return "function getBoundingClientRect() { [native code] }"; };
|
|
371
|
+
setFunctionName(Element.prototype.getBoundingClientRect, "getBoundingClientRect");
|
|
372
|
+
}
|
|
354
373
|
dispatchResizeEvent();
|
|
355
374
|
if (keepZoomLevel || keepEmulatedScreenSize) {
|
|
356
375
|
document.documentElement.style.setProperty("-sf-transform", transform, transformPriority);
|
|
@@ -28,6 +28,7 @@ import { getInstance } from "./core/util.js";
|
|
|
28
28
|
import * as zip from "./vendor/zip/zip.js";
|
|
29
29
|
import { extract } from "./processors/compression/compression-extract.js";
|
|
30
30
|
import { display } from "./processors/compression/compression-display.js";
|
|
31
|
+
import * as notes from "./core/notes.js";
|
|
31
32
|
|
|
32
33
|
const util = getInstance();
|
|
33
34
|
const helper = {
|
|
@@ -56,6 +57,7 @@ const helper = {
|
|
|
56
57
|
extract,
|
|
57
58
|
display,
|
|
58
59
|
formatFilename,
|
|
60
|
+
notes,
|
|
59
61
|
INFOBAR_TAGNAME: infobar.INFOBAR_TAGNAME,
|
|
60
62
|
NESTING_TRACK_ID_ATTRIBUTE_NAME: util.NESTING_TRACK_ID_ATTRIBUTE_NAME
|
|
61
63
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2010-2025 Gildas Lormeau
|
|
3
|
+
* contact : gildas.lormeau <at> gmail.com
|
|
4
|
+
*
|
|
5
|
+
* This file is part of SingleFile.
|
|
6
|
+
*
|
|
7
|
+
* The code in this file is free software: you can redistribute it and/or
|
|
8
|
+
* modify it under the terms of the GNU Affero General Public License
|
|
9
|
+
* (GNU AGPL) as published by the Free Software Foundation, either version 3
|
|
10
|
+
* of the License, or (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* The code in this file is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
|
|
15
|
+
* General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* As additional permission under GNU AGPL version 3 section 7, you may
|
|
18
|
+
* distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
|
|
19
|
+
* AGPL normally required by section 4, provided you include this license
|
|
20
|
+
* notice and a URL through which recipients can access the Corresponding
|
|
21
|
+
* Source.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/* global document */
|
|
25
|
+
|
|
26
|
+
import { init, restoreShadowRoots, repairNesting, NOTE_TAGNAME } from "./core/notes.js";
|
|
27
|
+
|
|
28
|
+
(() => {
|
|
29
|
+
|
|
30
|
+
if (document.currentScript) {
|
|
31
|
+
document.currentScript.remove();
|
|
32
|
+
}
|
|
33
|
+
const notes = init(document);
|
|
34
|
+
globalThis.onresize = notes.reflowNotes;
|
|
35
|
+
document.documentElement.onmouseup = document.documentElement.ontouchend = notes.onMouseUp;
|
|
36
|
+
restoreShadowRoots(document);
|
|
37
|
+
notes.reflowNotes();
|
|
38
|
+
document.querySelectorAll(NOTE_TAGNAME).forEach(containerElement => notes.attachNoteListeners(containerElement));
|
|
39
|
+
notes.waitResourcesLoad().then(notes.reflowNotes);
|
|
40
|
+
notes.watchNotesLayout();
|
|
41
|
+
repairNesting(document);
|
|
42
|
+
|
|
43
|
+
})();
|