@openleaf-editor/plugins-insert 0.1.0-beta.2
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/README.md +54 -0
- package/dist/glyphs.d.ts +10 -0
- package/dist/glyphs.d.ts.map +1 -0
- package/dist/glyphs.js +78 -0
- package/dist/glyphs.js.map +1 -0
- package/dist/grid.d.ts +10 -0
- package/dist/grid.d.ts.map +1 -0
- package/dist/grid.js +117 -0
- package/dist/grid.js.map +1 -0
- package/dist/icons.d.ts +2 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +12 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +130 -0
- package/dist/index.js.map +1 -0
- package/dist/openleaf-insert.css +51 -0
- package/dist/prompts.d.ts +6 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +120 -0
- package/dist/prompts.js.map +1 -0
- package/dist/resize.d.ts +3 -0
- package/dist/resize.d.ts.map +1 -0
- package/dist/resize.js +110 -0
- package/dist/resize.js.map +1 -0
- package/dist/snippets.d.ts +8 -0
- package/dist/snippets.d.ts.map +1 -0
- package/dist/snippets.js +8 -0
- package/dist/snippets.js.map +1 -0
- package/dist/styles.d.ts +2 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +54 -0
- package/dist/styles.js.map +1 -0
- package/package.json +41 -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/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# `@openleaf-editor/plugins-insert`
|
|
2
|
+
|
|
3
|
+
Insert and structure tools for [OpenLeaf](https://github.com/PeytonNowlin/openleaf): media embeds, collapsible sections, named anchors, a character map, emoji, date and time, page breaks, snippets, and image resize handles.
|
|
4
|
+
|
|
5
|
+
The matching **schema nodes live in `@openleaf-editor/core`**, so stored `<video>`, `<iframe>`, `<details>` and `<figure>` round-trip whether or not this package is loaded. This bundle is the editing chrome.
|
|
6
|
+
|
|
7
|
+
Iframes are stored only when their `src` is an `https:` URL on a known player host (`youtube.com/embed`, `player.vimeo.com/video`, and the rest of the allowlist). Arbitrary iframes are still dropped.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @openleaf-editor/element@beta @openleaf-editor/plugins-insert@beta
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import '@openleaf-editor/element'
|
|
17
|
+
import { installInsertTools } from '@openleaf-editor/plugins-insert'
|
|
18
|
+
|
|
19
|
+
installInsertTools({
|
|
20
|
+
snippets: [{ id: 'byline', title: 'Byline', html: '<p><em>Staff writer</em></p>' }],
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Installing does **not** rearrange the toolbar. Name the items you want:
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<openleaf-editor
|
|
28
|
+
toolbar="bold italic | link image media details | charmap emoji datetime pagebreak nbsp | source"
|
|
29
|
+
></openleaf-editor>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Shared file picker and lists
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import {
|
|
36
|
+
registerFilePicker,
|
|
37
|
+
registerLinkList,
|
|
38
|
+
registerImageList,
|
|
39
|
+
registerImageClasses,
|
|
40
|
+
} from '@openleaf-editor/element'
|
|
41
|
+
|
|
42
|
+
registerFilePicker(async ({ kind }) => {
|
|
43
|
+
const url = await openCmsLibrary(kind)
|
|
44
|
+
return url ? { url } : null
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
registerLinkList([
|
|
48
|
+
{ title: 'Home', value: '/' },
|
|
49
|
+
{ title: 'About', value: '/about' },
|
|
50
|
+
])
|
|
51
|
+
|
|
52
|
+
registerImageList([{ title: 'Hero', value: '/media/hero.jpg' }])
|
|
53
|
+
registerImageClasses(['align-left', 'full-width'])
|
|
54
|
+
```
|
package/dist/glyphs.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Common typographic characters, named for the grid's accessible labels. */
|
|
2
|
+
export declare const CHARACTERS: ReadonlyArray<{
|
|
3
|
+
char: string;
|
|
4
|
+
name: string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const EMOJI: ReadonlyArray<{
|
|
7
|
+
char: string;
|
|
8
|
+
name: string;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=glyphs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glyphs.d.ts","sourceRoot":"","sources":["../src/glyphs.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,eAAO,MAAM,UAAU,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAyCpE,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAiC/D,CAAA"}
|
package/dist/glyphs.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** Common typographic characters, named for the grid's accessible labels. */
|
|
2
|
+
export const CHARACTERS = [
|
|
3
|
+
{ char: '©', name: 'Copyright' },
|
|
4
|
+
{ char: '®', name: 'Registered' },
|
|
5
|
+
{ char: '™', name: 'Trademark' },
|
|
6
|
+
{ char: '§', name: 'Section' },
|
|
7
|
+
{ char: '¶', name: 'Pilcrow' },
|
|
8
|
+
{ char: '†', name: 'Dagger' },
|
|
9
|
+
{ char: '‡', name: 'Double dagger' },
|
|
10
|
+
{ char: '•', name: 'Bullet' },
|
|
11
|
+
{ char: '…', name: 'Ellipsis' },
|
|
12
|
+
{ char: '–', name: 'En dash' },
|
|
13
|
+
{ char: '—', name: 'Em dash' },
|
|
14
|
+
{ char: '‘', name: 'Left single quote' },
|
|
15
|
+
{ char: '’', name: 'Right single quote' },
|
|
16
|
+
{ char: '“', name: 'Left double quote' },
|
|
17
|
+
{ char: '”', name: 'Right double quote' },
|
|
18
|
+
{ char: '«', name: 'Left guillemet' },
|
|
19
|
+
{ char: '»', name: 'Right guillemet' },
|
|
20
|
+
{ char: '€', name: 'Euro' },
|
|
21
|
+
{ char: '£', name: 'Pound' },
|
|
22
|
+
{ char: '¥', name: 'Yen' },
|
|
23
|
+
{ char: '¢', name: 'Cent' },
|
|
24
|
+
{ char: '°', name: 'Degree' },
|
|
25
|
+
{ char: '±', name: 'Plus minus' },
|
|
26
|
+
{ char: '×', name: 'Multiply' },
|
|
27
|
+
{ char: '÷', name: 'Divide' },
|
|
28
|
+
{ char: '≠', name: 'Not equal' },
|
|
29
|
+
{ char: '≈', name: 'Almost equal' },
|
|
30
|
+
{ char: '≤', name: 'Less or equal' },
|
|
31
|
+
{ char: '≥', name: 'Greater or equal' },
|
|
32
|
+
{ char: 'µ', name: 'Micro' },
|
|
33
|
+
{ char: '∞', name: 'Infinity' },
|
|
34
|
+
{ char: '←', name: 'Left arrow' },
|
|
35
|
+
{ char: '→', name: 'Right arrow' },
|
|
36
|
+
{ char: '↑', name: 'Up arrow' },
|
|
37
|
+
{ char: '↓', name: 'Down arrow' },
|
|
38
|
+
{ char: '½', name: 'One half' },
|
|
39
|
+
{ char: '¼', name: 'One quarter' },
|
|
40
|
+
{ char: '¾', name: 'Three quarters' },
|
|
41
|
+
{ char: 'á', name: 'a acute' },
|
|
42
|
+
{ char: 'é', name: 'e acute' },
|
|
43
|
+
];
|
|
44
|
+
export const EMOJI = [
|
|
45
|
+
{ char: '😀', name: 'Grinning' },
|
|
46
|
+
{ char: '😃', name: 'Smiling' },
|
|
47
|
+
{ char: '😄', name: 'Smile' },
|
|
48
|
+
{ char: '😁', name: 'Beaming' },
|
|
49
|
+
{ char: '😅', name: 'Sweat smile' },
|
|
50
|
+
{ char: '😂', name: 'Tears of joy' },
|
|
51
|
+
{ char: '😉', name: 'Winking' },
|
|
52
|
+
{ char: '😊', name: 'Blush' },
|
|
53
|
+
{ char: '😍', name: 'Heart eyes' },
|
|
54
|
+
{ char: '😘', name: 'Kiss' },
|
|
55
|
+
{ char: '😎', name: 'Sunglasses' },
|
|
56
|
+
{ char: '😢', name: 'Crying' },
|
|
57
|
+
{ char: '😭', name: 'Loudly crying' },
|
|
58
|
+
{ char: '😡', name: 'Angry' },
|
|
59
|
+
{ char: '👍', name: 'Thumbs up' },
|
|
60
|
+
{ char: '👎', name: 'Thumbs down' },
|
|
61
|
+
{ char: '👏', name: 'Clapping' },
|
|
62
|
+
{ char: '🙏', name: 'Folded hands' },
|
|
63
|
+
{ char: '💪', name: 'Flexed biceps' },
|
|
64
|
+
{ char: '🔥', name: 'Fire' },
|
|
65
|
+
{ char: '✨', name: 'Sparkles' },
|
|
66
|
+
{ char: '⭐', name: 'Star' },
|
|
67
|
+
{ char: '❤️', name: 'Red heart' },
|
|
68
|
+
{ char: '💔', name: 'Broken heart' },
|
|
69
|
+
{ char: '✅', name: 'Check mark' },
|
|
70
|
+
{ char: '❌', name: 'Cross mark' },
|
|
71
|
+
{ char: '⚠️', name: 'Warning' },
|
|
72
|
+
{ char: '🎉', name: 'Party' },
|
|
73
|
+
{ char: '📌', name: 'Pin' },
|
|
74
|
+
{ char: '💡', name: 'Light bulb' },
|
|
75
|
+
{ char: '📝', name: 'Memo' },
|
|
76
|
+
{ char: '🔗', name: 'Link' },
|
|
77
|
+
];
|
|
78
|
+
//# sourceMappingURL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AAE;IAChC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE;IACpC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE;IACrC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE;IAC5B,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE;IAC/B,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE;IAC3B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE;IACjC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE;IACpC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE;IACjC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE;IACjC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;IAC/B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE;IAC7B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE;IAC3B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE;IAClC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE;IAC5B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE;CAC7B,CAAA"}
|
package/dist/grid.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ToolbarContext, type ToolbarControl } from '@openleaf-editor/ui';
|
|
2
|
+
export declare function buildGlyphPicker(ctx: ToolbarContext, options: {
|
|
3
|
+
label: string;
|
|
4
|
+
icon: string;
|
|
5
|
+
items: ReadonlyArray<{
|
|
6
|
+
char: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}>;
|
|
9
|
+
}): ToolbarControl;
|
|
10
|
+
//# sourceMappingURL=grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../src/grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAO3F,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,cAAc,EACnB,OAAO,EAAE;IACP,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACrD,GACA,cAAc,CAkHhB"}
|
package/dist/grid.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { iconElement } from '@openleaf-editor/ui';
|
|
2
|
+
import { insertText } from '@openleaf-editor/core';
|
|
3
|
+
const SUPPORTS_POPOVER = typeof HTMLElement !== 'undefined' && 'popover' in HTMLElement.prototype;
|
|
4
|
+
export function buildGlyphPicker(ctx, options) {
|
|
5
|
+
const { view, host } = ctx;
|
|
6
|
+
const doc = host.ownerDocument;
|
|
7
|
+
const wrap = doc.createElement('div');
|
|
8
|
+
const trigger = doc.createElement('button');
|
|
9
|
+
trigger.type = 'button';
|
|
10
|
+
trigger.className = 'ol-btn';
|
|
11
|
+
trigger.dataset['olId'] = options.label;
|
|
12
|
+
trigger.setAttribute('aria-label', options.label);
|
|
13
|
+
trigger.setAttribute('aria-haspopup', 'true');
|
|
14
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
15
|
+
trigger.appendChild(iconElement(options.icon, doc));
|
|
16
|
+
const grid = doc.createElement('div');
|
|
17
|
+
grid.className = 'ol-insert-grid';
|
|
18
|
+
grid.setAttribute('role', 'menu');
|
|
19
|
+
grid.setAttribute('aria-label', options.label);
|
|
20
|
+
if (SUPPORTS_POPOVER)
|
|
21
|
+
grid.setAttribute('popover', 'manual');
|
|
22
|
+
for (const item of options.items) {
|
|
23
|
+
const button = doc.createElement('button');
|
|
24
|
+
button.type = 'button';
|
|
25
|
+
button.textContent = item.char;
|
|
26
|
+
button.setAttribute('aria-label', item.name);
|
|
27
|
+
button.title = item.name;
|
|
28
|
+
button.addEventListener('click', () => {
|
|
29
|
+
insertText(item.char)(view.state, view.dispatch, view);
|
|
30
|
+
close();
|
|
31
|
+
view.focus();
|
|
32
|
+
});
|
|
33
|
+
grid.appendChild(button);
|
|
34
|
+
}
|
|
35
|
+
wrap.appendChild(trigger);
|
|
36
|
+
if (!SUPPORTS_POPOVER)
|
|
37
|
+
wrap.appendChild(grid);
|
|
38
|
+
else
|
|
39
|
+
doc.body.appendChild(grid);
|
|
40
|
+
const isOpen = () => SUPPORTS_POPOVER ? grid.matches(':popover-open') : !grid.hidden;
|
|
41
|
+
const close = () => {
|
|
42
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
43
|
+
if (!SUPPORTS_POPOVER) {
|
|
44
|
+
grid.hidden = true;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// Guarded: hidePopover() throws on an element that is not showing, and
|
|
48
|
+
// destroy() closes whether or not the picker was ever opened.
|
|
49
|
+
if (grid.matches(':popover-open')) {
|
|
50
|
+
;
|
|
51
|
+
grid.hidePopover();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Anchor the grid under its trigger, and keep it on screen.
|
|
56
|
+
*
|
|
57
|
+
* The popover path needs this as much as the fallback does: UA styles for
|
|
58
|
+
* `[popover]` are `position: fixed; inset: 0; margin: auto`, which centres the
|
|
59
|
+
* panel in the viewport rather than putting it under the button that opened
|
|
60
|
+
* it. Measured after showing, because a hidden element has no size to clamp.
|
|
61
|
+
*/
|
|
62
|
+
const place = () => {
|
|
63
|
+
const trigger_ = trigger.getBoundingClientRect();
|
|
64
|
+
const win = doc.defaultView;
|
|
65
|
+
const viewWidth = win?.innerWidth ?? 0;
|
|
66
|
+
const viewHeight = win?.innerHeight ?? 0;
|
|
67
|
+
grid.style.position = 'fixed';
|
|
68
|
+
grid.style.margin = '0';
|
|
69
|
+
const box = grid.getBoundingClientRect();
|
|
70
|
+
const left = Math.max(4, Math.min(trigger_.left, viewWidth - box.width - 4));
|
|
71
|
+
// Flipped above the trigger when there is no room below it.
|
|
72
|
+
const below = trigger_.bottom + 4;
|
|
73
|
+
const top = below + box.height > viewHeight ? Math.max(4, trigger_.top - box.height - 4) : below;
|
|
74
|
+
grid.style.left = `${Math.round(left)}px`;
|
|
75
|
+
grid.style.top = `${Math.round(top)}px`;
|
|
76
|
+
};
|
|
77
|
+
const open = () => {
|
|
78
|
+
trigger.setAttribute('aria-expanded', 'true');
|
|
79
|
+
if (!SUPPORTS_POPOVER)
|
|
80
|
+
grid.hidden = false;
|
|
81
|
+
else if (!grid.matches(':popover-open')) {
|
|
82
|
+
;
|
|
83
|
+
grid.showPopover();
|
|
84
|
+
}
|
|
85
|
+
place();
|
|
86
|
+
grid.querySelector('button')?.focus();
|
|
87
|
+
};
|
|
88
|
+
// `hidden` is the fallback path's only lever. On the popover path the popover
|
|
89
|
+
// state is what closes the grid, and leaving `hidden` set as well would fight
|
|
90
|
+
// the stylesheet rule that implements it -- showPopover() would open a grid
|
|
91
|
+
// that `[hidden]` still keeps at display:none.
|
|
92
|
+
if (!SUPPORTS_POPOVER)
|
|
93
|
+
grid.hidden = true;
|
|
94
|
+
trigger.addEventListener('click', () => {
|
|
95
|
+
if (isOpen())
|
|
96
|
+
close();
|
|
97
|
+
else
|
|
98
|
+
open();
|
|
99
|
+
});
|
|
100
|
+
grid.addEventListener('keydown', (event) => {
|
|
101
|
+
if (event.key === 'Escape') {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
close();
|
|
104
|
+
trigger.focus();
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
el: wrap,
|
|
109
|
+
update: (_state) => undefined,
|
|
110
|
+
destroy: () => {
|
|
111
|
+
close();
|
|
112
|
+
if (SUPPORTS_POPOVER)
|
|
113
|
+
grid.remove();
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=grid.js.map
|
package/dist/grid.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../src/grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA4C,MAAM,qBAAqB,CAAA;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAGlD,MAAM,gBAAgB,GACpB,OAAO,WAAW,KAAK,WAAW,IAAI,SAAS,IAAI,WAAW,CAAC,SAAS,CAAA;AAE1E,MAAM,UAAU,gBAAgB,CAC9B,GAAmB,EACnB,OAIC;IAED,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,GAAG,CAAA;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAA;IAC9B,MAAM,IAAI,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAErC,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC3C,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAA;IACvB,OAAO,CAAC,SAAS,GAAG,QAAQ,CAAA;IAC5B,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAA;IACvC,OAAO,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;IACjD,OAAO,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAA;IAC7C,OAAO,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;IAC9C,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAA;IAEnD,MAAM,IAAI,GA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,CAAA;QACjB,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO;QACL,EAAE,EAAE,IAAI;QACR,MAAM,EAAE,CAAC,MAAmB,EAAE,EAAE,CAAC,SAAS;QAC1C,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,EAAE,CAAA;YACP,IAAI,gBAAgB;gBAAE,IAAI,CAAC,MAAM,EAAE,CAAA;QACrC,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/icons.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../src/icons.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAU/C,CAAA"}
|
package/dist/icons.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const INSERT_ICONS = {
|
|
2
|
+
media: 'M4 6h16v12H4zM10 9l6 3-6 3z',
|
|
3
|
+
details: 'M5 7h14M5 12h10M5 17h14M3 7h.01M3 12h.01M3 17h.01',
|
|
4
|
+
anchor: 'M12 6a3 3 0 1 0 .01 0M12 9v11M8 16c1.5 2 6.5 2 8 0',
|
|
5
|
+
charmap: 'M5 5h6v6H5zM13 5h6v6h-6zM5 13h6v6H5zM13 13h6v6h-6z',
|
|
6
|
+
emoji: 'M12 4a8 8 0 1 0 .01 0M9 10h.01M15 10h.01M8 14c1.5 2 6.5 2 8 0',
|
|
7
|
+
datetime: 'M7 4v2M17 4v2M5 8h14M6 4h12v16H6z',
|
|
8
|
+
pagebreak: 'M4 8h16M4 16h16M12 8v8',
|
|
9
|
+
nbsp: 'M6 16h12M8 8h8v8',
|
|
10
|
+
snippet: 'M8 4h8l4 4v12H8zM12 4v4h4',
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=icons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../src/icons.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAA2B;IAClD,KAAK,EAAE,6BAA6B;IACpC,OAAO,EAAE,mDAAmD;IAC5D,MAAM,EAAE,oDAAoD;IAC5D,OAAO,EAAE,oDAAoD;IAC7D,KAAK,EAAE,+DAA+D;IACtE,QAAQ,EAAE,mCAAmC;IAC7C,SAAS,EAAE,wBAAwB;IACnC,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,2BAA2B;CACrC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in insert tools for OpenLeaf.
|
|
3
|
+
*
|
|
4
|
+
* Schema nodes for media, details, figures, page breaks and named anchors live
|
|
5
|
+
* in `@openleaf-editor/core`, so stored documents round-trip without this
|
|
6
|
+
* package. What this bundle adds is the chrome: toolbar items, dialogs, the
|
|
7
|
+
* character and emoji grids, snippet insertion, and in-editor image resize
|
|
8
|
+
* handles.
|
|
9
|
+
*/
|
|
10
|
+
import { type HtmlSnippet } from './snippets.js';
|
|
11
|
+
export declare const INSERT_TOOLBAR_ITEMS: readonly ["media", "details", "anchor", "charmap", "emoji", "datetime", "pagebreak", "nbsp", "snippet"];
|
|
12
|
+
export declare const INSERT_LAYOUT_SUFFIX: string;
|
|
13
|
+
export interface InsertOptions {
|
|
14
|
+
snippets?: readonly HtmlSnippet[];
|
|
15
|
+
}
|
|
16
|
+
export declare function installInsertTools(options?: InsertOptions): void;
|
|
17
|
+
export { CHARACTERS, EMOJI } from './glyphs.js';
|
|
18
|
+
export { listedSnippets, registerHtmlSnippets, type HtmlSnippet } from './snippets.js';
|
|
19
|
+
export { imageResizePlugin } from './resize.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAcH,OAAO,EAAwC,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AAGtF,eAAO,MAAM,oBAAoB,yGAUvB,CAAA;AAEV,eAAO,MAAM,oBAAoB,QAAyC,CAAA;AAE1E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,SAAS,WAAW,EAAE,CAAA;CAClC;AAID,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,aAAkB,GAAG,IAAI,CAuGpE;AAED,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in insert tools for OpenLeaf.
|
|
3
|
+
*
|
|
4
|
+
* Schema nodes for media, details, figures, page breaks and named anchors live
|
|
5
|
+
* in `@openleaf-editor/core`, so stored documents round-trip without this
|
|
6
|
+
* package. What this bundle adds is the chrome: toolbar items, dialogs, the
|
|
7
|
+
* character and emoji grids, snippet insertion, and in-editor image resize
|
|
8
|
+
* handles.
|
|
9
|
+
*/
|
|
10
|
+
import { insertNonBreakingSpace, insertPageBreak, insertText, registerEditorPlugin, } from '@openleaf-editor/core';
|
|
11
|
+
import { registerIcons, registerStyles, registerToolbarItem } from '@openleaf-editor/ui';
|
|
12
|
+
import { CHARACTERS, EMOJI } from './glyphs.js';
|
|
13
|
+
import { buildGlyphPicker } from './grid.js';
|
|
14
|
+
import { INSERT_ICONS } from './icons.js';
|
|
15
|
+
import { promptInsertAnchor, promptInsertDetails, promptInsertMedia, promptInsertSnippet } from './prompts.js';
|
|
16
|
+
import { imageResizePlugin } from './resize.js';
|
|
17
|
+
import { listedSnippets, registerHtmlSnippets } from './snippets.js';
|
|
18
|
+
import { INSERT_CSS } from './styles.js';
|
|
19
|
+
export const INSERT_TOOLBAR_ITEMS = [
|
|
20
|
+
'media',
|
|
21
|
+
'details',
|
|
22
|
+
'anchor',
|
|
23
|
+
'charmap',
|
|
24
|
+
'emoji',
|
|
25
|
+
'datetime',
|
|
26
|
+
'pagebreak',
|
|
27
|
+
'nbsp',
|
|
28
|
+
'snippet',
|
|
29
|
+
];
|
|
30
|
+
export const INSERT_LAYOUT_SUFFIX = ` | ${INSERT_TOOLBAR_ITEMS.join(' ')}`;
|
|
31
|
+
let installed = false;
|
|
32
|
+
export function installInsertTools(options = {}) {
|
|
33
|
+
if (installed)
|
|
34
|
+
return;
|
|
35
|
+
installed = true;
|
|
36
|
+
if (options.snippets)
|
|
37
|
+
registerHtmlSnippets(options.snippets);
|
|
38
|
+
registerIcons(INSERT_ICONS);
|
|
39
|
+
registerStyles(INSERT_CSS);
|
|
40
|
+
registerEditorPlugin(() => [imageResizePlugin()]);
|
|
41
|
+
registerToolbarItem({
|
|
42
|
+
id: 'media',
|
|
43
|
+
type: 'button',
|
|
44
|
+
kind: 'action',
|
|
45
|
+
label: 'Insert media',
|
|
46
|
+
icon: 'media',
|
|
47
|
+
run: ({ view, host }) => {
|
|
48
|
+
void promptInsertMedia(view, host);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
registerToolbarItem({
|
|
52
|
+
id: 'details',
|
|
53
|
+
type: 'button',
|
|
54
|
+
kind: 'action',
|
|
55
|
+
label: 'Collapsible section',
|
|
56
|
+
icon: 'details',
|
|
57
|
+
run: ({ view, host }) => {
|
|
58
|
+
void promptInsertDetails(view, host);
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
registerToolbarItem({
|
|
62
|
+
id: 'anchor',
|
|
63
|
+
type: 'button',
|
|
64
|
+
kind: 'action',
|
|
65
|
+
label: 'Named anchor',
|
|
66
|
+
icon: 'anchor',
|
|
67
|
+
run: ({ view, host }) => {
|
|
68
|
+
void promptInsertAnchor(view, host);
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
registerToolbarItem({
|
|
72
|
+
id: 'charmap',
|
|
73
|
+
type: 'custom',
|
|
74
|
+
label: 'Character map',
|
|
75
|
+
icon: 'charmap',
|
|
76
|
+
render: (ctx) => buildGlyphPicker(ctx, { label: 'Character map', icon: 'charmap', items: CHARACTERS }),
|
|
77
|
+
});
|
|
78
|
+
registerToolbarItem({
|
|
79
|
+
id: 'emoji',
|
|
80
|
+
type: 'custom',
|
|
81
|
+
label: 'Emoji',
|
|
82
|
+
icon: 'emoji',
|
|
83
|
+
render: (ctx) => buildGlyphPicker(ctx, { label: 'Emoji', icon: 'emoji', items: EMOJI }),
|
|
84
|
+
});
|
|
85
|
+
registerToolbarItem({
|
|
86
|
+
id: 'datetime',
|
|
87
|
+
type: 'button',
|
|
88
|
+
kind: 'action',
|
|
89
|
+
label: 'Insert date and time',
|
|
90
|
+
icon: 'datetime',
|
|
91
|
+
command: (state, dispatch, view) => {
|
|
92
|
+
const stamp = new Intl.DateTimeFormat(undefined, {
|
|
93
|
+
dateStyle: 'medium',
|
|
94
|
+
timeStyle: 'short',
|
|
95
|
+
}).format(new Date());
|
|
96
|
+
return insertText(stamp)(state, dispatch, view);
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
registerToolbarItem({
|
|
100
|
+
id: 'pagebreak',
|
|
101
|
+
type: 'button',
|
|
102
|
+
kind: 'action',
|
|
103
|
+
label: 'Page break',
|
|
104
|
+
icon: 'pagebreak',
|
|
105
|
+
command: insertPageBreak,
|
|
106
|
+
});
|
|
107
|
+
registerToolbarItem({
|
|
108
|
+
id: 'nbsp',
|
|
109
|
+
type: 'button',
|
|
110
|
+
kind: 'action',
|
|
111
|
+
label: 'Non-breaking space',
|
|
112
|
+
icon: 'nbsp',
|
|
113
|
+
command: insertNonBreakingSpace,
|
|
114
|
+
});
|
|
115
|
+
registerToolbarItem({
|
|
116
|
+
id: 'snippet',
|
|
117
|
+
type: 'button',
|
|
118
|
+
kind: 'action',
|
|
119
|
+
label: 'Insert snippet',
|
|
120
|
+
icon: 'snippet',
|
|
121
|
+
isEnabled: () => listedSnippets().length > 0,
|
|
122
|
+
run: ({ view, host }) => {
|
|
123
|
+
void promptInsertSnippet(view, host);
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
export { CHARACTERS, EMOJI } from './glyphs.js';
|
|
128
|
+
export { listedSnippets, registerHtmlSnippets } from './snippets.js';
|
|
129
|
+
export { imageResizePlugin } from './resize.js';
|
|
130
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,UAAU,EACV,oBAAoB,GACrB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACxF,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAC9G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAoB,MAAM,eAAe,CAAA;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,OAAO;IACP,SAAS;IACT,QAAQ;IACR,SAAS;IACT,OAAO;IACP,UAAU;IACV,WAAW;IACX,MAAM;IACN,SAAS;CACD,CAAA;AAEV,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,oBAAoB,CAAC,IAAI,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Q;QACd,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,eAAe;KACzB,CAAC,CAAA;IAEF,mBAAmB,CAAC;QAClB,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,oBAAoB;QAC3B,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,sBAAsB;KAChC,CAAC,CAAA;IAEF,mBAAmB,CAAC;QAClB,EAAE,EAAE,SAAS;QACb,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,gBAAgB;QACvB,IAAI,EAAE,SAAS;QACf,SAAS,EAAE,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,MAAM,GAAG,CAAC;QAC5C,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;YACtB,KAAK,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACtC,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAoB,MAAM,eAAe,CAAA;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
.ol-insert-grid {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
display: grid;
|
|
4
|
+
grid-template-columns: repeat(8, 2rem);
|
|
5
|
+
gap: 2px;
|
|
6
|
+
padding: 8px;
|
|
7
|
+
max-height: 16rem;
|
|
8
|
+
overflow: auto;
|
|
9
|
+
border: 1px solid var(--openleaf-color-border, #d1d9e0);
|
|
10
|
+
border-radius: var(--openleaf-radius, 6px);
|
|
11
|
+
background: var(--openleaf-color-surface, #fff);
|
|
12
|
+
color: var(--openleaf-color-text, #1f2328);
|
|
13
|
+
font: 16px/1.2 var(--openleaf-font, system-ui, sans-serif);
|
|
14
|
+
z-index: var(--openleaf-z-popover, 40);
|
|
15
|
+
}
|
|
16
|
+
/*
|
|
17
|
+
* Both hidden states are restated here, because the rules that implement them
|
|
18
|
+
* belong to the user agent while the display:grid above belongs to this sheet --
|
|
19
|
+
* and an author declaration beats a UA one whatever its specificity. Without
|
|
20
|
+
* these the grid is permanently displayed, and since the popover attribute also
|
|
21
|
+
* carries UA position:fixed, inset:0 and margin:auto, what an author saw was an
|
|
22
|
+
* emoji panel floating in the middle of the page on load, following the scroll.
|
|
23
|
+
*
|
|
24
|
+
* The attribute selector on the second rule matters: on a browser without
|
|
25
|
+
* popover support the grid carries no such attribute and lives in the toolbar,
|
|
26
|
+
* where a bare :not(:popover-open) would match forever and hide it for good.
|
|
27
|
+
*/
|
|
28
|
+
.ol-insert-grid[hidden] { display: none; }
|
|
29
|
+
.ol-insert-grid[popover]:not(:popover-open) { display: none; }
|
|
30
|
+
.ol-insert-grid button {
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
width: 2rem; height: 2rem; margin: 0; padding: 0;
|
|
33
|
+
border: 1px solid transparent; border-radius: 4px;
|
|
34
|
+
background: transparent; color: inherit; font: inherit; cursor: pointer;
|
|
35
|
+
}
|
|
36
|
+
.ol-insert-grid button:hover, .ol-insert-grid button:focus-visible {
|
|
37
|
+
border-color: var(--openleaf-color-accent, #0550ae);
|
|
38
|
+
outline: none;
|
|
39
|
+
}
|
|
40
|
+
.ol-img-resize { position: relative; display: inline-block; max-width: 100%; }
|
|
41
|
+
.ol-img-resize img { display: block; max-width: 100%; height: auto; }
|
|
42
|
+
.ol-img-handle {
|
|
43
|
+
position: absolute; right: 0; bottom: 0;
|
|
44
|
+
width: 12px; height: 12px; margin: 0; padding: 0;
|
|
45
|
+
border: 1px solid var(--openleaf-color-accent, #0550ae);
|
|
46
|
+
background: var(--openleaf-color-surface, #fff);
|
|
47
|
+
cursor: nwse-resize;
|
|
48
|
+
}
|
|
49
|
+
@media print {
|
|
50
|
+
.ol-pagebreak, hr.ol-pagebreak { break-after: page; page-break-after: always; border: 0; }
|
|
51
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { EditorView } from 'prosemirror-view';
|
|
2
|
+
export declare function promptInsertMedia(view: EditorView, host: HTMLElement): Promise<void>;
|
|
3
|
+
export declare function promptInsertDetails(view: EditorView, host: HTMLElement): Promise<void>;
|
|
4
|
+
export declare function promptInsertAnchor(view: EditorView, host: HTMLElement): Promise<void>;
|
|
5
|
+
export declare function promptInsertSnippet(view: EditorView, host: HTMLElement): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AA2DlD,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB1F;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAU5F;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAY3F;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB5F"}
|
package/dist/prompts.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { insertAudio, insertDetails, insertHtml, insertIframe, insertNamedAnchor, insertVideo, setHeadingId, isNodeActive } from '@openleaf-editor/core';
|
|
2
|
+
import { listedSnippets } from './snippets.js';
|
|
3
|
+
function ask(doc, title, fields) {
|
|
4
|
+
const dialog = doc.createElement('dialog');
|
|
5
|
+
dialog.className = 'ol-dialog';
|
|
6
|
+
const form = doc.createElement('form');
|
|
7
|
+
form.method = 'dialog';
|
|
8
|
+
const heading = doc.createElement('h2');
|
|
9
|
+
heading.textContent = title;
|
|
10
|
+
form.appendChild(heading);
|
|
11
|
+
const inputs = new Map();
|
|
12
|
+
for (const field of fields) {
|
|
13
|
+
const label = doc.createElement('label');
|
|
14
|
+
const span = doc.createElement('span');
|
|
15
|
+
span.textContent = field.label;
|
|
16
|
+
const input = doc.createElement('input');
|
|
17
|
+
input.type = 'text';
|
|
18
|
+
input.name = field.name;
|
|
19
|
+
input.value = field.value ?? '';
|
|
20
|
+
label.append(span, input);
|
|
21
|
+
inputs.set(field.name, input);
|
|
22
|
+
form.appendChild(label);
|
|
23
|
+
}
|
|
24
|
+
const actions = doc.createElement('div');
|
|
25
|
+
actions.className = 'ol-actions';
|
|
26
|
+
const cancel = doc.createElement('button');
|
|
27
|
+
cancel.type = 'button';
|
|
28
|
+
cancel.textContent = 'Cancel';
|
|
29
|
+
const ok = doc.createElement('button');
|
|
30
|
+
ok.type = 'submit';
|
|
31
|
+
ok.value = 'ok';
|
|
32
|
+
ok.textContent = 'Insert';
|
|
33
|
+
actions.append(cancel, ok);
|
|
34
|
+
form.appendChild(actions);
|
|
35
|
+
dialog.appendChild(form);
|
|
36
|
+
doc.body.appendChild(dialog);
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
|
+
const finish = (value) => {
|
|
39
|
+
dialog.close();
|
|
40
|
+
dialog.remove();
|
|
41
|
+
resolve(value);
|
|
42
|
+
};
|
|
43
|
+
cancel.addEventListener('click', () => finish(null));
|
|
44
|
+
dialog.addEventListener('cancel', (event) => {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
finish(null);
|
|
47
|
+
});
|
|
48
|
+
form.addEventListener('submit', (event) => {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
const values = {};
|
|
51
|
+
for (const [name, input] of inputs)
|
|
52
|
+
values[name] = input.value.trim();
|
|
53
|
+
finish(values);
|
|
54
|
+
});
|
|
55
|
+
dialog.showModal();
|
|
56
|
+
inputs.values().next().value?.focus();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export async function promptInsertMedia(view, host) {
|
|
60
|
+
const values = await ask(host.ownerDocument, 'Insert media', [
|
|
61
|
+
{ name: 'src', label: 'Address' },
|
|
62
|
+
{ name: 'title', label: 'Title' },
|
|
63
|
+
]);
|
|
64
|
+
if (!values?.['src']) {
|
|
65
|
+
view.focus();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const src = values['src'];
|
|
69
|
+
const title = values['title'] || null;
|
|
70
|
+
const kind = /youtube|vimeo|dailymotion|spotify|soundcloud|twitch|google\.com\/maps/i.test(src)
|
|
71
|
+
? insertIframe
|
|
72
|
+
: /\.(mp3|wav|ogg|m4a)(\?|$)/i.test(src)
|
|
73
|
+
? insertAudio
|
|
74
|
+
: insertVideo;
|
|
75
|
+
kind({ src, title })(view.state, view.dispatch, view);
|
|
76
|
+
view.focus();
|
|
77
|
+
}
|
|
78
|
+
export async function promptInsertDetails(view, host) {
|
|
79
|
+
const values = await ask(host.ownerDocument, 'Collapsible section', [
|
|
80
|
+
{ name: 'summary', label: 'Summary', value: 'Details' },
|
|
81
|
+
]);
|
|
82
|
+
if (!values) {
|
|
83
|
+
view.focus();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
insertDetails(values['summary'] || 'Details')(view.state, view.dispatch, view);
|
|
87
|
+
view.focus();
|
|
88
|
+
}
|
|
89
|
+
export async function promptInsertAnchor(view, host) {
|
|
90
|
+
const values = await ask(host.ownerDocument, 'Named anchor', [{ name: 'id', label: 'Name' }]);
|
|
91
|
+
if (!values?.['id']) {
|
|
92
|
+
view.focus();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (isNodeActive(view.state, 'heading')) {
|
|
96
|
+
setHeadingId(values['id'])(view.state, view.dispatch, view);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
insertNamedAnchor(values['id'])(view.state, view.dispatch, view);
|
|
100
|
+
}
|
|
101
|
+
view.focus();
|
|
102
|
+
}
|
|
103
|
+
export async function promptInsertSnippet(view, host) {
|
|
104
|
+
const available = listedSnippets();
|
|
105
|
+
if (available.length === 0) {
|
|
106
|
+
view.focus();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const values = await ask(host.ownerDocument, 'Insert snippet', [
|
|
110
|
+
{ name: 'id', label: `Snippet id (${available.map((s) => s.id).join(', ')})` },
|
|
111
|
+
]);
|
|
112
|
+
const found = available.find((s) => s.id === values?.['id'] || s.title === values?.['id']);
|
|
113
|
+
if (!found) {
|
|
114
|
+
view.focus();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
insertHtml(found.html)(view.state, view.dispatch, view);
|
|
118
|
+
view.focus();
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACxJ,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAG9C,SAAS,GAAG,CAAC,GAAa,EAAE,KAAa,EAAE,MAA8D;IACvG,MAAM,MAAM,GAAG,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC1C,MAAM,CAAC,SAAS,GAAG,WAAW,CAAA;IAC9B,MAAM,IAAI,GAAG,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;IACtC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAA;IACtB,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,CAA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7D,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;KAC/E,CAAC,CAAA;IACF,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAC1F,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,OAAM;IACR,CAAC;IACD,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IACvD,IAAI,CAAC,KAAK,EAAE,CAAA;AACd,CAAC"}
|
package/dist/resize.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resize.d.ts","sourceRoot":"","sources":["../src/resize.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAwG1C,wBAAgB,iBAAiB,IAAI,MAAM,CAQ1C"}
|
package/dist/resize.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { IMAGE_ALIGN_CLASS } from '@openleaf-editor/core';
|
|
2
|
+
import { Plugin } from 'prosemirror-state';
|
|
3
|
+
/**
|
|
4
|
+
* Put a stored dimension on the element without going through `img.width`.
|
|
5
|
+
*
|
|
6
|
+
* The schema preserves what the document said, and `width="50%"` is legal HTML.
|
|
7
|
+
* `img.width` is an unsigned long, so `Number('50%')` is NaN and lands as 0 --
|
|
8
|
+
* collapsing the image instead of rendering it at half the container. A
|
|
9
|
+
* percentage is not a valid width attribute value either, so it goes on the
|
|
10
|
+
* style, which is editor-only DOM and never serialized.
|
|
11
|
+
*/
|
|
12
|
+
function setDimension(img, name, raw) {
|
|
13
|
+
const value = raw === null || raw === undefined ? '' : String(raw).trim();
|
|
14
|
+
if (value === '') {
|
|
15
|
+
img.removeAttribute(name);
|
|
16
|
+
img.style.removeProperty(name);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (/^\d+$/.test(value)) {
|
|
20
|
+
img.style.removeProperty(name);
|
|
21
|
+
img.setAttribute(name, value);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
img.removeAttribute(name);
|
|
25
|
+
img.style.setProperty(name, value);
|
|
26
|
+
}
|
|
27
|
+
function applyAttrs(img, node) {
|
|
28
|
+
img.src = node.attrs['src'];
|
|
29
|
+
const alt = node.attrs['alt'];
|
|
30
|
+
if (alt !== null)
|
|
31
|
+
img.alt = alt;
|
|
32
|
+
else
|
|
33
|
+
img.removeAttribute('alt');
|
|
34
|
+
const title = node.attrs['title'];
|
|
35
|
+
if (title)
|
|
36
|
+
img.title = title;
|
|
37
|
+
else
|
|
38
|
+
img.removeAttribute('title');
|
|
39
|
+
setDimension(img, 'width', node.attrs['width']);
|
|
40
|
+
setDimension(img, 'height', node.attrs['height']);
|
|
41
|
+
const align = node.attrs['align'];
|
|
42
|
+
const classes = [align ? IMAGE_ALIGN_CLASS[align] : '', node.attrs['className'] ?? '']
|
|
43
|
+
.filter((part) => part !== '')
|
|
44
|
+
.join(' ');
|
|
45
|
+
img.className = classes;
|
|
46
|
+
}
|
|
47
|
+
function imageView(node, view, getPos) {
|
|
48
|
+
const wrap = view.dom.ownerDocument.createElement('span');
|
|
49
|
+
wrap.className = 'ol-img-resize';
|
|
50
|
+
const img = view.dom.ownerDocument.createElement('img');
|
|
51
|
+
applyAttrs(img, node);
|
|
52
|
+
const handle = view.dom.ownerDocument.createElement('button');
|
|
53
|
+
handle.type = 'button';
|
|
54
|
+
handle.className = 'ol-img-handle';
|
|
55
|
+
handle.setAttribute('aria-label', 'Resize image');
|
|
56
|
+
wrap.append(img, handle);
|
|
57
|
+
let dragging = false;
|
|
58
|
+
let startX = 0;
|
|
59
|
+
let startWidth = 0;
|
|
60
|
+
const onMove = (event) => {
|
|
61
|
+
if (!dragging)
|
|
62
|
+
return;
|
|
63
|
+
const next = Math.max(16, Math.round(startWidth + (event.clientX - startX)));
|
|
64
|
+
const pos = getPos();
|
|
65
|
+
if (pos === undefined)
|
|
66
|
+
return;
|
|
67
|
+
const ratio = img.naturalHeight && img.naturalWidth ? img.naturalHeight / img.naturalWidth : 0;
|
|
68
|
+
const height = ratio ? String(Math.round(next * ratio)) : null;
|
|
69
|
+
view.dispatch(view.state.tr.setNodeMarkup(pos, undefined, {
|
|
70
|
+
...view.state.doc.nodeAt(pos)?.attrs,
|
|
71
|
+
width: String(next),
|
|
72
|
+
height,
|
|
73
|
+
}));
|
|
74
|
+
};
|
|
75
|
+
const onUp = () => {
|
|
76
|
+
dragging = false;
|
|
77
|
+
window.removeEventListener('pointermove', onMove);
|
|
78
|
+
window.removeEventListener('pointerup', onUp);
|
|
79
|
+
};
|
|
80
|
+
handle.addEventListener('pointerdown', (event) => {
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
dragging = true;
|
|
83
|
+
startX = event.clientX;
|
|
84
|
+
startWidth = img.getBoundingClientRect().width;
|
|
85
|
+
window.addEventListener('pointermove', onMove);
|
|
86
|
+
window.addEventListener('pointerup', onUp);
|
|
87
|
+
});
|
|
88
|
+
return {
|
|
89
|
+
dom: wrap,
|
|
90
|
+
update(updated) {
|
|
91
|
+
if (updated.type.name !== 'image')
|
|
92
|
+
return false;
|
|
93
|
+
applyAttrs(img, updated);
|
|
94
|
+
return true;
|
|
95
|
+
},
|
|
96
|
+
destroy() {
|
|
97
|
+
onUp();
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export function imageResizePlugin() {
|
|
102
|
+
return new Plugin({
|
|
103
|
+
props: {
|
|
104
|
+
nodeViews: {
|
|
105
|
+
image: (node, view, getPos) => imageView(node, view, getPos),
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=resize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resize.js","sourceRoot":"","sources":["../src/resize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAmB,MAAM,uBAAuB,CAAA;AAE1E,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAG1C;;;;;;;;GAQG;AACH,SAAS,YAAY,CAAC,GAAqB,EAAE,IAAwB,EAAE,GAAY;IACjF,MAAM,KAAK,GAAG,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IACzE,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QACjB,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;QACzB,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;QAC9B,OAAM;IACR,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;QAC9B,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QAC7B,OAAM;IACR,CAAC;IACD,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;IACzB,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACpC,CAAC;AAED,SAAS,UAAU,CAAC,GAAqB,EAAE,IAAY;IACrD,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAW,CAAA;IACrC,MA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SACF;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface HtmlSnippet {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
html: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function registerHtmlSnippets(next: readonly HtmlSnippet[]): void;
|
|
7
|
+
export declare function listedSnippets(): readonly HtmlSnippet[];
|
|
8
|
+
//# sourceMappingURL=snippets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippets.d.ts","sourceRoot":"","sources":["../src/snippets.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACb;AAID,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,GAAG,IAAI,CAEvE;AAED,wBAAgB,cAAc,IAAI,SAAS,WAAW,EAAE,CAEvD"}
|
package/dist/snippets.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippets.js","sourceRoot":"","sources":["../src/snippets.ts"],"names":[],"mappings":"AAMA,IAAI,QAAQ,GAA2B,EAAE,CAAA;AAEzC,MAAM,UAAU,oBAAoB,CAAC,IAA4B;IAC/D,QAAQ,GAAG,IAAI,CAAA;AACjB,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const INSERT_CSS = "\n.ol-insert-grid {\n box-sizing: border-box;\n display: grid;\n grid-template-columns: repeat(8, 2rem);\n gap: 2px;\n padding: 8px;\n max-height: 16rem;\n overflow: auto;\n border: 1px solid var(--openleaf-color-border, #d1d9e0);\n border-radius: var(--openleaf-radius, 6px);\n background: var(--openleaf-color-surface, #fff);\n color: var(--openleaf-color-text, #1f2328);\n font: 16px/1.2 var(--openleaf-font, system-ui, sans-serif);\n z-index: var(--openleaf-z-popover, 40);\n}\n/*\n * Both hidden states are restated here, because the rules that implement them\n * belong to the user agent while the display:grid above belongs to this sheet --\n * and an author declaration beats a UA one whatever its specificity. Without\n * these the grid is permanently displayed, and since the popover attribute also\n * carries UA position:fixed, inset:0 and margin:auto, what an author saw was an\n * emoji panel floating in the middle of the page on load, following the scroll.\n *\n * The attribute selector on the second rule matters: on a browser without\n * popover support the grid carries no such attribute and lives in the toolbar,\n * where a bare :not(:popover-open) would match forever and hide it for good.\n */\n.ol-insert-grid[hidden] { display: none; }\n.ol-insert-grid[popover]:not(:popover-open) { display: none; }\n.ol-insert-grid button {\n box-sizing: border-box;\n width: 2rem; height: 2rem; margin: 0; padding: 0;\n border: 1px solid transparent; border-radius: 4px;\n background: transparent; color: inherit; font: inherit; cursor: pointer;\n}\n.ol-insert-grid button:hover, .ol-insert-grid button:focus-visible {\n border-color: var(--openleaf-color-accent, #0550ae);\n outline: none;\n}\n.ol-img-resize { position: relative; display: inline-block; max-width: 100%; }\n.ol-img-resize img { display: block; max-width: 100%; height: auto; }\n.ol-img-handle {\n position: absolute; right: 0; bottom: 0;\n width: 12px; height: 12px; margin: 0; padding: 0;\n border: 1px solid var(--openleaf-color-accent, #0550ae);\n background: var(--openleaf-color-surface, #fff);\n cursor: nwse-resize;\n}\n@media print {\n .ol-pagebreak, hr.ol-pagebreak { break-after: page; page-break-after: always; border: 0; }\n}\n";
|
|
2
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,ysEAoDtB,CAAA"}
|
package/dist/styles.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export const INSERT_CSS = `
|
|
2
|
+
.ol-insert-grid {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
display: grid;
|
|
5
|
+
grid-template-columns: repeat(8, 2rem);
|
|
6
|
+
gap: 2px;
|
|
7
|
+
padding: 8px;
|
|
8
|
+
max-height: 16rem;
|
|
9
|
+
overflow: auto;
|
|
10
|
+
border: 1px solid var(--openleaf-color-border, #d1d9e0);
|
|
11
|
+
border-radius: var(--openleaf-radius, 6px);
|
|
12
|
+
background: var(--openleaf-color-surface, #fff);
|
|
13
|
+
color: var(--openleaf-color-text, #1f2328);
|
|
14
|
+
font: 16px/1.2 var(--openleaf-font, system-ui, sans-serif);
|
|
15
|
+
z-index: var(--openleaf-z-popover, 40);
|
|
16
|
+
}
|
|
17
|
+
/*
|
|
18
|
+
* Both hidden states are restated here, because the rules that implement them
|
|
19
|
+
* belong to the user agent while the display:grid above belongs to this sheet --
|
|
20
|
+
* and an author declaration beats a UA one whatever its specificity. Without
|
|
21
|
+
* these the grid is permanently displayed, and since the popover attribute also
|
|
22
|
+
* carries UA position:fixed, inset:0 and margin:auto, what an author saw was an
|
|
23
|
+
* emoji panel floating in the middle of the page on load, following the scroll.
|
|
24
|
+
*
|
|
25
|
+
* The attribute selector on the second rule matters: on a browser without
|
|
26
|
+
* popover support the grid carries no such attribute and lives in the toolbar,
|
|
27
|
+
* where a bare :not(:popover-open) would match forever and hide it for good.
|
|
28
|
+
*/
|
|
29
|
+
.ol-insert-grid[hidden] { display: none; }
|
|
30
|
+
.ol-insert-grid[popover]:not(:popover-open) { display: none; }
|
|
31
|
+
.ol-insert-grid button {
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
width: 2rem; height: 2rem; margin: 0; padding: 0;
|
|
34
|
+
border: 1px solid transparent; border-radius: 4px;
|
|
35
|
+
background: transparent; color: inherit; font: inherit; cursor: pointer;
|
|
36
|
+
}
|
|
37
|
+
.ol-insert-grid button:hover, .ol-insert-grid button:focus-visible {
|
|
38
|
+
border-color: var(--openleaf-color-accent, #0550ae);
|
|
39
|
+
outline: none;
|
|
40
|
+
}
|
|
41
|
+
.ol-img-resize { position: relative; display: inline-block; max-width: 100%; }
|
|
42
|
+
.ol-img-resize img { display: block; max-width: 100%; height: auto; }
|
|
43
|
+
.ol-img-handle {
|
|
44
|
+
position: absolute; right: 0; bottom: 0;
|
|
45
|
+
width: 12px; height: 12px; margin: 0; padding: 0;
|
|
46
|
+
border: 1px solid var(--openleaf-color-accent, #0550ae);
|
|
47
|
+
background: var(--openleaf-color-surface, #fff);
|
|
48
|
+
cursor: nwse-resize;
|
|
49
|
+
}
|
|
50
|
+
@media print {
|
|
51
|
+
.ol-pagebreak, hr.ol-pagebreak { break-after: page; page-break-after: always; border: 0; }
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDzB,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openleaf-editor/plugins-insert",
|
|
3
|
+
"version": "0.1.0-beta.2",
|
|
4
|
+
"description": "Opt-in insert tools for OpenLeaf: media embeds, collapsible sections, anchors, character map, emoji, snippets, page breaks, and image resize handles. The matching schema nodes live in @openleaf-editor/core so stored documents round-trip whether or not this package is loaded.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/PeytonNowlin/openleaf.git",
|
|
12
|
+
"directory": "packages/plugins-insert"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://peytonnowlin.github.io/openleaf/",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/PeytonNowlin/openleaf/issues"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./openleaf-insert.css": "./dist/openleaf-insert.css"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"prosemirror-model": "^1.25.11",
|
|
33
|
+
"prosemirror-state": "^1.4.3",
|
|
34
|
+
"prosemirror-view": "^1.37.0",
|
|
35
|
+
"@openleaf-editor/core": "0.1.0-beta.2",
|
|
36
|
+
"@openleaf-editor/ui": "0.1.0-beta.2"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc -p tsconfig.json && node scripts/emit-css.mjs"
|
|
40
|
+
}
|
|
41
|
+
}
|