foldkit-mixins-richtext 0.8.0 → 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.
Files changed (2) hide show
  1. package/README.md +52 -12
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -33,7 +33,45 @@ view owns its elements; the two share the rules, such as `markActive`.
33
33
 
34
34
  In the snippets, `model`, `h`, `Message`, and `edited` are the application's, as in
35
35
  `foldkit-richtext-dom`'s editor; a name such as `DraftedLink` is one of its own Message
36
- constructors.
36
+ constructors, and `EditorMessage` is the editor's own Message.
37
+
38
+ <!-- docs-check
39
+ import { Schema } from 'effect'
40
+ import type { HtmlBuilder, KeyboardModifiers } from 'foldkit/html'
41
+ import { defineMessageUnion } from 'foldkit/message'
42
+ import * as RichText from 'foldkit-richtext'
43
+ import { Message as EditorMessage, type EditorEvent } from 'foldkit-richtext-dom/editor'
44
+ import type { EditorState } from 'foldkit-richtext-dom/editor-bundle'
45
+ import type { SourceSession } from 'foldkit-richtext-markdown'
46
+ const Message = defineMessageUnion({
47
+ GotEditor: { message: EditorMessage },
48
+ DraftedLink: { href: Schema.String },
49
+ CopiedCode: { node: RichText.NodeId },
50
+ ChoseCommand: { event: EditorMessage },
51
+ ChangedPalette: { query: Schema.String, index: Schema.Number },
52
+ ClosedPalette: {},
53
+ DraftedSource: { draft: Schema.String },
54
+ MovedInSource: { caret: Schema.Number },
55
+ LeftSource: {},
56
+ })
57
+ type Message = typeof Message.Type
58
+ const { DraftedLink, DraftedSource, MovedInSource, LeftSource } = Message
59
+ const edited = (message: EditorEvent): Message => Message.GotEditor({ message })
60
+ declare const model: {
61
+ readonly document: RichText.Document
62
+ readonly editor: EditorState
63
+ readonly linkDraft: string
64
+ readonly palette: { readonly query: string; readonly index: number } | null
65
+ readonly source: SourceSession | null
66
+ }
67
+ declare const h: HtmlBuilder<Message>
68
+ declare const document: RichText.Document
69
+ declare const selection: RichText.Selection | null
70
+ declare const storedMarks: ReadonlyArray<string> | null
71
+ declare const modifiers: KeyboardModifiers
72
+ declare const code: RichText.Block
73
+ const ArticleKit = RichText.kit({ nodes: [RichText.block('Paragraph')], marks: [RichText.Bold] })
74
+ -->
37
75
 
38
76
  ## Install
39
77
 
@@ -57,7 +95,7 @@ const Toolbar = markToolbar<Message>().pipe(
57
95
  Toolbar(
58
96
  {
59
97
  state: { document, selection, storedMarks },
60
- toggled: mark => edited(Message.ToggledMark({ mark })),
98
+ toggled: mark => edited(EditorMessage.ToggledMark({ mark })),
61
99
  },
62
100
  h,
63
101
  )
@@ -460,16 +498,18 @@ editor:
460
498
  ```ts
461
499
  import { sourceEditor } from 'foldkit-mixins-richtext'
462
500
 
463
- sourceEditor<Message>()(
464
- {
465
- session: model.source,
466
- document: model.document,
467
- drafted: draft => DraftedSource({ draft }),
468
- moved: caret => MovedInSource({ caret }),
469
- done: LeftSource(),
470
- },
471
- h,
472
- )
501
+ model.source === null
502
+ ? h.empty
503
+ : sourceEditor<Message>()(
504
+ {
505
+ session: model.source,
506
+ document: model.document,
507
+ drafted: draft => DraftedSource({ draft }),
508
+ moved: caret => MovedInSource({ caret }),
509
+ done: LeftSource(),
510
+ },
511
+ h,
512
+ )
473
513
  ```
474
514
 
475
515
  - **The text area** holds the draft and sends `drafted` as it changes. When drawn it takes focus
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldkit-mixins-richtext",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "The rich-text editor's chrome, drawn through Mixins slots.",
5
5
  "keywords": [
6
6
  "foldkit",
@@ -39,12 +39,12 @@
39
39
  "LICENSE"
40
40
  ],
41
41
  "dependencies": {
42
- "foldkit-media": "0.6.0",
43
- "foldkit-richtext": "0.8.0",
44
- "foldkit-mixins": "0.23.0",
45
- "foldkit-primitives": "0.18.0",
46
- "foldkit-richtext-dom": "0.9.0",
47
- "foldkit-richtext-markdown": "0.6.0"
42
+ "foldkit-media": "0.8.0",
43
+ "foldkit-primitives": "0.20.0",
44
+ "foldkit-mixins": "0.25.0",
45
+ "foldkit-richtext": "0.10.0",
46
+ "foldkit-richtext-markdown": "0.8.0",
47
+ "foldkit-richtext-dom": "0.11.0"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "effect": "^4.1.0",