@hyperframes/core 0.9.106 → 0.10.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/dist/compiler/htmlDocument.d.ts +1 -0
- package/dist/compiler/htmlDocument.js +4 -0
- package/dist/generated/runtime-inline.js +1 -1
- package/dist/hyperframe.runtime.iife.js +58 -58
- package/dist/runtime/editing/editElement.js +3 -3
- package/dist/runtime/editing/textEdit.js +3 -3
- package/dist/runtime/editing/textMarkup.d.ts +1 -0
- package/dist/runtime/editing/textMarkup.js +2 -1
- package/package.json +4 -4
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { EDITING_ELEMENT_HANDLE } from "../editingElement.js";
|
|
4
4
|
import { elementForHandle } from "../editingHandles.js";
|
|
5
5
|
import { isStylableElement } from "../domRealm.js";
|
|
6
|
-
import { DATA_ATTRIBUTE, holdsOnlyTextMarkup, MAX_EDIT_VALUE } from "./textMarkup.js";
|
|
6
|
+
import { DATA_ATTRIBUTE, holdsOnlyTextMarkup, MAX_EDIT_VALUE, MAX_TEXT_MARKUP } from "./textMarkup.js";
|
|
7
7
|
export const MAX_EDIT_ENTRIES = 64;
|
|
8
8
|
export { MAX_EDIT_VALUE };
|
|
9
9
|
const STYLE_NAME = /^(?:-?[a-z][a-z0-9-]*|--[\w\u0080-\uffff-]+)$/;
|
|
@@ -11,7 +11,7 @@ const PANEL_ATTRIBUTES = new Set(["loop", "muted", "alt", "title", "src"]);
|
|
|
11
11
|
const MEDIA_TAGS = new Set(["img", "video", "audio"]);
|
|
12
12
|
const isAttributeName = (name) => DATA_ATTRIBUTE.test(name) || PANEL_ATTRIBUTES.has(name);
|
|
13
13
|
export function isTextMarkup(html) {
|
|
14
|
-
if (html.length >
|
|
14
|
+
if (html.length > MAX_TEXT_MARKUP)
|
|
15
15
|
return false;
|
|
16
16
|
const holder = document.createElement("template");
|
|
17
17
|
holder.innerHTML = html;
|
|
@@ -36,7 +36,7 @@ const EDIT_KEYS = new Set([
|
|
|
36
36
|
"attributes,handle,html,styles",
|
|
37
37
|
"attributes,expect,handle,html,styles",
|
|
38
38
|
]);
|
|
39
|
-
const isOptionalMarkup = (value) => value === undefined || (typeof value === "string" && value.length <=
|
|
39
|
+
const isOptionalMarkup = (value) => value === undefined || (typeof value === "string" && value.length <= MAX_TEXT_MARKUP);
|
|
40
40
|
const markupFieldsOk = (html, expect) => isOptionalMarkup(html) &&
|
|
41
41
|
isOptionalMarkup(expect) &&
|
|
42
42
|
(expect === undefined || html !== undefined);
|
|
@@ -5,8 +5,8 @@ import { EDITING_ELEMENT_HANDLE } from "../editingElement.js";
|
|
|
5
5
|
import { elementForHandle } from "../editingHandles.js";
|
|
6
6
|
import { isDomNode, isStylableElement } from "../domRealm.js";
|
|
7
7
|
import { sanitizeRichTextChildren } from "../../utils/richTextSanitize.js";
|
|
8
|
-
import { openTextEdits, isTextMarkup
|
|
9
|
-
import { isEditableText } from "./textMarkup.js";
|
|
8
|
+
import { openTextEdits, isTextMarkup } from "./editElement.js";
|
|
9
|
+
import { isEditableText, MAX_TEXT_MARKUP } from "./textMarkup.js";
|
|
10
10
|
import { caretBoxIn, caretColorOf, caretSideAfterKey, placeCaretAtEnd, } from "./textCaret.js";
|
|
11
11
|
import { applyInlineStyle, INLINE_STYLE_PROPERTIES, readFirstPaintedElement, readInlineStyle, readInlineStyleSpread, } from "../../utils/inlineTextStyleRead.js";
|
|
12
12
|
const EDITING_OUTLINE = "2px solid #3CE6AC";
|
|
@@ -101,7 +101,7 @@ export function textEditAwayEvent(data, version) {
|
|
|
101
101
|
return null;
|
|
102
102
|
return { handle, button, point, viewportWidth, keys };
|
|
103
103
|
}
|
|
104
|
-
const isValue = (value) => value === null || (typeof value === "string" && value.length <=
|
|
104
|
+
const isValue = (value) => value === null || (typeof value === "string" && value.length <= MAX_TEXT_MARKUP);
|
|
105
105
|
const isTextMarkupOrNull = (value) => value === null || (typeof value === "string" && isTextMarkup(value));
|
|
106
106
|
export function textEditEndedEvent(data, version) {
|
|
107
107
|
if (!isRecord(data) || !keysAre(data, "event,handle,html,previous,v"))
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const DATA_ATTRIBUTE: RegExp;
|
|
2
2
|
export declare const MAX_EDIT_VALUE = 200000;
|
|
3
|
+
export declare const MAX_TEXT_MARKUP: number;
|
|
3
4
|
export declare const holdsOnlyTextMarkup: (root: ParentNode) => boolean;
|
|
4
5
|
export declare const isEditableText: (element: Element) => boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Text markup: text in inline text tags carrying plain attributes, so no URL and no handler.
|
|
2
2
|
export const DATA_ATTRIBUTE = /^data-[a-z0-9_-]+$/;
|
|
3
3
|
export const MAX_EDIT_VALUE = 200_000;
|
|
4
|
+
export const MAX_TEXT_MARKUP = 32 * 1024 * 1024;
|
|
4
5
|
const TEXT_TAGS = new Set([
|
|
5
6
|
"span",
|
|
6
7
|
"strong",
|
|
@@ -19,4 +20,4 @@ export const holdsOnlyTextMarkup = (root) => Array.from(root.querySelectorAll("*
|
|
|
19
20
|
el
|
|
20
21
|
.getAttributeNames()
|
|
21
22
|
.every((name) => TEXT_ATTRIBUTES.has(name) || DATA_ATTRIBUTE.test(name)));
|
|
22
|
-
export const isEditableText = (element) => holdsOnlyTextMarkup(element) && element.innerHTML.length <=
|
|
23
|
+
export const isEditableText = (element) => holdsOnlyTextMarkup(element) && element.innerHTML.length <= MAX_TEXT_MARKUP;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -525,9 +525,9 @@
|
|
|
525
525
|
"linkedom": "^0.18.12",
|
|
526
526
|
"postcss": "^8.5.8",
|
|
527
527
|
"wawoff2": "^2.0.1",
|
|
528
|
-
"@hyperframes/lint": "0.
|
|
529
|
-
"@hyperframes/
|
|
530
|
-
"@hyperframes/
|
|
528
|
+
"@hyperframes/lint": "0.10.0",
|
|
529
|
+
"@hyperframes/parsers": "0.10.0",
|
|
530
|
+
"@hyperframes/studio-server": "0.10.0"
|
|
531
531
|
},
|
|
532
532
|
"devDependencies": {
|
|
533
533
|
"@fontsource/archivo-black": "^5.2.8",
|