@seamlet/astro 0.6.0 → 0.8.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/README.md +42 -17
- package/components/RichLine.astro +37 -0
- package/components/RichText.astro +42 -0
- package/dist/bridge.d.ts +3 -3
- package/dist/bridge.js +263 -13
- package/dist/chunk-27XIZEVS.js +705 -0
- package/dist/{chunk-GLXC5OLC.js → chunk-ZUJEM3P7.js} +127 -0
- package/dist/{content-C_WpiWBm.d.ts → content-6k-E7NWf.d.ts} +48 -4
- package/dist/{messages-CBf5diaN.d.ts → messages-Dx0jNy3N.d.ts} +76 -4
- package/dist/{parse-content-9RIWhb6z.d.ts → parse-content-C9ldnmvj.d.ts} +1 -1
- package/dist/protocol.d.ts +16 -4
- package/dist/protocol.js +26 -4
- package/dist/schema.d.ts +4 -4
- package/dist/schema.js +13 -1
- package/dist/site.d.ts +1 -1
- package/dist/site.js +1 -1
- package/package.json +5 -3
- package/dist/chunk-XCBYYKWR.js +0 -160
package/dist/chunk-XCBYYKWR.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
formatFieldPath,
|
|
3
|
-
resolveFieldPath
|
|
4
|
-
} from "./chunk-GLXC5OLC.js";
|
|
5
|
-
|
|
6
|
-
// src/bridge/editor-shortcuts.ts
|
|
7
|
-
function shortcutOf(event) {
|
|
8
|
-
const hasCommandKey = event.metaKey || event.ctrlKey;
|
|
9
|
-
if (!hasCommandKey || event.altKey) {
|
|
10
|
-
return void 0;
|
|
11
|
-
}
|
|
12
|
-
switch (event.code) {
|
|
13
|
-
case "KeyS":
|
|
14
|
-
return "save";
|
|
15
|
-
case "KeyZ":
|
|
16
|
-
return event.shiftKey ? "redo" : "undo";
|
|
17
|
-
case "KeyY":
|
|
18
|
-
return "redo";
|
|
19
|
-
default:
|
|
20
|
-
return void 0;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// src/bridge/image-fields.ts
|
|
25
|
-
function imageFieldAt(schema, path) {
|
|
26
|
-
const target = path === void 0 ? void 0 : resolveFieldPath(schema, path);
|
|
27
|
-
const isImage = target?.kind === "field" && target.field.kind === "image";
|
|
28
|
-
return isImage ? { path: target.path, field: target.field } : void 0;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// src/bridge/messages.ts
|
|
32
|
-
var PROTOCOL_VERSION = 1;
|
|
33
|
-
var EDITOR_KEYS = /* @__PURE__ */ new Set([
|
|
34
|
-
"save",
|
|
35
|
-
"undo",
|
|
36
|
-
"redo",
|
|
37
|
-
"escape"
|
|
38
|
-
]);
|
|
39
|
-
var TYPING_OUTCOMES = /* @__PURE__ */ new Set([
|
|
40
|
-
"kept",
|
|
41
|
-
"reverted"
|
|
42
|
-
]);
|
|
43
|
-
function readPageMessage(data) {
|
|
44
|
-
if (!isRecord(data)) return void 0;
|
|
45
|
-
return isPageMessage(data) ? data : void 0;
|
|
46
|
-
}
|
|
47
|
-
function readEditorMessage(data) {
|
|
48
|
-
if (!isRecord(data)) return void 0;
|
|
49
|
-
return isEditorMessage(data) ? data : void 0;
|
|
50
|
-
}
|
|
51
|
-
function isPageMessage(message) {
|
|
52
|
-
switch (message["type"]) {
|
|
53
|
-
case "ready":
|
|
54
|
-
return isNumber(message["protocol"]);
|
|
55
|
-
case "file-drag-end":
|
|
56
|
-
case "rendered":
|
|
57
|
-
case "render-failed":
|
|
58
|
-
return true;
|
|
59
|
-
case "layout":
|
|
60
|
-
return isLayout(message["layout"]);
|
|
61
|
-
case "hover":
|
|
62
|
-
case "file-drag":
|
|
63
|
-
return isOptional(message["path"], isString);
|
|
64
|
-
case "click":
|
|
65
|
-
return isOptional(message["target"], isClickTarget);
|
|
66
|
-
case "link-click":
|
|
67
|
-
return isString(message["href"]);
|
|
68
|
-
case "key":
|
|
69
|
-
return isString(message["key"]) && EDITOR_KEYS.has(message["key"]);
|
|
70
|
-
case "file-drop":
|
|
71
|
-
return isString(message["path"]) && message["file"] instanceof File;
|
|
72
|
-
case "typing-started":
|
|
73
|
-
case "typing-refused":
|
|
74
|
-
return isString(message["path"]);
|
|
75
|
-
case "typed":
|
|
76
|
-
return isString(message["path"]) && isString(message["text"]);
|
|
77
|
-
case "typing-ended":
|
|
78
|
-
return isString(message["path"]) && isString(message["outcome"]) && TYPING_OUTCOMES.has(message["outcome"]);
|
|
79
|
-
default:
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function isEditorMessage(message) {
|
|
84
|
-
switch (message["type"]) {
|
|
85
|
-
case "connect":
|
|
86
|
-
return isRecord(message["schema"]);
|
|
87
|
-
case "render":
|
|
88
|
-
return isRecord(message["content"]);
|
|
89
|
-
case "start-typing":
|
|
90
|
-
return isString(message["path"]) && isString(message["text"]) && typeof message["isSingleLine"] === "boolean" && isPoint(message["point"]);
|
|
91
|
-
case "stop-typing":
|
|
92
|
-
return true;
|
|
93
|
-
case "scroll-to":
|
|
94
|
-
return isFieldPath(message["path"]);
|
|
95
|
-
default:
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function isLayout(value) {
|
|
100
|
-
if (!isRecord(value)) return false;
|
|
101
|
-
const markers = value["markers"];
|
|
102
|
-
return Array.isArray(markers) && markers.every(isMarkerBox) && isViewport(value["viewport"]) && isOptional(value["link"], isLinkBox);
|
|
103
|
-
}
|
|
104
|
-
function isMarkerBox(value) {
|
|
105
|
-
return isRecord(value) && isString(value["path"]) && isBox(value["box"]);
|
|
106
|
-
}
|
|
107
|
-
function isLinkBox(value) {
|
|
108
|
-
return isRecord(value) && isString(value["href"]) && isBox(value["box"]);
|
|
109
|
-
}
|
|
110
|
-
function isClickTarget(value) {
|
|
111
|
-
return isRecord(value) && isString(value["path"]) && isPoint(value["point"]);
|
|
112
|
-
}
|
|
113
|
-
function isBox(value) {
|
|
114
|
-
return isRecord(value) && isNumber(value["top"]) && isNumber(value["left"]) && isNumber(value["width"]) && isNumber(value["height"]);
|
|
115
|
-
}
|
|
116
|
-
function isViewport(value) {
|
|
117
|
-
return isRecord(value) && isNumber(value["width"]) && isNumber(value["height"]);
|
|
118
|
-
}
|
|
119
|
-
function isPoint(value) {
|
|
120
|
-
return isRecord(value) && isNumber(value["x"]) && isNumber(value["y"]);
|
|
121
|
-
}
|
|
122
|
-
function isFieldPath(value) {
|
|
123
|
-
return Array.isArray(value) && value.every((segment) => isString(segment) || isNumber(segment));
|
|
124
|
-
}
|
|
125
|
-
function isOptional(value, isPresent) {
|
|
126
|
-
return value === void 0 || isPresent(value);
|
|
127
|
-
}
|
|
128
|
-
function isRecord(value) {
|
|
129
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
130
|
-
}
|
|
131
|
-
function isString(value) {
|
|
132
|
-
return typeof value === "string";
|
|
133
|
-
}
|
|
134
|
-
function isNumber(value) {
|
|
135
|
-
return typeof value === "number" && Number.isFinite(value);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// src/bridge/file-drags.ts
|
|
139
|
-
function carriesFiles(event) {
|
|
140
|
-
return event.dataTransfer?.types.includes("Files") === true;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// src/bridge/marked-paths.ts
|
|
144
|
-
function closestMarkedPath(path, isMarked) {
|
|
145
|
-
for (let length = path.length; length > 0; length -= 1) {
|
|
146
|
-
const candidate = formatFieldPath(path.slice(0, length));
|
|
147
|
-
if (isMarked(candidate)) return candidate;
|
|
148
|
-
}
|
|
149
|
-
return void 0;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export {
|
|
153
|
-
shortcutOf,
|
|
154
|
-
imageFieldAt,
|
|
155
|
-
PROTOCOL_VERSION,
|
|
156
|
-
readPageMessage,
|
|
157
|
-
readEditorMessage,
|
|
158
|
-
carriesFiles,
|
|
159
|
-
closestMarkedPath
|
|
160
|
-
};
|