@openleaf-editor/core 0.1.0-beta.2 → 0.1.0-beta.3

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 (95) hide show
  1. package/README.md +115 -0
  2. package/dist/autolink.d.ts.map +1 -1
  3. package/dist/autolink.js +45 -7
  4. package/dist/autolink.js.map +1 -1
  5. package/dist/command-helpers.d.ts +8 -0
  6. package/dist/command-helpers.d.ts.map +1 -0
  7. package/dist/command-helpers.js +36 -0
  8. package/dist/command-helpers.js.map +1 -0
  9. package/dist/commands.d.ts +15 -61
  10. package/dist/commands.d.ts.map +1 -1
  11. package/dist/commands.js +295 -343
  12. package/dist/commands.js.map +1 -1
  13. package/dist/css.d.ts +1 -175
  14. package/dist/css.d.ts.map +1 -1
  15. package/dist/css.js +1 -516
  16. package/dist/css.js.map +1 -1
  17. package/dist/disclosure.d.ts +21 -0
  18. package/dist/disclosure.d.ts.map +1 -0
  19. package/dist/disclosure.js +144 -0
  20. package/dist/disclosure.js.map +1 -0
  21. package/dist/elements.d.ts +2 -0
  22. package/dist/elements.d.ts.map +1 -0
  23. package/dist/elements.js +2 -0
  24. package/dist/elements.js.map +1 -0
  25. package/dist/embed.d.ts +1 -51
  26. package/dist/embed.d.ts.map +1 -1
  27. package/dist/embed.js +1 -115
  28. package/dist/embed.js.map +1 -1
  29. package/dist/errors.d.ts +38 -0
  30. package/dist/errors.d.ts.map +1 -0
  31. package/dist/errors.js +40 -0
  32. package/dist/errors.js.map +1 -0
  33. package/dist/extensions.d.ts +46 -5
  34. package/dist/extensions.d.ts.map +1 -1
  35. package/dist/extensions.js +272 -52
  36. package/dist/extensions.js.map +1 -1
  37. package/dist/formats.d.ts.map +1 -1
  38. package/dist/formats.js +19 -7
  39. package/dist/formats.js.map +1 -1
  40. package/dist/html.d.ts +32 -2
  41. package/dist/html.d.ts.map +1 -1
  42. package/dist/html.js +185 -31
  43. package/dist/html.js.map +1 -1
  44. package/dist/index.d.ts +21 -6
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +32 -6
  47. package/dist/index.js.map +1 -1
  48. package/dist/insert-commands.d.ts +172 -0
  49. package/dist/insert-commands.d.ts.map +1 -0
  50. package/dist/insert-commands.js +560 -0
  51. package/dist/insert-commands.js.map +1 -0
  52. package/dist/isolating-selection.d.ts +41 -0
  53. package/dist/isolating-selection.d.ts.map +1 -0
  54. package/dist/isolating-selection.js +162 -0
  55. package/dist/isolating-selection.js.map +1 -0
  56. package/dist/noneditable.d.ts.map +1 -1
  57. package/dist/noneditable.js +18 -4
  58. package/dist/noneditable.js.map +1 -1
  59. package/dist/plugins.d.ts +20 -2
  60. package/dist/plugins.d.ts.map +1 -1
  61. package/dist/plugins.js +27 -2
  62. package/dist/plugins.js.map +1 -1
  63. package/dist/preserve.d.ts +48 -17
  64. package/dist/preserve.d.ts.map +1 -1
  65. package/dist/preserve.js +214 -43
  66. package/dist/preserve.js.map +1 -1
  67. package/dist/schema.d.ts +15 -0
  68. package/dist/schema.d.ts.map +1 -1
  69. package/dist/schema.js +157 -28
  70. package/dist/schema.js.map +1 -1
  71. package/dist/structure.d.ts +32 -0
  72. package/dist/structure.d.ts.map +1 -1
  73. package/dist/structure.js +53 -10
  74. package/dist/structure.js.map +1 -1
  75. package/dist/tables.d.ts +47 -1
  76. package/dist/tables.d.ts.map +1 -1
  77. package/dist/tables.js +417 -40
  78. package/dist/tables.js.map +1 -1
  79. package/dist/testing.d.ts +3 -0
  80. package/dist/testing.d.ts.map +1 -0
  81. package/dist/testing.js +3 -0
  82. package/dist/testing.js.map +1 -0
  83. package/dist/tokens.d.ts +8 -0
  84. package/dist/tokens.d.ts.map +1 -1
  85. package/dist/tokens.js +54 -6
  86. package/dist/tokens.js.map +1 -1
  87. package/dist/url.d.ts +1 -25
  88. package/dist/url.d.ts.map +1 -1
  89. package/dist/url.js +1 -77
  90. package/dist/url.js.map +1 -1
  91. package/dist/visual-aids.d.ts +11 -1
  92. package/dist/visual-aids.d.ts.map +1 -1
  93. package/dist/visual-aids.js +124 -36
  94. package/dist/visual-aids.js.map +1 -1
  95. package/package.json +15 -1
