@folijs/react 0.3.0 → 0.5.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/CHANGELOG.md +55 -0
- package/dist/FoliCanvas.d.ts +8 -0
- package/dist/FoliCanvas.d.ts.map +1 -1
- package/dist/FoliCanvas.js +9 -4
- package/dist/FoliCanvas.js.map +1 -1
- package/dist/FoliComments.d.ts +22 -0
- package/dist/FoliComments.d.ts.map +1 -0
- package/dist/FoliComments.js +275 -0
- package/dist/FoliComments.js.map +1 -0
- package/dist/FoliEditor.d.ts +12 -1
- package/dist/FoliEditor.d.ts.map +1 -1
- package/dist/FoliEditor.js +6 -4
- package/dist/FoliEditor.js.map +1 -1
- package/dist/FoliToolbar.d.ts +14 -2
- package/dist/FoliToolbar.d.ts.map +1 -1
- package/dist/FoliToolbar.js +537 -14
- package/dist/FoliToolbar.js.map +1 -1
- package/dist/editor.d.ts +7 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +8 -2
- package/dist/editor.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/FoliCanvas.tsx +26 -5
- package/src/FoliComments.tsx +499 -0
- package/src/FoliEditor.tsx +49 -4
- package/src/FoliToolbar.tsx +834 -11
- package/src/editor.tsx +15 -2
- package/src/index.ts +1 -0
- package/styles.css +126 -2
package/src/editor.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
type EditorDocument,
|
|
5
5
|
type EditorState,
|
|
6
6
|
type Plugin,
|
|
7
|
+
type ReviewView,
|
|
7
8
|
} from "@folijs/core";
|
|
8
9
|
import {
|
|
9
10
|
createContext,
|
|
@@ -33,6 +34,12 @@ export interface UseFoliEditorOptions {
|
|
|
33
34
|
initialContent?: EditorDocument | undefined;
|
|
34
35
|
/** Read once, when the editor is created. */
|
|
35
36
|
plugins?: readonly Plugin[] | undefined;
|
|
37
|
+
/** Read once: who edits (tracked changes are made in this name; `createEditor`'s `author`). */
|
|
38
|
+
author?: string | undefined;
|
|
39
|
+
/** Read once: record edits as tracked changes from the start (a `.docx`'s `trackRevisions`). */
|
|
40
|
+
trackChanges?: boolean | undefined;
|
|
41
|
+
/** Read once: how tracked changes show at first (default `markup`). */
|
|
42
|
+
reviewView?: ReviewView | undefined;
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
/**
|
|
@@ -42,8 +49,14 @@ export interface UseFoliEditorOptions {
|
|
|
42
49
|
*/
|
|
43
50
|
export function useFoliEditor(options: UseFoliEditorOptions = {}): Editor {
|
|
44
51
|
const [editor] = useState(() => {
|
|
45
|
-
const { initialContent: document, plugins } = options;
|
|
46
|
-
return createEditor({
|
|
52
|
+
const { initialContent: document, plugins, author, trackChanges, reviewView } = options;
|
|
53
|
+
return createEditor({
|
|
54
|
+
...(document && { document }),
|
|
55
|
+
...(plugins && { plugins }),
|
|
56
|
+
...(author !== undefined && { author }),
|
|
57
|
+
...(trackChanges !== undefined && { trackChanges }),
|
|
58
|
+
...(reviewView !== undefined && { reviewView }),
|
|
59
|
+
});
|
|
47
60
|
});
|
|
48
61
|
return editor;
|
|
49
62
|
}
|
package/src/index.ts
CHANGED
package/styles.css
CHANGED
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
cursor: pointer;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
.foli-menu-item:hover,
|
|
165
|
+
.foli-menu-item:not([aria-disabled="true"]):hover,
|
|
166
166
|
.foli-menu-item:focus-visible {
|
|
167
167
|
background: var(--foli-toolbar-hover);
|
|
168
168
|
}
|
|
@@ -172,6 +172,27 @@
|
|
|
172
172
|
outline-offset: -2px;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/* An item that cannot apply here (the table menu's): shown, focusable, dimmed. */
|
|
176
|
+
.foli-menu-item[aria-disabled="true"] {
|
|
177
|
+
opacity: 0.5;
|
|
178
|
+
cursor: default;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* The table menu's checkbox item: a check before it when on. */
|
|
182
|
+
.foli-menu-item[role="menuitemcheckbox"]::before {
|
|
183
|
+
content: "";
|
|
184
|
+
width: 1em;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.foli-menu-item[role="menuitemcheckbox"][aria-checked="true"]::before {
|
|
188
|
+
/* No accessible name of its own: the item's checked state says it. */
|
|
189
|
+
content: "\2713" / "";
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.foli-table-dialog input {
|
|
193
|
+
flex: 0 0 5em;
|
|
194
|
+
}
|
|
195
|
+
|
|
175
196
|
.foli-menu-swatch {
|
|
176
197
|
width: 16px;
|
|
177
198
|
height: 16px;
|
|
@@ -260,6 +281,104 @@
|
|
|
260
281
|
background: var(--foli-border-color);
|
|
261
282
|
}
|
|
262
283
|
|
|
284
|
+
/* The pages and the comments pane (FoliEditor) side by side. */
|
|
285
|
+
.foli-editor-body {
|
|
286
|
+
display: flex;
|
|
287
|
+
align-items: flex-start;
|
|
288
|
+
background: var(--foli-canvas-background);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.foli-editor-body > .foli-canvas {
|
|
292
|
+
flex: 1 1 auto;
|
|
293
|
+
min-width: 0;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/* Comments pane (FoliComments): threads beside their text. */
|
|
297
|
+
.foli-comments {
|
|
298
|
+
position: relative;
|
|
299
|
+
flex: 0 0 18rem;
|
|
300
|
+
margin: 32px 16px 32px 0;
|
|
301
|
+
color: var(--foli-text-color);
|
|
302
|
+
font:
|
|
303
|
+
13px / 1.4 system-ui,
|
|
304
|
+
sans-serif;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.foli-comments-empty {
|
|
308
|
+
margin: 0;
|
|
309
|
+
opacity: 0.7;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.foli-comment-thread {
|
|
313
|
+
position: absolute;
|
|
314
|
+
inset-inline: 0;
|
|
315
|
+
padding: 8px;
|
|
316
|
+
border: 1px solid var(--foli-border-color);
|
|
317
|
+
border-radius: 6px;
|
|
318
|
+
background: var(--foli-page-background);
|
|
319
|
+
box-shadow: var(--foli-page-shadow);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.foli-comment-thread[data-active],
|
|
323
|
+
.foli-comment-thread:focus-within {
|
|
324
|
+
border-color: var(--foli-focus-ring);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.foli-comment-thread[data-done] {
|
|
328
|
+
opacity: 0.7;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.foli-comment + .foli-comment {
|
|
332
|
+
margin-top: 8px;
|
|
333
|
+
padding-top: 8px;
|
|
334
|
+
border-top: 1px solid var(--foli-border-color);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.foli-comment-meta,
|
|
338
|
+
.foli-comment-text p {
|
|
339
|
+
margin: 0;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.foli-comment-actions {
|
|
343
|
+
display: flex;
|
|
344
|
+
flex-wrap: wrap;
|
|
345
|
+
gap: 4px;
|
|
346
|
+
margin-top: 6px;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.foli-comment-actions button {
|
|
350
|
+
height: 28px;
|
|
351
|
+
padding: 0 8px;
|
|
352
|
+
border: 1px solid var(--foli-border-color);
|
|
353
|
+
border-radius: 4px;
|
|
354
|
+
background: none;
|
|
355
|
+
color: inherit;
|
|
356
|
+
font: inherit;
|
|
357
|
+
cursor: pointer;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.foli-comment-form label {
|
|
361
|
+
display: block;
|
|
362
|
+
margin-top: 6px;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.foli-comment-form textarea {
|
|
366
|
+
box-sizing: border-box;
|
|
367
|
+
width: 100%;
|
|
368
|
+
font: inherit;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.foli-comments :focus-visible {
|
|
372
|
+
outline: 2px solid var(--foli-focus-ring);
|
|
373
|
+
outline-offset: 1px;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/* The text of the comment that has the focus. */
|
|
377
|
+
.foli-content .foli-comment-active {
|
|
378
|
+
outline: 2px solid var(--foli-focus-ring);
|
|
379
|
+
outline-offset: 1px;
|
|
380
|
+
}
|
|
381
|
+
|
|
263
382
|
/*
|
|
264
383
|
* The view prints one sheet per page (size from the document settings); this drops the chrome.
|
|
265
384
|
* Hide the rest of your page in print: anything printed before the pages adds sheets.
|
|
@@ -273,7 +392,12 @@
|
|
|
273
392
|
box-shadow: none;
|
|
274
393
|
}
|
|
275
394
|
.foli-toolbar,
|
|
276
|
-
.foli-link-dialog
|
|
395
|
+
.foli-link-dialog,
|
|
396
|
+
.foli-comments {
|
|
277
397
|
display: none;
|
|
278
398
|
}
|
|
399
|
+
.foli-editor-body {
|
|
400
|
+
display: block;
|
|
401
|
+
background: none;
|
|
402
|
+
}
|
|
279
403
|
}
|