@openleaf-editor/element 0.1.0-beta.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/README.md +42 -0
- package/dist/global.d.ts +43 -0
- package/dist/global.d.ts.map +1 -0
- package/dist/global.js +43 -0
- package/dist/global.js.map +1 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +483 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -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,42 @@
|
|
|
1
|
+
# `@openleaf-editor/element`
|
|
2
|
+
|
|
3
|
+
The `<openleaf-editor>` custom element: OpenLeaf's drop-in for CMS forms. HTML in, HTML out, syncs to a textarea.
|
|
4
|
+
|
|
5
|
+
This is a **beta**. APIs may still change.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @openleaf-editor/element@beta
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import '@openleaf-editor/element'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<form method="post">
|
|
19
|
+
<label for="body">Post body</label>
|
|
20
|
+
<openleaf-editor for="body" aria-label="Post body"></openleaf-editor>
|
|
21
|
+
<textarea id="body" name="body" hidden></textarea>
|
|
22
|
+
<button type="submit">Save</button>
|
|
23
|
+
</form>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Optional plugins, each a separate package:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { installTableEditing } from '@openleaf-editor/plugins-table'
|
|
30
|
+
import { installSyntaxHighlighting } from '@openleaf-editor/plugins-highlight'
|
|
31
|
+
import { installImport } from '@openleaf-editor/plugins-import'
|
|
32
|
+
import { installDocxImport } from '@openleaf-editor/plugins-import-docx'
|
|
33
|
+
|
|
34
|
+
installTableEditing()
|
|
35
|
+
installSyntaxHighlighting()
|
|
36
|
+
installImport()
|
|
37
|
+
installDocxImport()
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Sanitize submitted HTML on the server. `@openleaf-editor/sanitize` ships the same allowlist as data.
|
|
41
|
+
|
|
42
|
+
See the [project README](https://github.com/PeytonNowlin/openleaf) for the rest.
|
package/dist/global.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bundle entry point, and the plugin host.
|
|
3
|
+
*
|
|
4
|
+
* Two script tags cannot share module state, so an opt-in bundle loaded after
|
|
5
|
+
* this one would normally bundle its own copy of ProseMirror -- turning a 12.5 KB
|
|
6
|
+
* table plugin into a 200 KB one, and worse, giving it a *second* copy of the
|
|
7
|
+
* schema and the registries. Two schemas means a table node created by the
|
|
8
|
+
* plugin is a different node type than the one the editor understands, which
|
|
9
|
+
* fails in ways that are very hard to read.
|
|
10
|
+
*
|
|
11
|
+
* So this entry publishes the shared runtime on the global. The plugin bundles
|
|
12
|
+
* are built with these modules marked external and resolved from
|
|
13
|
+
* `window.OpenLeaf.__runtime` instead, which keeps exactly one copy of
|
|
14
|
+
* everything on the page.
|
|
15
|
+
*
|
|
16
|
+
* `__runtime` is named with underscores because it is not a public API. It is a
|
|
17
|
+
* linkage detail between bundles built from this repository at the same version;
|
|
18
|
+
* anything outside should import the packages properly.
|
|
19
|
+
*/
|
|
20
|
+
import * as openleafCore from '@openleaf-editor/core';
|
|
21
|
+
import * as openleafPaste from '@openleaf-editor/paste';
|
|
22
|
+
import * as openleafUi from '@openleaf-editor/ui';
|
|
23
|
+
import * as pmCommands from 'prosemirror-commands';
|
|
24
|
+
import * as pmHistory from 'prosemirror-history';
|
|
25
|
+
import * as pmKeymap from 'prosemirror-keymap';
|
|
26
|
+
import * as pmModel from 'prosemirror-model';
|
|
27
|
+
import * as pmState from 'prosemirror-state';
|
|
28
|
+
import * as pmTransform from 'prosemirror-transform';
|
|
29
|
+
import * as pmView from 'prosemirror-view';
|
|
30
|
+
export * from './index.js';
|
|
31
|
+
export declare const __runtime: {
|
|
32
|
+
'@openleaf-editor/core': typeof openleafCore;
|
|
33
|
+
'@openleaf-editor/paste': typeof openleafPaste;
|
|
34
|
+
'@openleaf-editor/ui': typeof openleafUi;
|
|
35
|
+
'prosemirror-commands': typeof pmCommands;
|
|
36
|
+
'prosemirror-history': typeof pmHistory;
|
|
37
|
+
'prosemirror-keymap': typeof pmKeymap;
|
|
38
|
+
'prosemirror-model': typeof pmModel;
|
|
39
|
+
'prosemirror-state': typeof pmState;
|
|
40
|
+
'prosemirror-transform': typeof pmTransform;
|
|
41
|
+
'prosemirror-view': typeof pmView;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=global.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../src/global.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,SAAS,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAE1C,cAAc,YAAY,CAAA;AAE1B,eAAO,MAAM,SAAS;;;;;;;;;;;CAWrB,CAAA"}
|
package/dist/global.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bundle entry point, and the plugin host.
|
|
3
|
+
*
|
|
4
|
+
* Two script tags cannot share module state, so an opt-in bundle loaded after
|
|
5
|
+
* this one would normally bundle its own copy of ProseMirror -- turning a 12.5 KB
|
|
6
|
+
* table plugin into a 200 KB one, and worse, giving it a *second* copy of the
|
|
7
|
+
* schema and the registries. Two schemas means a table node created by the
|
|
8
|
+
* plugin is a different node type than the one the editor understands, which
|
|
9
|
+
* fails in ways that are very hard to read.
|
|
10
|
+
*
|
|
11
|
+
* So this entry publishes the shared runtime on the global. The plugin bundles
|
|
12
|
+
* are built with these modules marked external and resolved from
|
|
13
|
+
* `window.OpenLeaf.__runtime` instead, which keeps exactly one copy of
|
|
14
|
+
* everything on the page.
|
|
15
|
+
*
|
|
16
|
+
* `__runtime` is named with underscores because it is not a public API. It is a
|
|
17
|
+
* linkage detail between bundles built from this repository at the same version;
|
|
18
|
+
* anything outside should import the packages properly.
|
|
19
|
+
*/
|
|
20
|
+
import * as openleafCore from '@openleaf-editor/core';
|
|
21
|
+
import * as openleafPaste from '@openleaf-editor/paste';
|
|
22
|
+
import * as openleafUi from '@openleaf-editor/ui';
|
|
23
|
+
import * as pmCommands from 'prosemirror-commands';
|
|
24
|
+
import * as pmHistory from 'prosemirror-history';
|
|
25
|
+
import * as pmKeymap from 'prosemirror-keymap';
|
|
26
|
+
import * as pmModel from 'prosemirror-model';
|
|
27
|
+
import * as pmState from 'prosemirror-state';
|
|
28
|
+
import * as pmTransform from 'prosemirror-transform';
|
|
29
|
+
import * as pmView from 'prosemirror-view';
|
|
30
|
+
export * from './index.js';
|
|
31
|
+
export const __runtime = {
|
|
32
|
+
'@openleaf-editor/core': openleafCore,
|
|
33
|
+
'@openleaf-editor/paste': openleafPaste,
|
|
34
|
+
'@openleaf-editor/ui': openleafUi,
|
|
35
|
+
'prosemirror-commands': pmCommands,
|
|
36
|
+
'prosemirror-history': pmHistory,
|
|
37
|
+
'prosemirror-keymap': pmKeymap,
|
|
38
|
+
'prosemirror-model': pmModel,
|
|
39
|
+
'prosemirror-state': pmState,
|
|
40
|
+
'prosemirror-transform': pmTransform,
|
|
41
|
+
'prosemirror-view': pmView,
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.js","sourceRoot":"","sources":["../src/global.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,SAAS,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAE1C,cAAc,YAAY,CAAA;AAE1B,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,uBAAuB,EAAE,YAAY;IACrC,wBAAwB,EAAE,aAAa;IACvC,qBAAqB,EAAE,UAAU;IACjC,sBAAsB,EAAE,UAAU;IAClC,qBAAqB,EAAE,SAAS;IAChC,oBAAoB,EAAE,QAAQ;IAC9B,mBAAmB,EAAE,OAAO;IAC5B,mBAAmB,EAAE,OAAO;IAC5B,uBAAuB,EAAE,WAAW;IACpC,kBAAkB,EAAE,MAAM;CAC3B,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <openleaf-editor> -- the CMS drop-in.
|
|
3
|
+
*
|
|
4
|
+
* Design constraints, in priority order:
|
|
5
|
+
*
|
|
6
|
+
* 1. WORKS WITHOUT A BUILD STEP. A `<script>` tag and a custom element,
|
|
7
|
+
* because the integrations that most need a free editor are PHP templates
|
|
8
|
+
* and Django forms, not Vite projects.
|
|
9
|
+
*
|
|
10
|
+
* 2. HTML IN, HTML OUT. No proprietary document format. A CMS that adopts
|
|
11
|
+
* OpenLeaf and later drops it is left with content it can still render.
|
|
12
|
+
*
|
|
13
|
+
* 3. NO SHADOW DOM ON THE CONTENT AREA. Deliberate. CMS integrators expect the
|
|
14
|
+
* site's own typography to apply to the content they are editing -- that is
|
|
15
|
+
* what makes it WYSIWYG. Shadow DOM would block exactly the inheritance
|
|
16
|
+
* they want. Chrome styles are namespaced instead.
|
|
17
|
+
*
|
|
18
|
+
* 4. THE TEXTAREA CONTRACT. CMS forms submit textareas. The element keeps one
|
|
19
|
+
* in sync and writes to it before submit, so server-side code that already
|
|
20
|
+
* reads `$_POST['body']` keeps working untouched.
|
|
21
|
+
*
|
|
22
|
+
* Attributes:
|
|
23
|
+
* for id of the textarea to bind to
|
|
24
|
+
* skin named appearance: midnight, paper, contrast, compact
|
|
25
|
+
* theme light | dark | auto (default: follow the visitor's system)
|
|
26
|
+
* toolbar space-separated item ids, `|` for a separator; `none` to omit
|
|
27
|
+
* readonly render but do not allow editing
|
|
28
|
+
* aria-label accessible name for the editable region
|
|
29
|
+
*/
|
|
30
|
+
import { Toolbar } from '@openleaf-editor/ui';
|
|
31
|
+
import { EditorView } from 'prosemirror-view';
|
|
32
|
+
/**
|
|
33
|
+
* Emitted when the HTML source view opens and closes, carrying the textarea.
|
|
34
|
+
*
|
|
35
|
+
* The extension point exists so an opt-in bundle can enhance the source box --
|
|
36
|
+
* formatting, syntax highlighting -- without the element having to know anything
|
|
37
|
+
* about it. Names are defined here rather than imported so the element keeps no
|
|
38
|
+
* dependency on any plugin.
|
|
39
|
+
*/
|
|
40
|
+
export declare const SOURCE_OPEN_EVENT = "openleaf:source-open";
|
|
41
|
+
export declare const SOURCE_CLOSE_EVENT = "openleaf:source-close";
|
|
42
|
+
export declare class OpenLeafEditor extends HTMLElement {
|
|
43
|
+
#private;
|
|
44
|
+
static get observedAttributes(): string[];
|
|
45
|
+
/**
|
|
46
|
+
* Appearance attributes are applied on change as well as at build time, so a
|
|
47
|
+
* host that lets a person switch theme does not have to rebuild the editor --
|
|
48
|
+
* which would cost them their undo history for a colour change.
|
|
49
|
+
*/
|
|
50
|
+
attributeChangedCallback(name: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Build the editor -- but not before the document's scripts have run.
|
|
53
|
+
*
|
|
54
|
+
* A custom element upgrades at the microtask checkpoint that ends the script
|
|
55
|
+
* defining it, so `connectedCallback` fires BEFORE the next `<script>` tag
|
|
56
|
+
* executes. Every documented integration loads plugin bundles as later script
|
|
57
|
+
* tags, which means they register after this point.
|
|
58
|
+
*
|
|
59
|
+
* ProseMirror plugins survive that, because `state.reconfigure` can swap them
|
|
60
|
+
* into a live editor. A schema cannot: `reconfigure` keeps the old schema by
|
|
61
|
+
* construction. So an editor built at upgrade time could never contain a
|
|
62
|
+
* plugin's node types -- not as an edge case, but in every shipped layout.
|
|
63
|
+
*
|
|
64
|
+
* Waiting for `DOMContentLoaded` closes that gap for the whole two-script-tag
|
|
65
|
+
* model. The editor already appears asynchronously via element upgrade, so
|
|
66
|
+
* nothing about this is visible to an author.
|
|
67
|
+
*/
|
|
68
|
+
connectedCallback(): void;
|
|
69
|
+
disconnectedCallback(): void;
|
|
70
|
+
/** Current document as an HTML string. */
|
|
71
|
+
get value(): string;
|
|
72
|
+
set value(html: string);
|
|
73
|
+
/** Escape hatch for plugins and integrations that need the real view. */
|
|
74
|
+
get view(): EditorView | null;
|
|
75
|
+
/** The schema this editor was built with. */
|
|
76
|
+
get schema(): import('prosemirror-model').Schema;
|
|
77
|
+
/** The toolbar, for plugins pushing external state via setItemState. */
|
|
78
|
+
get toolbar(): Toolbar | null;
|
|
79
|
+
get sourceMode(): boolean;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Re-exported so the single-file bundle can offer paste normalization without a
|
|
83
|
+
* second script tag. Useful for custom paste handling, and for normalizing
|
|
84
|
+
* clipboard HTML somewhere other than the editor.
|
|
85
|
+
*/
|
|
86
|
+
export { normalizePastedHtml } from '@openleaf-editor/paste';
|
|
87
|
+
/** Idempotent: safe to import twice, or alongside a bundled copy. */
|
|
88
|
+
export declare function defineOpenLeafEditor(tag?: string): void;
|
|
89
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAaH,OAAO,EAEL,OAAO,EAOR,MAAM,qBAAqB,CAAA;AAK5B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAI7C;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,yBAAyB,CAAA;AACvD,eAAO,MAAM,kBAAkB,0BAA0B,CAAA;AAEzD,qBAAa,cAAe,SAAQ,WAAW;;IAC7C,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED;;;;OAIG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IA6C5C;;;;;;;;;;;;;;;;OAgBG;IACH,iBAAiB,IAAI,IAAI;IAuLzB,oBAAoB,IAAI,IAAI;IAiB5B,0CAA0C;IAC1C,IAAI,KAAK,IAAI,MAAM,CAIlB;IAED,IAAI,KAAK,CAAC,IAAI,EAAE,MAAM,EAWrB;IAED,yEAAyE;IACzE,IAAI,IAAI,IAAI,UAAU,GAAG,IAAI,CAE5B;IAED,6CAA6C;IAC7C,IAAI,MAAM,IAAI,OAAO,mBAAmB,EAAE,MAAM,CAE/C;IAED,wEAAwE;IACxE,IAAI,OAAO,IAAI,OAAO,GAAG,IAAI,CAE5B;IAED,IAAI,UAAU,IAAI,OAAO,CAExB;CA0IF;AAED;;;;GAIG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAE5D,qEAAqE;AACrE,wBAAgB,oBAAoB,CAAC,GAAG,SAAoB,GAAG,IAAI,CAIlE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <openleaf-editor> -- the CMS drop-in.
|
|
3
|
+
*
|
|
4
|
+
* Design constraints, in priority order:
|
|
5
|
+
*
|
|
6
|
+
* 1. WORKS WITHOUT A BUILD STEP. A `<script>` tag and a custom element,
|
|
7
|
+
* because the integrations that most need a free editor are PHP templates
|
|
8
|
+
* and Django forms, not Vite projects.
|
|
9
|
+
*
|
|
10
|
+
* 2. HTML IN, HTML OUT. No proprietary document format. A CMS that adopts
|
|
11
|
+
* OpenLeaf and later drops it is left with content it can still render.
|
|
12
|
+
*
|
|
13
|
+
* 3. NO SHADOW DOM ON THE CONTENT AREA. Deliberate. CMS integrators expect the
|
|
14
|
+
* site's own typography to apply to the content they are editing -- that is
|
|
15
|
+
* what makes it WYSIWYG. Shadow DOM would block exactly the inheritance
|
|
16
|
+
* they want. Chrome styles are namespaced instead.
|
|
17
|
+
*
|
|
18
|
+
* 4. THE TEXTAREA CONTRACT. CMS forms submit textareas. The element keeps one
|
|
19
|
+
* in sync and writes to it before submit, so server-side code that already
|
|
20
|
+
* reads `$_POST['body']` keeps working untouched.
|
|
21
|
+
*
|
|
22
|
+
* Attributes:
|
|
23
|
+
* for id of the textarea to bind to
|
|
24
|
+
* skin named appearance: midnight, paper, contrast, compact
|
|
25
|
+
* theme light | dark | auto (default: follow the visitor's system)
|
|
26
|
+
* toolbar space-separated item ids, `|` for a separator; `none` to omit
|
|
27
|
+
* readonly render but do not allow editing
|
|
28
|
+
* aria-label accessible name for the editable region
|
|
29
|
+
*/
|
|
30
|
+
import { buildKeymap, coreSchema, createRegisteredPlugins, onEditorPluginsChange, onSchemaExtensionsChange, parseHtml, serializeHtml, } from '@openleaf-editor/core';
|
|
31
|
+
import { normalizePastedHtml } from '@openleaf-editor/paste';
|
|
32
|
+
import { SOURCE_TOGGLE_EVENT, Toolbar, applyColourScheme, applySkin, ensureSkins, ensureStyles, registerDefaultItems, } from '@openleaf-editor/ui';
|
|
33
|
+
import { baseKeymap } from 'prosemirror-commands';
|
|
34
|
+
import { history } from 'prosemirror-history';
|
|
35
|
+
import { keymap } from 'prosemirror-keymap';
|
|
36
|
+
import { EditorState, Plugin } from 'prosemirror-state';
|
|
37
|
+
import { EditorView } from 'prosemirror-view';
|
|
38
|
+
let hintCounter = 0;
|
|
39
|
+
/**
|
|
40
|
+
* Emitted when the HTML source view opens and closes, carrying the textarea.
|
|
41
|
+
*
|
|
42
|
+
* The extension point exists so an opt-in bundle can enhance the source box --
|
|
43
|
+
* formatting, syntax highlighting -- without the element having to know anything
|
|
44
|
+
* about it. Names are defined here rather than imported so the element keeps no
|
|
45
|
+
* dependency on any plugin.
|
|
46
|
+
*/
|
|
47
|
+
export const SOURCE_OPEN_EVENT = 'openleaf:source-open';
|
|
48
|
+
export const SOURCE_CLOSE_EVENT = 'openleaf:source-close';
|
|
49
|
+
export class OpenLeafEditor extends HTMLElement {
|
|
50
|
+
static get observedAttributes() {
|
|
51
|
+
return ['for', 'readonly', 'skin', 'theme'];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Appearance attributes are applied on change as well as at build time, so a
|
|
55
|
+
* host that lets a person switch theme does not have to rebuild the editor --
|
|
56
|
+
* which would cost them their undo history for a colour change.
|
|
57
|
+
*/
|
|
58
|
+
attributeChangedCallback(name) {
|
|
59
|
+
if (name === 'skin')
|
|
60
|
+
applySkin(this, this.getAttribute('skin'));
|
|
61
|
+
if (name === 'theme')
|
|
62
|
+
applyColourScheme(this, this.#colourScheme());
|
|
63
|
+
if (name === 'readonly')
|
|
64
|
+
this.#applyReadonly();
|
|
65
|
+
if (name === 'for')
|
|
66
|
+
this.#rebindTextarea();
|
|
67
|
+
}
|
|
68
|
+
#colourScheme() {
|
|
69
|
+
const value = this.getAttribute('theme');
|
|
70
|
+
return value === 'light' || value === 'dark' ? value : 'auto';
|
|
71
|
+
}
|
|
72
|
+
#view = null;
|
|
73
|
+
#toolbar = null;
|
|
74
|
+
#textarea = null;
|
|
75
|
+
#form = null;
|
|
76
|
+
#contentHost = null;
|
|
77
|
+
#sourceArea = null;
|
|
78
|
+
#sourceMode = false;
|
|
79
|
+
#deferred = false;
|
|
80
|
+
/** The schema this editor was built with. Fixed for its lifetime. */
|
|
81
|
+
#schema = coreSchema();
|
|
82
|
+
#basePlugins = [];
|
|
83
|
+
#pluginCache = new Map();
|
|
84
|
+
#unwatchPlugins;
|
|
85
|
+
#unwatchSchema;
|
|
86
|
+
#onSubmit = () => this.#syncToTextarea();
|
|
87
|
+
#onFormData = (event) => {
|
|
88
|
+
this.#syncToTextarea();
|
|
89
|
+
// formdata fires after the browser has already built event.formData from
|
|
90
|
+
// the current controls. Updating textarea.value does not change that
|
|
91
|
+
// snapshot; the entry has to be written onto the FormData itself.
|
|
92
|
+
if (this.#textarea?.name)
|
|
93
|
+
event.formData.set(this.#textarea.name, this.#textarea.value);
|
|
94
|
+
};
|
|
95
|
+
#onReset = () => {
|
|
96
|
+
// The reset event fires *before* the controls are restored -- read
|
|
97
|
+
// textarea.value in the handler and it is still the edited text. The
|
|
98
|
+
// microtask runs after the reset algorithm finishes, which is the first
|
|
99
|
+
// point the default is actually readable. Removing it re-loads the
|
|
100
|
+
// editor with the content the reset was meant to discard.
|
|
101
|
+
queueMicrotask(() => {
|
|
102
|
+
if (this.#textarea)
|
|
103
|
+
this.value = this.#textarea.value;
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Build the editor -- but not before the document's scripts have run.
|
|
108
|
+
*
|
|
109
|
+
* A custom element upgrades at the microtask checkpoint that ends the script
|
|
110
|
+
* defining it, so `connectedCallback` fires BEFORE the next `<script>` tag
|
|
111
|
+
* executes. Every documented integration loads plugin bundles as later script
|
|
112
|
+
* tags, which means they register after this point.
|
|
113
|
+
*
|
|
114
|
+
* ProseMirror plugins survive that, because `state.reconfigure` can swap them
|
|
115
|
+
* into a live editor. A schema cannot: `reconfigure` keeps the old schema by
|
|
116
|
+
* construction. So an editor built at upgrade time could never contain a
|
|
117
|
+
* plugin's node types -- not as an edge case, but in every shipped layout.
|
|
118
|
+
*
|
|
119
|
+
* Waiting for `DOMContentLoaded` closes that gap for the whole two-script-tag
|
|
120
|
+
* model. The editor already appears asynchronously via element upgrade, so
|
|
121
|
+
* nothing about this is visible to an author.
|
|
122
|
+
*/
|
|
123
|
+
connectedCallback() {
|
|
124
|
+
if (this.#view || this.#deferred)
|
|
125
|
+
return;
|
|
126
|
+
if (this.ownerDocument.readyState === 'loading') {
|
|
127
|
+
this.#deferred = true;
|
|
128
|
+
this.ownerDocument.addEventListener('DOMContentLoaded', () => {
|
|
129
|
+
this.#deferred = false;
|
|
130
|
+
if (this.isConnected && !this.#view)
|
|
131
|
+
this.#build();
|
|
132
|
+
}, { once: true });
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
this.#build();
|
|
136
|
+
}
|
|
137
|
+
#build() {
|
|
138
|
+
registerDefaultItems();
|
|
139
|
+
ensureStyles(this.ownerDocument);
|
|
140
|
+
ensureSkins(this.ownerDocument);
|
|
141
|
+
applySkin(this, this.getAttribute('skin'));
|
|
142
|
+
applyColourScheme(this, this.#colourScheme());
|
|
143
|
+
this.#textarea = this.#findTextarea();
|
|
144
|
+
const initialHtml = this.#textarea?.value ?? this.innerHTML;
|
|
145
|
+
const nestedTextarea = this.#textarea && this.contains(this.#textarea) ? this.#textarea : null;
|
|
146
|
+
// Nested binding used to `innerHTML = ''` the textarea out of the document,
|
|
147
|
+
// so it was no longer a successful form control. Lift it aside first, then
|
|
148
|
+
// put it back hidden so the form still posts it.
|
|
149
|
+
nestedTextarea?.remove();
|
|
150
|
+
this.innerHTML = '';
|
|
151
|
+
this.classList.add('ol-editor');
|
|
152
|
+
const layout = this.getAttribute('toolbar');
|
|
153
|
+
const wantsToolbar = layout !== 'none';
|
|
154
|
+
if (wantsToolbar) {
|
|
155
|
+
this.#toolbar = new Toolbar(this, this.ownerDocument, {
|
|
156
|
+
...(layout ? { layout } : {}),
|
|
157
|
+
});
|
|
158
|
+
this.appendChild(this.#toolbar.el);
|
|
159
|
+
}
|
|
160
|
+
const contentHost = this.ownerDocument.createElement('div');
|
|
161
|
+
contentHost.className = 'ol-content';
|
|
162
|
+
this.appendChild(contentHost);
|
|
163
|
+
this.#contentHost = contentHost;
|
|
164
|
+
// The Alt+F10 hint lives in a hidden element referenced by
|
|
165
|
+
// aria-describedby. Screen reader users cannot guess the shortcut, and
|
|
166
|
+
// discoverability comes from telling them rather than from choosing a
|
|
167
|
+
// guessable key.
|
|
168
|
+
const hintId = `ol-hint-${(hintCounter += 1)}`;
|
|
169
|
+
const hint = this.ownerDocument.createElement('span');
|
|
170
|
+
hint.id = hintId;
|
|
171
|
+
hint.className = 'ol-live';
|
|
172
|
+
hint.textContent = wantsToolbar
|
|
173
|
+
? 'Rich text editor. Press Alt plus F10 for the formatting toolbar.'
|
|
174
|
+
: 'Rich text editor.';
|
|
175
|
+
this.appendChild(hint);
|
|
176
|
+
if (this.#toolbar)
|
|
177
|
+
this.appendChild(this.#toolbar.liveRegion);
|
|
178
|
+
// Held on the instance rather than built inline, because `reconfigure`
|
|
179
|
+
// has to hand the view back the *same* history() it was created with.
|
|
180
|
+
// Building a second one is what dropped undo when a plugin registered late.
|
|
181
|
+
this.#basePlugins = [
|
|
182
|
+
history(),
|
|
183
|
+
// Alt+F10 is bound before the shared keymap so it cannot be shadowed.
|
|
184
|
+
keymap({
|
|
185
|
+
'Alt-F10': () => {
|
|
186
|
+
this.#toolbar?.focusToolbar();
|
|
187
|
+
return true;
|
|
188
|
+
},
|
|
189
|
+
}),
|
|
190
|
+
// The shared shortcut table, so toolbar tooltips and any help dialog
|
|
191
|
+
// render the real bindings rather than a duplicate list that drifts.
|
|
192
|
+
keymap(buildKeymap()),
|
|
193
|
+
keymap(baseKeymap),
|
|
194
|
+
];
|
|
195
|
+
this.#schema = coreSchema();
|
|
196
|
+
this.#view = new EditorView(contentHost, {
|
|
197
|
+
state: EditorState.create({
|
|
198
|
+
doc: parseHtml(initialHtml, { schema: this.#schema }),
|
|
199
|
+
// Plugins contributed by opt-in bundles. The cache is per editor, so
|
|
200
|
+
// instances are still never shared between two editors -- each carries
|
|
201
|
+
// its own state and two editors sharing one would fight over it -- but
|
|
202
|
+
// reconfiguring this editor reuses its own, which is what stops a late
|
|
203
|
+
// registration resetting the plugin state of the ones already running.
|
|
204
|
+
plugins: [...this.#basePlugins, ...createRegisteredPlugins(this.#schema, this.#pluginCache)],
|
|
205
|
+
}),
|
|
206
|
+
editable: () => !this.hasAttribute('readonly'),
|
|
207
|
+
attributes: {
|
|
208
|
+
role: 'textbox',
|
|
209
|
+
'aria-multiline': 'true',
|
|
210
|
+
'aria-label': this.getAttribute('aria-label') ?? 'Rich text editor',
|
|
211
|
+
'aria-describedby': hintId,
|
|
212
|
+
},
|
|
213
|
+
// Normalize before ProseMirror parses. Word and Google Docs express
|
|
214
|
+
// structure as proprietary CSS, so without this a pasted list arrives as
|
|
215
|
+
// a wall of paragraphs with stray bullet characters in the text.
|
|
216
|
+
transformPastedHTML: (html) => normalizePastedHtml(html),
|
|
217
|
+
dispatchTransaction: (tr) => {
|
|
218
|
+
const view = this.#view;
|
|
219
|
+
if (!view)
|
|
220
|
+
return;
|
|
221
|
+
view.updateState(view.state.apply(tr));
|
|
222
|
+
// Persistence comes FIRST, and deliberately so. The document is already
|
|
223
|
+
// committed by the line above; nothing about writing it out should
|
|
224
|
+
// depend on chrome rendering succeeding. With this the other way round,
|
|
225
|
+
// a third-party toolbar predicate that threw on one keystroke threw on
|
|
226
|
+
// every keystroke after it, and the textarea sync plus this event never
|
|
227
|
+
// ran again for the rest of the session -- an autosave listening here
|
|
228
|
+
// would stop silently and the author would lose work.
|
|
229
|
+
if (tr.docChanged) {
|
|
230
|
+
this.#syncToTextarea();
|
|
231
|
+
this.dispatchEvent(new CustomEvent('openleaf:change', { bubbles: true }));
|
|
232
|
+
}
|
|
233
|
+
// Passing the transaction lets the toolbar tell a formatting change from
|
|
234
|
+
// a cursor move, which is what keeps its announcements useful instead of
|
|
235
|
+
// chatty. Guarded because everything it calls may be third-party code.
|
|
236
|
+
try {
|
|
237
|
+
this.#toolbar?.update(view.state, tr);
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
console.error('@openleaf-editor/element: toolbar update failed', error);
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
this.#toolbar?.mount(this.#view);
|
|
245
|
+
this.addEventListener(SOURCE_TOGGLE_EVENT, this.#onToggleSource);
|
|
246
|
+
if (nestedTextarea) {
|
|
247
|
+
nestedTextarea.hidden = true;
|
|
248
|
+
this.appendChild(nestedTextarea);
|
|
249
|
+
}
|
|
250
|
+
// An editor already on the page when a deferred bundle finishes loading
|
|
251
|
+
// would otherwise never receive its plugins, and the author would find
|
|
252
|
+
// table controls that do nothing. `reconfigure` keeps the document and the
|
|
253
|
+
// undo history; rebuilding the state from scratch would discard both.
|
|
254
|
+
this.#unwatchSchema = onSchemaExtensionsChange(() => {
|
|
255
|
+
if (!this.#view)
|
|
256
|
+
return;
|
|
257
|
+
if (coreSchema() === this.#schema)
|
|
258
|
+
return;
|
|
259
|
+
console.warn('@openleaf-editor/element: a schema extension registered after this editor was ' +
|
|
260
|
+
'built, so its node types are not available here. A document\'s schema is ' +
|
|
261
|
+
'fixed when its editor is created -- load the plugin script before the ' +
|
|
262
|
+
'editor, or reload the page. Editors created from now on will have it.');
|
|
263
|
+
});
|
|
264
|
+
this.#unwatchPlugins = onEditorPluginsChange(() => {
|
|
265
|
+
const view = this.#view;
|
|
266
|
+
if (!view)
|
|
267
|
+
return;
|
|
268
|
+
view.updateState(view.state.reconfigure({
|
|
269
|
+
plugins: [
|
|
270
|
+
...this.#basePlugins,
|
|
271
|
+
...createRegisteredPlugins(this.#schema, this.#pluginCache),
|
|
272
|
+
],
|
|
273
|
+
}));
|
|
274
|
+
this.#toolbar?.update(view.state);
|
|
275
|
+
});
|
|
276
|
+
// Belt and braces: `submit` covers ordinary posts, `formdata` covers
|
|
277
|
+
// fetch-based submissions built from a FormData snapshot.
|
|
278
|
+
// Prefer the bound textarea's form: the documented `for` binding allows
|
|
279
|
+
// the editor to live outside the <form>, next to a hidden textarea inside it.
|
|
280
|
+
this.#form = this.#textarea?.form ?? this.closest('form');
|
|
281
|
+
this.#form?.addEventListener('submit', this.#onSubmit);
|
|
282
|
+
this.#form?.addEventListener('formdata', this.#onFormData);
|
|
283
|
+
this.#form?.addEventListener('reset', this.#onReset);
|
|
284
|
+
this.#syncToTextarea();
|
|
285
|
+
}
|
|
286
|
+
disconnectedCallback() {
|
|
287
|
+
// Persist whatever is in the source box before tearing it down, so a
|
|
288
|
+
// framework that moves the element does not drop unsaved HTML.
|
|
289
|
+
this.#syncToTextarea();
|
|
290
|
+
this.#teardownSource({ apply: false });
|
|
291
|
+
this.#form?.removeEventListener('submit', this.#onSubmit);
|
|
292
|
+
this.#form?.removeEventListener('formdata', this.#onFormData);
|
|
293
|
+
this.#form?.removeEventListener('reset', this.#onReset);
|
|
294
|
+
this.removeEventListener(SOURCE_TOGGLE_EVENT, this.#onToggleSource);
|
|
295
|
+
this.#unwatchPlugins?.();
|
|
296
|
+
this.#unwatchSchema?.();
|
|
297
|
+
this.#toolbar?.destroy();
|
|
298
|
+
this.#toolbar = null;
|
|
299
|
+
this.#view?.destroy();
|
|
300
|
+
this.#view = null;
|
|
301
|
+
}
|
|
302
|
+
/** Current document as an HTML string. */
|
|
303
|
+
get value() {
|
|
304
|
+
if (this.#sourceMode && this.#sourceArea)
|
|
305
|
+
return this.#sourceArea.value;
|
|
306
|
+
if (!this.#view)
|
|
307
|
+
return this.#textarea?.value ?? '';
|
|
308
|
+
return serializeHtml(this.#view.state.doc);
|
|
309
|
+
}
|
|
310
|
+
set value(html) {
|
|
311
|
+
if (this.#sourceMode && this.#sourceArea) {
|
|
312
|
+
this.#sourceArea.value = html;
|
|
313
|
+
this.#syncToTextarea();
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (!this.#view) {
|
|
317
|
+
if (this.#textarea)
|
|
318
|
+
this.#textarea.value = html;
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
this.#replaceDocument(html);
|
|
322
|
+
}
|
|
323
|
+
/** Escape hatch for plugins and integrations that need the real view. */
|
|
324
|
+
get view() {
|
|
325
|
+
return this.#view;
|
|
326
|
+
}
|
|
327
|
+
/** The schema this editor was built with. */
|
|
328
|
+
get schema() {
|
|
329
|
+
return this.#schema;
|
|
330
|
+
}
|
|
331
|
+
/** The toolbar, for plugins pushing external state via setItemState. */
|
|
332
|
+
get toolbar() {
|
|
333
|
+
return this.#toolbar;
|
|
334
|
+
}
|
|
335
|
+
get sourceMode() {
|
|
336
|
+
return this.#sourceMode;
|
|
337
|
+
}
|
|
338
|
+
/* -------------------------------------------------------------- *
|
|
339
|
+
* Source view
|
|
340
|
+
* -------------------------------------------------------------- */
|
|
341
|
+
/**
|
|
342
|
+
* Toggle raw HTML editing.
|
|
343
|
+
*
|
|
344
|
+
* Switching view is a large context change, so focus moves into whichever
|
|
345
|
+
* control is now live rather than being left on the button that caused the
|
|
346
|
+
* switch. Leaving it silent and stranded is the common failure here.
|
|
347
|
+
*/
|
|
348
|
+
#onToggleSource = () => {
|
|
349
|
+
const view = this.#view;
|
|
350
|
+
const contentHost = this.#contentHost;
|
|
351
|
+
if (!view || !contentHost)
|
|
352
|
+
return;
|
|
353
|
+
if (!this.#sourceMode) {
|
|
354
|
+
const area = this.ownerDocument.createElement('textarea');
|
|
355
|
+
area.className = 'ol-source';
|
|
356
|
+
area.setAttribute('aria-label', 'HTML source');
|
|
357
|
+
area.spellcheck = false;
|
|
358
|
+
area.readOnly = this.hasAttribute('readonly');
|
|
359
|
+
area.value = serializeHtml(view.state.doc);
|
|
360
|
+
contentHost.hidden = true;
|
|
361
|
+
contentHost.after(area);
|
|
362
|
+
this.#sourceArea = area;
|
|
363
|
+
this.#sourceMode = true;
|
|
364
|
+
this.#toolbar?.setItemState('source', { active: true });
|
|
365
|
+
// Announced before focus so an enhancer can wrap the textarea while it is
|
|
366
|
+
// still inert; focusing first would move the caret and then move the
|
|
367
|
+
// element out from under it.
|
|
368
|
+
this.dispatchEvent(new CustomEvent(SOURCE_OPEN_EVENT, { bubbles: true, detail: { textarea: area } }));
|
|
369
|
+
area.focus();
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
// `apply: false` under readonly: the source box is read-only there, so
|
|
373
|
+
// there is nothing to write back and parsing it would be a no-op that
|
|
374
|
+
// still lands a transaction.
|
|
375
|
+
this.#teardownSource({ apply: !this.hasAttribute('readonly') });
|
|
376
|
+
contentHost.hidden = false;
|
|
377
|
+
this.#toolbar?.setItemState('source', { active: false });
|
|
378
|
+
view.focus();
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* Leave source mode.
|
|
382
|
+
*
|
|
383
|
+
* `apply: false` is disconnect: fire the close event so enhancers can
|
|
384
|
+
* tear down, but do not parse the leftover textarea back into a view that
|
|
385
|
+
* is about to be destroyed.
|
|
386
|
+
*/
|
|
387
|
+
#teardownSource(options) {
|
|
388
|
+
const area = this.#sourceArea;
|
|
389
|
+
const view = this.#view;
|
|
390
|
+
if (!area) {
|
|
391
|
+
this.#sourceMode = false;
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
this.dispatchEvent(new CustomEvent(SOURCE_CLOSE_EVENT, { bubbles: true, detail: { textarea: area } }));
|
|
395
|
+
const html = area.value;
|
|
396
|
+
area.remove();
|
|
397
|
+
this.#sourceArea = null;
|
|
398
|
+
this.#sourceMode = false;
|
|
399
|
+
if (options.apply && view) {
|
|
400
|
+
// Compare documents, not strings. A source-view enhancer is free to
|
|
401
|
+
// pretty-print the HTML for display, and that indentation parses to the
|
|
402
|
+
// same document. Comparing the text would call it an edit, so merely
|
|
403
|
+
// looking at the source would land an undo step and fire
|
|
404
|
+
// openleaf:change -- the two things leaving source is meant not to do.
|
|
405
|
+
this.#replaceDocument(html, { onlyIfChanged: true });
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Replace the document with a transaction, so undo and change events survive.
|
|
410
|
+
*
|
|
411
|
+
* `onlyIfChanged` skips the dispatch when the HTML parses to the document
|
|
412
|
+
* already on screen.
|
|
413
|
+
*/
|
|
414
|
+
#replaceDocument(html, options) {
|
|
415
|
+
const view = this.#view;
|
|
416
|
+
if (!view)
|
|
417
|
+
return;
|
|
418
|
+
const next = parseHtml(html, { schema: this.#schema });
|
|
419
|
+
if (options?.onlyIfChanged && next.eq(view.state.doc))
|
|
420
|
+
return;
|
|
421
|
+
view.dispatch(view.state.tr.replaceWith(0, view.state.doc.content.size, next.content));
|
|
422
|
+
}
|
|
423
|
+
/* -------------------------------------------------------------- *
|
|
424
|
+
* Textarea binding
|
|
425
|
+
* -------------------------------------------------------------- */
|
|
426
|
+
#findTextarea() {
|
|
427
|
+
const id = this.getAttribute('for');
|
|
428
|
+
if (id) {
|
|
429
|
+
const el = this.getRootNode().getElementById?.(id);
|
|
430
|
+
if (el instanceof HTMLTextAreaElement)
|
|
431
|
+
return el;
|
|
432
|
+
// A `for` that resolves to nothing is a silent data-loss bug waiting to
|
|
433
|
+
// happen, so say so loudly rather than falling back.
|
|
434
|
+
console.error(`<openleaf-editor for="${id}">: no <textarea id="${id}"> found. ` +
|
|
435
|
+
'Content will not be submitted with the form.');
|
|
436
|
+
return null;
|
|
437
|
+
}
|
|
438
|
+
return this.querySelector('textarea');
|
|
439
|
+
}
|
|
440
|
+
#syncToTextarea() {
|
|
441
|
+
if (!this.#textarea)
|
|
442
|
+
return;
|
|
443
|
+
if (this.#sourceMode && this.#sourceArea) {
|
|
444
|
+
this.#textarea.value = this.#sourceArea.value;
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (!this.#view)
|
|
448
|
+
return;
|
|
449
|
+
this.#textarea.value = serializeHtml(this.#view.state.doc);
|
|
450
|
+
}
|
|
451
|
+
#applyReadonly() {
|
|
452
|
+
// `editable()` already reads the attribute; the view has to be told to
|
|
453
|
+
// re-evaluate it. Without this, adding readonly after mount leaves
|
|
454
|
+
// contenteditable="true" until some unrelated transaction.
|
|
455
|
+
this.#view?.setProps({});
|
|
456
|
+
if (this.#sourceArea)
|
|
457
|
+
this.#sourceArea.readOnly = this.hasAttribute('readonly');
|
|
458
|
+
if (this.#view)
|
|
459
|
+
this.#toolbar?.update(this.#view.state);
|
|
460
|
+
}
|
|
461
|
+
#rebindTextarea() {
|
|
462
|
+
if (!this.#view)
|
|
463
|
+
return;
|
|
464
|
+
this.#textarea = this.#findTextarea();
|
|
465
|
+
this.#syncToTextarea();
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Re-exported so the single-file bundle can offer paste normalization without a
|
|
470
|
+
* second script tag. Useful for custom paste handling, and for normalizing
|
|
471
|
+
* clipboard HTML somewhere other than the editor.
|
|
472
|
+
*/
|
|
473
|
+
export { normalizePastedHtml } from '@openleaf-editor/paste';
|
|
474
|
+
/** Idempotent: safe to import twice, or alongside a bundled copy. */
|
|
475
|
+
export function defineOpenLeafEditor(tag = 'openleaf-editor') {
|
|
476
|
+
if (typeof customElements === 'undefined')
|
|
477
|
+
return;
|
|
478
|
+
if (customElements.get(tag))
|
|
479
|
+
return;
|
|
480
|
+
customElements.define(tag, OpenLeafEditor);
|
|
481
|
+
}
|
|
482
|
+
defineOpenLeafEditor();
|
|
483
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EACL,WAAW,EACX,UAAU,EACV,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,SAAS,EACT,aAAa,GAEd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EACL,mBAAmB,EACnB,OAAO,EACP,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,oBAAoB,GAErB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,IAAI,WAAW,GAAG,CAAC,CAAA;AAEnB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,sBAAsB,CAAA;AACvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,uBAAuB,CAAA;AAEzD,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C,MAAM,KAAK,kBAAkB;QAC3B,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;IAED;;;;OAIG;IACH,wBAAwB,CAAC,IAAY;QACnC,IAAI,IAAI,KAAK,MAAM;YAAE,SA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C,KAAK;YAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACzD,CAAC;IAED,eAAe;QACb,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAM;QACvB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;QACrC,IAAI,CAAC,eAAe,EAAE,CAAA;IACxB,CAAC;CACF;AAED;;;;GAIG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAE5D,qEAAqE;AACrE,MAAM,UAAU,oBAAoB,CAAC,GAAG,GAAG,iBAAiB;IAC1D,IAAI,OAAO,cAAc,KAAK,WAAW;QAAE,OAAM;IACjD,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAM;IACnC,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,cAAc,CAAC,CAAA;AAC5C,CAAC;AAED,oBAAoB,EAAE,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openleaf-editor/element",
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"description": "The <openleaf-editor> custom element: OpenLeaf's drop-in for CMS forms. HTML in, HTML out, syncs to a textarea.",
|
|
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/element"
|
|
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
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"prosemirror-commands": "^1.6.2",
|
|
32
|
+
"prosemirror-history": "^1.4.1",
|
|
33
|
+
"prosemirror-keymap": "^1.2.2",
|
|
34
|
+
"prosemirror-model": "^1.24.1",
|
|
35
|
+
"prosemirror-state": "^1.4.3",
|
|
36
|
+
"prosemirror-transform": "^1.10.2",
|
|
37
|
+
"prosemirror-view": "^1.37.0",
|
|
38
|
+
"@openleaf-editor/core": "0.1.0-beta.0",
|
|
39
|
+
"@openleaf-editor/paste": "0.1.0-beta.0",
|
|
40
|
+
"@openleaf-editor/ui": "0.1.0-beta.0"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.json"
|
|
44
|
+
}
|
|
45
|
+
}
|