@@ -0,0 +1,172 @@
1
+ import type { Command, EditorState } from 'prosemirror-state';
2
+ import { type ImageAlign } from './tokens.js';
3
+ export interface LinkAttrs {
4
+ href: string;
5
+ title?: string | null;
6
+ target?: string | null;
7
+ rel?: string | null;
8
+ id?: string | null;
9
+ }
10
+ /**
11
+ * Apply or update a link across the selection.
12
+ *
13
+ * Removes any existing link first: without that, updating a link that only
14
+ * partially overlaps the selection leaves two adjacent links with different
15
+ * hrefs, which looks fine and is wrong.
16
+ *
17
+ * Declines an href the schema would refuse. The parse rule at `schema.ts:541`
18
+ * already rejects `javascript:`, but only on the way *in* -- so without this
19
+ * check the hostile href lives in the document, serializes into the bound
20
+ * textarea and is submitted. It disappears on the next parse, one round trip
21
+ * after the server stored it, which is the wrong side of the write.
22
+ */
23
+ export declare function setLink(attrs: LinkAttrs): Command;
24
+ export declare const unsetLink: Command;
25
+ export interface ImageAttrs {
26
+ src: string;
27
+ alt?: string | null;
28
+ title?: string | null;
29
+ width?: string | null;
30
+ height?: string | null;
31
+ align?: ImageAlign | null;
32
+ className?: string | null;
33
+ /**
34
+ * When present, the image is wrapped in `<figure>` with this caption.
35
+ * An empty string still wraps: a figure with no caption text is how an
36
+ * author says "this will have a caption" without writing one yet.
37
+ */
38
+ caption?: string | null;
39
+ }
40
+ /**
41
+ * Insert an image, optionally wrapped in a captioned `<figure>`.
42
+ *
43
+ * Declines a `src` the schema would refuse, for the same reason `setLink` does:
44
+ * the parse rule only guards the way in, so an unchecked `javascript:` src is
45
+ * live in the document and submitted with the form before anything strips it.
46
+ */
47
+ export declare function insertImage(attrs: ImageAttrs): Command;
48
+ export interface SelectedImage {
49
+ /** Document position of the `image` node, for `setNodeMarkup`. */
50
+ pos: number;
51
+ src: string;
52
+ alt: string | null;
53
+ title: string | null;
54
+ width: string | null;
55
+ height: string | null;
56
+ align: ImageAlign | null;
57
+ className: string | null;
58
+ /**
59
+ * Caption text when the image lives in a `<figure>`, including `''` for a
60
+ * figure whose figcaption is still empty. `null` means there is no figure.
61
+ */
62
+ caption: string | null;
63
+ }
64
+ /**
65
+ * The image the selection is on, or null.
66
+ *
67
+ * A `NodeSelection` on `image` counts, and so does one on a `figure` that
68
+ * contains an image -- clicking the picture and clicking the figure around it
69
+ * are the same author intent. A caret beside an image is not: treating that as
70
+ * a selection would let the dialog retarget a neighbour when the author meant
71
+ * to insert, the same trap `selectedMedia` refuses.
72
+ */
73
+ export declare function selectedImage(state: EditorState): SelectedImage | null;
74
+ /**
75
+ * Update the selected image in place.
76
+ *
77
+ * `setNodeMarkup` rather than replace-with-a-new-node: the surrounding
78
+ * `<figure>`, the author's `class`, and dimensions the dialog does not edit
79
+ * all survive a save that only changed the address or the alt text. Replacing
80
+ * the `NodeSelection` dropped every one of those, including the figcaption.
81
+ *
82
+ * Attributes omitted from `attrs` (`undefined`) stay as they were. `null` is
83
+ * an explicit clear -- except `src`, which must be a storeable address.
84
+ */
85
+ export declare function updateImage(attrs: ImageAttrs): Command;
86
+ export declare function insertText(text: string): Command;
87
+ export declare const insertNonBreakingSpace: Command;
88
+ export declare const insertPageBreak: Command;
89
+ export declare function insertNamedAnchor(id: string): Command;
90
+ export declare function setHeadingId(id: string | null): Command;
91
+ export declare function insertDetails(summaryText?: string): Command;
92
+ /**
93
+ * One `<source>` row from the insert-media dialog.
94
+ *
95
+ * `type` is the MIME hint a browser uses to pick between alternatives without
96
+ * downloading them. It is optional because a dialog cannot always know it, and
97
+ * a `<source>` with no type is still a working source.
98
+ */
99
+ export interface MediaSource {
100
+ src: string;
101
+ type?: string | null;
102
+ }
103
+ export interface MediaAttrs {
104
+ /**
105
+ * Optional, because a player may carry its addresses in `sources` instead --
106
+ * the source-only shape `mediaAttrs` accepts on parse. One or the other must
107
+ * be present; a player with neither has nothing to play.
108
+ */
109
+ src?: string | null;
110
+ title?: string | null;
111
+ width?: string | null;
112
+ height?: string | null;
113
+ /**
114
+ * Omitted means different things on the two paths, deliberately. Inserting a
115
+ * player with no opinion gets controls, because a player nobody can start is
116
+ * not much of one. Updating one with no opinion changes nothing, because the
117
+ * caller did not ask to.
118
+ */
119
+ controls?: boolean;
120
+ poster?: string | null;
121
+ allow?: string | null;
122
+ allowfullscreen?: boolean;
123
+ /**
124
+ * Alternative addresses, stored as the `<source>` children of the player.
125
+ *
126
+ * Authoritative for `<source>` on an update: what is passed replaces what is
127
+ * there. Other furniture -- `<track>` captions -- is carried through, so a
128
+ * caller that cannot see them cannot delete them.
129
+ */
130
+ sources?: readonly MediaSource[];
131
+ }
132
+ export declare function insertVideo(attrs: MediaAttrs): Command;
133
+ export declare function insertAudio(attrs: MediaAttrs): Command;
134
+ export interface SelectedMedia {
135
+ kind: 'video' | 'audio' | 'iframe';
136
+ /** Document position of the node, for `setNodeMarkup`. */
137
+ pos: number;
138
+ src: string | null;
139
+ title: string | null;
140
+ width: string | null;
141
+ height: string | null;
142
+ controls: boolean;
143
+ poster: string | null;
144
+ /** Alternative addresses read back out of the stored `<source>` children. */
145
+ sources: MediaSource[];
146
+ }
147
+ /**
148
+ * The media node the selection is on, or null.
149
+ *
150
+ * Only a `NodeSelection` counts. A caret beside a player is not a selection of
151
+ * it, and treating it as one would let the dialog silently retarget: the author
152
+ * clicks away, opens the dialog expecting to insert, and edits the node they
153
+ * had selected a moment ago instead.
154
+ */
155
+ export declare function selectedMedia(state: EditorState): SelectedMedia | null;
156
+ /**
157
+ * Update the selected media node in place.
158
+ *
159
+ * `setNodeMarkup` rather than replace-with-a-new-node: the position and the
160
+ * selection both survive, so the player the author was editing is still the
161
+ * selected one afterwards and a second edit does not have to find it again.
162
+ */
163
+ export declare function updateMedia(attrs: MediaAttrs): Command;
164
+ export declare function insertIframe(attrs: MediaAttrs): Command;
165
+ /**
166
+ * Parse HTML against the live schema and insert it.
167
+ *
168
+ * Used by the snippet picker. The HTML still goes through the same parse
169
+ * pipeline as stored content, so a snippet cannot smuggle in a `<script>`.
170
+ */
171
+ export declare function insertHtml(html: string): Command;
172
+ //# sourceMappingURL=insert-commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert-commands.d.ts","sourceRoot":"","sources":["../src/insert-commands.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAM7D,OAAO,EAA8C,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AASzF,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CA0BjD;AAED,eAAO,MAAM,SAAS,EAAE,OAYvB,CAAA;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,KAAK,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAkCtD;AAED,MAAM,WAAW,aAAa;IAC5B,kEAAkE;IAClE,GAAG,EAAE,MAAM,C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