@openartifactsai/editor-kit 0.0.0-stage → 0.23.0-rc.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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +143 -2
- package/package.json +67 -4
- package/src/Announcer.d.ts +2 -0
- package/src/Announcer.js +8 -0
- package/src/FindBar.d.ts +31 -0
- package/src/FindBar.js +37 -0
- package/src/FoldToolbar.d.ts +58 -0
- package/src/FoldToolbar.js +438 -0
- package/src/PanelEdge.d.ts +20 -0
- package/src/PanelEdge.js +74 -0
- package/src/VideoShrinkNotice.d.ts +10 -0
- package/src/VideoShrinkNotice.js +81 -0
- package/src/WheelZoomItem.d.ts +12 -0
- package/src/WheelZoomItem.js +18 -0
- package/src/agent.d.ts +68 -0
- package/src/agent.js +113 -0
- package/src/announce.d.ts +21 -0
- package/src/announce.js +31 -0
- package/src/chrome.d.ts +208 -0
- package/src/chrome.js +148 -0
- package/src/clipboard.d.ts +19 -0
- package/src/clipboard.js +48 -0
- package/src/collab/CommentList.d.ts +32 -0
- package/src/collab/CommentList.js +165 -0
- package/src/collab/CommentViews.d.ts +131 -0
- package/src/collab/CommentViews.js +619 -0
- package/src/collab/HistoryViews.d.ts +38 -0
- package/src/collab/HistoryViews.js +103 -0
- package/src/collab/PresenceViews.d.ts +53 -0
- package/src/collab/PresenceViews.js +48 -0
- package/src/collab/cds/cds.d.ts +151 -0
- package/src/collab/cds/cds.js +231 -0
- package/src/collab/cds/comment-card.d.ts +113 -0
- package/src/collab/cds/comment-card.js +230 -0
- package/src/collab/cds/comment-composer.d.ts +35 -0
- package/src/collab/cds/comment-composer.js +125 -0
- package/src/collab/cds/comments-css.d.ts +2 -0
- package/src/collab/cds/comments-css.js +3 -0
- package/src/collab/cds/comments.css +504 -0
- package/src/collab/cds/edge-piles.d.ts +69 -0
- package/src/collab/cds/edge-piles.js +178 -0
- package/src/collab/cds/layer.d.ts +41 -0
- package/src/collab/cds/layer.js +144 -0
- package/src/collab/cds/markdown.d.ts +20 -0
- package/src/collab/cds/markdown.js +534 -0
- package/src/collab/cds/shield.d.ts +28 -0
- package/src/collab/cds/shield.js +114 -0
- package/src/collab/cds/time.d.ts +2 -0
- package/src/collab/cds/time.js +41 -0
- package/src/collab/collab.d.ts +102 -0
- package/src/collab/collab.js +121 -0
- package/src/collab/comments.d.ts +272 -0
- package/src/collab/comments.js +596 -0
- package/src/collab/history-wiring.d.ts +32 -0
- package/src/collab/history-wiring.js +53 -0
- package/src/collab/history.d.ts +59 -0
- package/src/collab/history.js +96 -0
- package/src/collab/mentions/mention-list.d.ts +63 -0
- package/src/collab/mentions/mention-list.js +257 -0
- package/src/collab/mentions.d.ts +112 -0
- package/src/collab/mentions.js +164 -0
- package/src/collab/peer-colors.d.ts +123 -0
- package/src/collab/peer-colors.js +273 -0
- package/src/collab/pins.d.ts +70 -0
- package/src/collab/pins.js +44 -0
- package/src/collab/presence.d.ts +92 -0
- package/src/collab/presence.js +158 -0
- package/src/design-systems.d.ts +46 -0
- package/src/design-systems.js +61 -0
- package/src/downloads.d.ts +31 -0
- package/src/downloads.js +46 -0
- package/src/file-drop.d.ts +33 -0
- package/src/file-drop.js +36 -0
- package/src/find.d.ts +64 -0
- package/src/find.js +147 -0
- package/src/follow.d.ts +141 -0
- package/src/follow.js +389 -0
- package/src/index.d.ts +32 -0
- package/src/index.js +32 -0
- package/src/keys.d.ts +18 -0
- package/src/keys.js +42 -0
- package/src/menu-fit.d.ts +12 -0
- package/src/menu-fit.js +9 -0
- package/src/merge.d.ts +23 -0
- package/src/merge.js +116 -0
- package/src/page-link.d.ts +33 -0
- package/src/page-link.js +75 -0
- package/src/project-sync.d.ts +161 -0
- package/src/project-sync.js +319 -0
- package/src/react.d.ts +20 -0
- package/src/react.js +20 -0
- package/src/read-retries.d.ts +55 -0
- package/src/read-retries.js +125 -0
- package/src/right-drag-pan.d.ts +128 -0
- package/src/right-drag-pan.js +253 -0
- package/src/roles.d.ts +39 -0
- package/src/roles.js +27 -0
- package/src/session.d.ts +56 -0
- package/src/session.js +57 -0
- package/src/shell.d.ts +60 -0
- package/src/shell.js +111 -0
- package/src/stash.d.ts +26 -0
- package/src/stash.js +69 -0
- package/src/styles.css +17 -0
- package/src/toolbar-fold.d.ts +106 -0
- package/src/toolbar-fold.js +130 -0
- package/src/video-shrink/index.d.ts +8 -0
- package/src/video-shrink/index.js +7 -0
- package/src/video-shrink/plan.d.ts +92 -0
- package/src/video-shrink/plan.js +133 -0
- package/src/video-shrink/protocol.d.ts +29 -0
- package/src/video-shrink/protocol.js +2 -0
- package/src/video-shrink/queue.d.ts +69 -0
- package/src/video-shrink/queue.js +287 -0
- package/src/video-shrink/worker.d.ts +8 -0
- package/src/video-shrink/worker.js +223 -0
- package/src/wheel-zoom.d.ts +14 -0
- package/src/wheel-zoom.js +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,144 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @openartifactsai/editor-kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
What the artifact editors (`design-editor`, `slides-editor`,
|
|
4
|
+
`whiteboard-editor`, `design-system-editor`) share beyond the UI primitives of
|
|
5
|
+
`@openartifactsai/ui`. It is private and is not built on its own: each editor's
|
|
6
|
+
Vite build compiles the sources it imports.
|
|
7
|
+
|
|
8
|
+
The kit holds behavior and views. Each editor keeps its document model and
|
|
9
|
+
stores, and connects them to the kit through a small **adapter**: an object of
|
|
10
|
+
callbacks the kit calls. The kit never imports an editor.
|
|
11
|
+
|
|
12
|
+
## Entries
|
|
13
|
+
|
|
14
|
+
| Import | What | Rules |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| `@openartifactsai/editor-kit` | Pure modules: stores, controllers, helpers (`src/index.ts`) | `.ts` only. No React views, no `@openartifactsai/ui`, lucide or Base UI. Loads in `node --test`. |
|
|
17
|
+
| `@openartifactsai/editor-kit/react` | The shared views (`src/react.ts`) | May import `@openartifactsai/ui`, React, lucide. |
|
|
18
|
+
| `@openartifactsai/editor-kit/video-shrink` | Shrinking videos over the 20 MB limit before they are stored (`src/video-shrink/`): the plan for each try, the queue (`queueShrink`, `cancelShrink`, `useVideoShrink`), the messages, and the worker it starts (mediabunny) | `.ts` only. Kept out of the pure entry so editors without videos do not bundle the worker. |
|
|
19
|
+
| `@openartifactsai/editor-kit/video-shrink/notice` | `VideoShrinkNotice`: the toast that shows the queue's progress and Cancel | Mount it once in an editor that queues shrinks. |
|
|
20
|
+
| `@openartifactsai/editor-kit/styles.css` | `@source "./"`, so Tailwind scans the kit for class names | Import it after the UI kit's sheet. |
|
|
21
|
+
|
|
22
|
+
`test/isolation.test.ts` enforces these rules: it checks every import in
|
|
23
|
+
`src/`, keeps the pure modules free of views, and loads the pure entry in
|
|
24
|
+
node.
|
|
25
|
+
|
|
26
|
+
## What lives where
|
|
27
|
+
|
|
28
|
+
Pure entry (`src/`):
|
|
29
|
+
|
|
30
|
+
| Module | Contents |
|
|
31
|
+
|---|---|
|
|
32
|
+
| `collab/comments.ts` | `createComments(adapter)`: the comments store and actions (threads, drafts, replies, resolve, send to agent). |
|
|
33
|
+
| `collab/history.ts` | `createHistory(adapter)`: the version history store (list, preview, restore, notices). |
|
|
34
|
+
| `collab/history-wiring.ts` | `wireVersionHistory`, `readVersionFiles`: history over the `history` capability with a files store. |
|
|
35
|
+
| `collab/presence.ts` | `createPresence(adapter)`, peer colors (`PEER_COLORS`, `AGENT_COLOR`, `peerColor`), `peerValue`. |
|
|
36
|
+
| `collab/collab.ts` | `createCollab`: the glue between comments, history and the Shell (chrome report, commands, the right-hand panel, Esc and comment-mode keys). |
|
|
37
|
+
| `collab/pins.ts` | Camera math for comment pins and cards. |
|
|
38
|
+
| `merge.ts` | `mergeLines(base, ours, theirs, { adjacent })`: three-way line merge. `adjacent: 'conflict'` (slides) refuses changes on touching lines; the default `'merge'` (design system) takes both. |
|
|
39
|
+
| `find.ts` | `occurrences`, `excerpt`, `stepIndex`, `createFind(adapter)`, `highlightText`, `clearFindHighlights` (CSS Custom Highlight API). |
|
|
40
|
+
| `roles.ts` | `roleAbilities(role)`, `readOnlyLabel(role)`. |
|
|
41
|
+
| `session.ts` | `connectHost(names)`, `sessionSlot()`, `GUEST_VIEWER`, `artifactPath`, `projectPath`. |
|
|
42
|
+
| `shell.ts` | `agentChrome`, `chromeReporter` (deduped reports), `createShellBridge` (a bridge with a React hook for what the Shell draws). |
|
|
43
|
+
| `agent.ts` | `agentResultMessage(result, subject)`, `sendFailure`, `watchAgentStatus`. |
|
|
44
|
+
| `downloads.ts` | `saveFile` (host downloads, else the browser), `browserDownload`, `browserDownloadUrl`. |
|
|
45
|
+
| `follow.ts` | `createFollower(host)`: following the agent's work on a canvas (frames new work once the agent is quiet, counts what lands out of view and on which side, stops when the viewer takes over). The editor supplies boxes, camera and timers through a `FollowHost`. |
|
|
46
|
+
| `design-systems.ts` | `createSystemsLoader(adapter)`: reads installed design systems under `project/ds/` and reloads them when they change. |
|
|
47
|
+
| `stash.ts` | `storedJson`, `stashFresh`, `STASH_KEEP_MS`, `normalizeJson`: recovery stashes in `localStorage`. |
|
|
48
|
+
| `page-link.ts` | `#page=` links and browser history for pages. |
|
|
49
|
+
| `announce.ts` | `announce(message)` for the screen reader live region. |
|
|
50
|
+
| `keys.ts` | `isApplePlatform`, `MOD`, `ALT`, `SHIFT`, `modKey`, `isTextField`. |
|
|
51
|
+
|
|
52
|
+
React entry: `CommentViews` (pins, capture, cards), `CommentList`,
|
|
53
|
+
`HistoryViews` (aside, preview bar), `PresenceViews` (avatars, cursors, peer
|
|
54
|
+
boxes), `Announcer`, `chrome.tsx` (`ChromeButton`, `ChromeMenu*`, `Card`,
|
|
55
|
+
`Tip`, `POPUP`…) and `FindBar`.
|
|
56
|
+
|
|
57
|
+
Token helpers for installed design systems (`styleDeclarations`, `styleTag`,
|
|
58
|
+
`installedKey`, `lengthPx`) live in `@openartifactsai/design-system-core`
|
|
59
|
+
(`installed.ts`) because they describe the token format, not an editor.
|
|
60
|
+
|
|
61
|
+
## Adopting a module
|
|
62
|
+
|
|
63
|
+
1. Add `"@openartifactsai/editor-kit": "0.1.0"` to the editor's `dependencies`
|
|
64
|
+
and run `npm install` (the workspace symlink resolves it; no Vite alias is
|
|
65
|
+
needed).
|
|
66
|
+
2. In the editor's `styles.css`, after `@import "@openartifactsai/ui/styles.css";`,
|
|
67
|
+
add `@import "@openartifactsai/editor-kit/styles.css";`. Define the chrome
|
|
68
|
+
tokens the shared views use in the editor's `@theme`: the colors
|
|
69
|
+
`--color-chrome`, `-fg`, `-muted`, `-accent`, `-hover`, `-line`,
|
|
70
|
+
`-pressed`, `-pressed-fg` and `-focus` (the focus outline), and the
|
|
71
|
+
shadows `--shadow-chrome` and `--shadow-chrome-popup`.
|
|
72
|
+
3. Write the adapter next to the editor's store, usually in
|
|
73
|
+
`src/services/<module>.ts`, and export what the rest of the editor uses
|
|
74
|
+
from there. Components import views from `/react`.
|
|
75
|
+
4. Delete the editor's own copy and its tests; the kit's tests cover the
|
|
76
|
+
shared part. Keep tests for what the adapter adds.
|
|
77
|
+
|
|
78
|
+
## Adapter contracts
|
|
79
|
+
|
|
80
|
+
- **`CommentsAdapter<A>`** (`A`: the editor's anchor). Required: `parse`,
|
|
81
|
+
`serialize`, `label`, `canComment`, `canSendToAgent`. Optional: `location`
|
|
82
|
+
(stored for the agent), `state` (`ok`/`moved`/`detached`/`orphaned`),
|
|
83
|
+
`stateNote`, `reveal`, `notify`, `agentName`, `onModeChange`, `noun`,
|
|
84
|
+
`maxThreads`.
|
|
85
|
+
- **`HistoryAdapter<P>`** (`P`: a loaded preview). `loadPreview(history, n)`
|
|
86
|
+
reads version `n`; optional `notify` and `noun`.
|
|
87
|
+
- **`PresenceAdapter<S>`** (`S`: what the editor publishes besides the
|
|
88
|
+
pointer). `key`, `snapshot`, `parse`, `watch(changed)` (returns an
|
|
89
|
+
unsubscribe), `pointer(event)` (world point or `null`), optional
|
|
90
|
+
`wrotePath`.
|
|
91
|
+
- **`createCollab({ comments, history, adapter })`**. `comments` and `history`
|
|
92
|
+
are a kit controller or an editor's own store of the same shape
|
|
93
|
+
(`CollabComments`, `CollabHistory`). `CollabAdapter`: `onSurface`,
|
|
94
|
+
`readOnly`, optional `showSurface`, `commentOnSelection` and `pageButton`.
|
|
95
|
+
- **`FindAdapter<M>`** (`M`: a match). `search(query)`, `reveal(match, index,
|
|
96
|
+
count)`, `onClose`, optional `start(matches)` and `noResults`. Stepping
|
|
97
|
+
searches again, so matches follow edits. For highlights, call
|
|
98
|
+
`highlightText(doc, root, query, ownerOf, occurrence)`; `ownerOf(parent)`
|
|
99
|
+
says which element owns a text node (its key and whether it is the current
|
|
100
|
+
match) or `null` to skip it.
|
|
101
|
+
- **`SystemsLoaderAdapter<R, S>`**. `artifact()`, `records()`,
|
|
102
|
+
`subscribe(listener)`, `read(record, tokens)` and `loaded(result)`. Call
|
|
103
|
+
`start()` once the session is connected. The loader reloads when the
|
|
104
|
+
installed records change or a copy's `tokens.json` changes, and drops reads
|
|
105
|
+
that a newer reload overtook.
|
|
106
|
+
- **Session**. `connectHost(['artifact', 'agent', …])` installs the page
|
|
107
|
+
provider, then connects the user, the named capabilities and the Shell, and
|
|
108
|
+
returns `{ viewer, abilities, shell, ...capabilities }`. Keep the result in
|
|
109
|
+
a `sessionSlot()`. A page that connected to the Shell before the session
|
|
110
|
+
(to report early) passes that connection as `connectHost(names, shell)`.
|
|
111
|
+
- **Shell**. Use `chromeReporter(shell, build)` when the editor subscribes
|
|
112
|
+
its own stores and handles commands itself (design, slides, design
|
|
113
|
+
system). Use `createShellBridge(() => shell)` when several modules
|
|
114
|
+
contribute parts of the report and register command handlers
|
|
115
|
+
(whiteboard).
|
|
116
|
+
- **Save state**. Report `saved: 'saving'` for edits that are on their way,
|
|
117
|
+
including edits still waiting out the write debounce (a live-store `dirty`
|
|
118
|
+
status); the Shell shows "Saving…" only once it lasts half a second.
|
|
119
|
+
`unsaved` is for edits the page could not save, and the Shell shows it as a
|
|
120
|
+
failure ("Couldn't save", with a retry when `save_now` is enabled).
|
|
121
|
+
- **Opening**. A page that needs a moment after it connects to draw its first
|
|
122
|
+
view (the whiteboard, restoring its camera and loading its board) reports
|
|
123
|
+
`ready: false` as early as it can, and `ready: true` once that view is up.
|
|
124
|
+
The Shell keeps its loading cover over the page until then, for at most
|
|
125
|
+
`CHROME_READY_TIMEOUT_MS` (10 s), and ignores `ready: false` once the page
|
|
126
|
+
has been shown. A page that never sends `ready` shows on its first report.
|
|
127
|
+
- **Downloads**. `saveFile(downloads, name, blob)` returns `{ to: 'host' }`
|
|
128
|
+
or `{ to: 'browser' }`, so the editor can choose its toast.
|
|
129
|
+
|
|
130
|
+
## Left in the editors
|
|
131
|
+
|
|
132
|
+
These look alike but are not shared yet, because they depend on each
|
|
133
|
+
editor's document store, file kinds or look:
|
|
134
|
+
|
|
135
|
+
- `services/sync.ts` (the debounced publish, conflict merge and offline
|
|
136
|
+
retry). The loop has the same shape everywhere, but what is sent, how it is
|
|
137
|
+
acknowledged and when it saves again differ per store.
|
|
138
|
+
- Each editor's `systemFromTokens` and recovery banner.
|
|
139
|
+
- The whiteboard's chrome, find and announcer, and the slides comments
|
|
140
|
+
service. They have their own views and comment semantics.
|
|
141
|
+
- The design system's history and presence, and its markdown, live-props,
|
|
142
|
+
type and comment-anchor helpers. They have no second user yet.
|
|
143
|
+
|
|
144
|
+
Move one into the kit when a second editor needs the same thing.
|
package/package.json
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openartifactsai/editor-kit",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.23.0-rc.0",
|
|
4
|
+
"description": "What every artifact editor shares: collaboration (comments, presence, history), roles and host session, Shell chrome reports, find, recovery stashes, line merge, announcements, chrome primitives and design-system loading.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./src/index.d.ts",
|
|
9
|
+
"default": "./src/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./react": {
|
|
12
|
+
"types": "./src/react.d.ts",
|
|
13
|
+
"default": "./src/react.js"
|
|
14
|
+
},
|
|
15
|
+
"./video-shrink": {
|
|
16
|
+
"types": "./src/video-shrink/index.d.ts",
|
|
17
|
+
"default": "./src/video-shrink/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./video-shrink/notice": {
|
|
20
|
+
"types": "./src/VideoShrinkNotice.d.ts",
|
|
21
|
+
"default": "./src/VideoShrinkNotice.js"
|
|
22
|
+
},
|
|
23
|
+
"./styles.css": "./src/styles.css",
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"src",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"NOTICE"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@base-ui/react": "^1.8.0",
|
|
33
|
+
"@openartifactsai/design-system-core": "0.23.0-rc.0",
|
|
34
|
+
"@openartifactsai/runtime": "0.23.0-rc.0",
|
|
35
|
+
"@openartifactsai/ui": "0.23.0-rc.0",
|
|
36
|
+
"clsx": "^2.1.1",
|
|
37
|
+
"lucide-react": "^1.65.0",
|
|
38
|
+
"mediabunny": "^1.63.0",
|
|
39
|
+
"zustand": "^5.0.10",
|
|
40
|
+
"@fontsource-variable/inter": "^5.3.0"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": "^19.2.4",
|
|
44
|
+
"react-dom": "^19.2.4",
|
|
45
|
+
"tailwindcss": "^4.3.3"
|
|
46
|
+
},
|
|
47
|
+
"peerDependenciesMeta": {
|
|
48
|
+
"tailwindcss": {
|
|
49
|
+
"optional": true
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"license": "Apache-2.0",
|
|
53
|
+
"author": {
|
|
54
|
+
"name": "Jim Liu 宝玉",
|
|
55
|
+
"url": "https://github.com/JimLiu"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/openartifactsai/open-artifacts#readme",
|
|
58
|
+
"repository": {
|
|
59
|
+
"type": "git",
|
|
60
|
+
"url": "git+https://github.com/openartifactsai/open-artifacts.git",
|
|
61
|
+
"directory": "packages/editor-kit"
|
|
62
|
+
},
|
|
63
|
+
"bugs": {
|
|
64
|
+
"url": "https://github.com/openartifactsai/open-artifacts/issues"
|
|
65
|
+
},
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public"
|
|
68
|
+
}
|
|
69
|
+
}
|
package/src/Announcer.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/** The polite live region screen readers hear (`announce.ts`). Render it once per page. */
|
|
3
|
+
import { useAnnouncer } from "./announce.js";
|
|
4
|
+
export function Announcer() {
|
|
5
|
+
const message = useAnnouncer((s) => s.message);
|
|
6
|
+
const serial = useAnnouncer((s) => s.serial);
|
|
7
|
+
return (_jsx("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", className: "sr-only", style: { position: 'absolute', width: 1, height: 1, overflow: 'hidden', clip: 'rect(0 0 0 0)', whiteSpace: 'nowrap' }, children: _jsx("span", { children: message }, serial) }));
|
|
8
|
+
}
|
package/src/FindBar.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The find bar: a search field, "n of m", previous / next and close. Enter
|
|
3
|
+
* goes to the next match, ⇧Enter to the previous one, Escape closes. The
|
|
4
|
+
* editor renders it while find is open and passes its find store's state.
|
|
5
|
+
*/
|
|
6
|
+
import { type ReactNode } from 'react';
|
|
7
|
+
/** Props of {@link FindBar}. */
|
|
8
|
+
export interface FindBarProps {
|
|
9
|
+
/** Label and placeholder of the field ("Find in design"). */
|
|
10
|
+
label: string;
|
|
11
|
+
query: string;
|
|
12
|
+
count: number;
|
|
13
|
+
/** The match shown, or -1. */
|
|
14
|
+
index: number;
|
|
15
|
+
onQuery(query: string): void;
|
|
16
|
+
onStep(delta: 1 | -1): void;
|
|
17
|
+
onClose(): void;
|
|
18
|
+
/** A window event (⌘F while open) that focuses the field again. */
|
|
19
|
+
focusEvent: string;
|
|
20
|
+
/** Classes of the card (placement). */
|
|
21
|
+
className?: string;
|
|
22
|
+
/** Label of the close button (default "Close"). */
|
|
23
|
+
closeLabel?: string;
|
|
24
|
+
/** F3 / ⇧F3 step too. */
|
|
25
|
+
f3?: boolean;
|
|
26
|
+
/** Escape stops at the field (the editor's own Escape handling never sees it). */
|
|
27
|
+
stopEscape?: boolean;
|
|
28
|
+
/** Announce "n of m" through a polite live region. */
|
|
29
|
+
liveStatus?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function FindBar({ label, query, count, index, onQuery, onStep, onClose, focusEvent, className, closeLabel, f3, stopEscape, liveStatus }: FindBarProps): ReactNode;
|
package/src/FindBar.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The find bar: a search field, "n of m", previous / next and close. Enter
|
|
4
|
+
* goes to the next match, ⇧Enter to the previous one, Escape closes. The
|
|
5
|
+
* editor renders it while find is open and passes its find store's state.
|
|
6
|
+
*/
|
|
7
|
+
import { ChevronDown, ChevronUp, Search, X } from 'lucide-react';
|
|
8
|
+
import { isComposingKey } from '@openartifactsai/ui';
|
|
9
|
+
import { useEffect, useRef } from 'react';
|
|
10
|
+
import { Card, ChromeButton, Tip } from "./chrome.js";
|
|
11
|
+
export function FindBar({ label, query, count, index, onQuery, onStep, onClose, focusEvent, className, closeLabel = 'Close', f3, stopEscape, liveStatus }) {
|
|
12
|
+
const input = useRef(null);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const focus = () => {
|
|
15
|
+
input.current?.focus();
|
|
16
|
+
input.current?.select();
|
|
17
|
+
};
|
|
18
|
+
focus();
|
|
19
|
+
window.addEventListener(focusEvent, focus);
|
|
20
|
+
return () => window.removeEventListener(focusEvent, focus);
|
|
21
|
+
}, [focusEvent]);
|
|
22
|
+
const status = !query.trim() ? '' : count === 0 ? 'No results' : `${index + 1} of ${count}`;
|
|
23
|
+
return (_jsxs(Card, { role: "search", className: className, children: [_jsx(Search, { className: "size-4 shrink-0 text-chrome-muted", strokeWidth: 1.5 }), _jsx("input", { ref: input, "aria-label": label, placeholder: label, value: query, className: "w-48 bg-transparent text-[13px] text-chrome-fg outline-none placeholder:text-chrome-muted", onChange: (event) => onQuery(event.target.value), onKeyDown: (event) => {
|
|
24
|
+
if (isComposingKey(event.nativeEvent))
|
|
25
|
+
return;
|
|
26
|
+
if (event.key === 'Enter' || (f3 && event.key === 'F3')) {
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
onStep(event.shiftKey ? -1 : 1);
|
|
29
|
+
}
|
|
30
|
+
else if (event.key === 'Escape') {
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
if (stopEscape)
|
|
33
|
+
event.stopPropagation();
|
|
34
|
+
onClose();
|
|
35
|
+
}
|
|
36
|
+
} }), _jsx("span", { "aria-live": liveStatus ? 'polite' : undefined, className: "min-w-14 text-right text-[12px] tabular-nums text-chrome-muted", children: status }), _jsx(Tip, { label: "Previous match", shortcut: "\u21E7\u21B5", children: _jsx(ChromeButton, { square: true, "aria-label": "Previous match", disabled: count === 0, onClick: () => onStep(-1), children: _jsx(ChevronUp, { className: "size-4", strokeWidth: 1.5 }) }) }), _jsx(Tip, { label: "Next match", shortcut: "\u21B5", children: _jsx(ChromeButton, { square: true, "aria-label": "Next match", disabled: count === 0, onClick: () => onStep(1), children: _jsx(ChevronDown, { className: "size-4", strokeWidth: 1.5 }) }) }), _jsx(Tip, { label: "Close", shortcut: "Esc", children: _jsx(ChromeButton, { square: true, "aria-label": closeLabel, onClick: onClose, children: _jsx(X, { className: "size-4", strokeWidth: 1.5 }) }) })] }));
|
|
37
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A floating toolbar that can fold. With `fold` on, controls that do not fit
|
|
3
|
+
* the strip's width move into a "More tools" card opened from a button at the
|
|
4
|
+
* strip's end (the rules are in `toolbar-fold.ts`). They are the same mounted
|
|
5
|
+
* controls: each lives in a host node that moves, so pressed states, spinners
|
|
6
|
+
* and open popups go with it. On a narrow touch screen the strip does not
|
|
7
|
+
* fold; its row scrolls.
|
|
8
|
+
*
|
|
9
|
+
* Build the strip from {@link FoldGroup}s and {@link FoldDivider}s. Mark the
|
|
10
|
+
* properties / more button `data-fold-more`, a control that must stay on the
|
|
11
|
+
* strip `data-fold-keep`, and the last group `tail`.
|
|
12
|
+
*
|
|
13
|
+
* Arrow keys, Home and End move focus through the strip's and the open
|
|
14
|
+
* card's controls. An editor whose own Escape handling runs first (capturing
|
|
15
|
+
* on the window) leaves alone a press inside {@link FOLD_OWNS_ESCAPE}.
|
|
16
|
+
*/
|
|
17
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
18
|
+
/** The room a card may open into (viewport px). */
|
|
19
|
+
export interface FoldBand {
|
|
20
|
+
top: number;
|
|
21
|
+
bottom: number;
|
|
22
|
+
}
|
|
23
|
+
/** Whether the strip around the caller is folded (its properties button changes icon in the card). */
|
|
24
|
+
export declare function useFolded(): boolean;
|
|
25
|
+
/** Props of {@link FoldGroup}. */
|
|
26
|
+
export interface FoldGroupProps extends HTMLAttributes<HTMLSpanElement> {
|
|
27
|
+
/** The strip's last group (lead control, Delete, properties): it stays on the strip, apart from a `data-fold-more` button. */
|
|
28
|
+
tail?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** A group of related controls; each of its children folds as one item. */
|
|
31
|
+
export declare function FoldGroup({ tail, className, children, ...rest }: FoldGroupProps): ReactNode;
|
|
32
|
+
/** The divider between two groups; it goes when a group next to it empties. */
|
|
33
|
+
export declare function FoldDivider({ className }: {
|
|
34
|
+
className?: string;
|
|
35
|
+
}): ReactNode;
|
|
36
|
+
/** Props of {@link FoldToolbar}. */
|
|
37
|
+
export interface FoldToolbarProps extends HTMLAttributes<HTMLDivElement> {
|
|
38
|
+
/** Fold controls that do not fit into the "More tools" card. */
|
|
39
|
+
fold?: boolean;
|
|
40
|
+
/** Changes with what the strip acts on (the selection): the card closes. */
|
|
41
|
+
foldKey?: unknown;
|
|
42
|
+
/** The room the card may open into; the viewport by default. */
|
|
43
|
+
band?: FoldBand;
|
|
44
|
+
/** Which side of the selection the strip sits on: the card opens on that side. */
|
|
45
|
+
placed?: 'above' | 'below';
|
|
46
|
+
/** The strip's widest (px); the viewport less 16px by default. */
|
|
47
|
+
limit?: number;
|
|
48
|
+
/** Classes of the row that holds the controls (padding, gaps). */
|
|
49
|
+
rowClassName?: string;
|
|
50
|
+
/** Size of the "More tools" button, matching the strip's controls. */
|
|
51
|
+
size?: 'md' | 'lg' | 'xl';
|
|
52
|
+
/** Arrow keys, Home and End move focus along the strip (default on). */
|
|
53
|
+
arrowKeys?: boolean;
|
|
54
|
+
/** Tab inside the strip: return true when it took the focus elsewhere itself. */
|
|
55
|
+
onTabOut?: () => boolean;
|
|
56
|
+
}
|
|
57
|
+
/** A floating toolbar strip that folds what does not fit into a "More tools" card. */
|
|
58
|
+
export declare const FoldToolbar: import("react").ForwardRefExoticComponent<FoldToolbarProps & import("react").RefAttributes<HTMLDivElement>>;
|