@editora/preview 1.0.1
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/dist/index.es.js +321 -0
- package/dist/index.umd.js +230 -0
- package/package.json +36 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
let c = !1;
|
|
2
|
+
const g = () => {
|
|
3
|
+
if (typeof document > "u") return;
|
|
4
|
+
const r = "rte-preview-plugin-styles";
|
|
5
|
+
if (document.getElementById(r)) return;
|
|
6
|
+
const t = document.createElement("style");
|
|
7
|
+
t.id = r, t.textContent = `
|
|
8
|
+
/* Preview Editor Dialog Styles */
|
|
9
|
+
.rte-preview-editor-overlay {
|
|
10
|
+
position: fixed !important;
|
|
11
|
+
top: 0 !important;
|
|
12
|
+
left: 0 !important;
|
|
13
|
+
right: 0 !important;
|
|
14
|
+
bottom: 0 !important;
|
|
15
|
+
width: 100vw !important;
|
|
16
|
+
height: 100vh !important;
|
|
17
|
+
background-color: rgba(0, 0, 0, 0.6) !important;
|
|
18
|
+
display: flex !important;
|
|
19
|
+
align-items: center !important;
|
|
20
|
+
justify-content: center !important;
|
|
21
|
+
z-index: 10000 !important;
|
|
22
|
+
padding: 20px !important;
|
|
23
|
+
box-sizing: border-box !important;
|
|
24
|
+
margin: 0 !important;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.rte-preview-editor-modal {
|
|
28
|
+
background: white;
|
|
29
|
+
border-radius: 8px;
|
|
30
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
31
|
+
width: 100%;
|
|
32
|
+
max-width: 1200px;
|
|
33
|
+
max-height: 90vh;
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
position: relative;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.rte-preview-editor-header {
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: space-between;
|
|
44
|
+
padding: 16px 20px;
|
|
45
|
+
border-bottom: 1px solid #e1e5e9;
|
|
46
|
+
background: #f8f9fa;
|
|
47
|
+
border-radius: 8px 8px 0 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.rte-preview-editor-header h2 {
|
|
51
|
+
margin: 0;
|
|
52
|
+
font-size: 18px;
|
|
53
|
+
font-weight: 600;
|
|
54
|
+
color: #1a1a1a;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.rte-preview-editor-header-actions {
|
|
58
|
+
display: flex;
|
|
59
|
+
gap: 8px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.rte-preview-editor-close-btn {
|
|
63
|
+
background: none;
|
|
64
|
+
border: none;
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
padding: 4px;
|
|
67
|
+
border-radius: 4px;
|
|
68
|
+
color: #666;
|
|
69
|
+
font-size: 16px;
|
|
70
|
+
line-height: 1;
|
|
71
|
+
transition: all 0.2s ease;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.rte-preview-editor-close-btn:hover {
|
|
75
|
+
background: #e1e5e9;
|
|
76
|
+
color: #1a1a1a;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.rte-preview-editor-body {
|
|
80
|
+
flex: 1;
|
|
81
|
+
overflow: auto;
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
padding: 25px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.rte-preview-editor-content {
|
|
88
|
+
flex: 1;
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-direction: column;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.rte-preview-editor-light-editor {
|
|
94
|
+
flex: 1;
|
|
95
|
+
overflow: auto;
|
|
96
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
97
|
+
font-size: 16px;
|
|
98
|
+
line-height: 1.6;
|
|
99
|
+
color: #1a1a1a;
|
|
100
|
+
padding: 20px;
|
|
101
|
+
background: #fafafa;
|
|
102
|
+
border: 1px solid #e1e5e9;
|
|
103
|
+
border-radius: 4px;
|
|
104
|
+
min-height: 400px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.rte-preview-editor-light-editor h1,
|
|
108
|
+
.rte-preview-editor-light-editor h2,
|
|
109
|
+
.rte-preview-editor-light-editor h3,
|
|
110
|
+
.rte-preview-editor-light-editor h4,
|
|
111
|
+
.rte-preview-editor-light-editor h5,
|
|
112
|
+
.rte-preview-editor-light-editor h6 {
|
|
113
|
+
margin-top: 1.5em;
|
|
114
|
+
margin-bottom: 0.5em;
|
|
115
|
+
font-weight: 600;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.rte-preview-editor-light-editor h1 {
|
|
119
|
+
font-size: 2em;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.rte-preview-editor-light-editor h2 {
|
|
123
|
+
font-size: 1.5em;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.rte-preview-editor-light-editor h3 {
|
|
127
|
+
font-size: 1.25em;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.rte-preview-editor-light-editor p {
|
|
131
|
+
margin: 1em 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.rte-preview-editor-light-editor ul,
|
|
135
|
+
.rte-preview-editor-light-editor ol {
|
|
136
|
+
padding-left: 2em;
|
|
137
|
+
margin: 1em 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.rte-preview-editor-light-editor li {
|
|
141
|
+
margin: 0.5em 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.rte-preview-editor-light-editor table {
|
|
145
|
+
border-collapse: collapse;
|
|
146
|
+
width: 100%;
|
|
147
|
+
margin: 1em 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.rte-preview-editor-light-editor table td,
|
|
151
|
+
.rte-preview-editor-light-editor table th {
|
|
152
|
+
border: 1px solid #ddd;
|
|
153
|
+
padding: 0.5em;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.rte-preview-editor-light-editor table th {
|
|
157
|
+
background: #f5f5f5;
|
|
158
|
+
font-weight: 600;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.rte-preview-editor-light-editor blockquote {
|
|
162
|
+
border-left: 4px solid #ddd;
|
|
163
|
+
margin: 1em 0;
|
|
164
|
+
padding-left: 1em;
|
|
165
|
+
color: #666;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.rte-preview-editor-light-editor code {
|
|
169
|
+
background: #f5f5f5;
|
|
170
|
+
padding: 2px 6px;
|
|
171
|
+
border-radius: 3px;
|
|
172
|
+
font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
|
|
173
|
+
font-size: 0.9em;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.rte-preview-editor-light-editor pre {
|
|
177
|
+
background: #f5f5f5;
|
|
178
|
+
padding: 1em;
|
|
179
|
+
border-radius: 4px;
|
|
180
|
+
overflow-x: auto;
|
|
181
|
+
margin: 1em 0;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.rte-preview-editor-light-editor pre code {
|
|
185
|
+
background: none;
|
|
186
|
+
padding: 0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.rte-preview-editor-light-editor img {
|
|
190
|
+
max-width: 100%;
|
|
191
|
+
height: auto;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.rte-preview-editor-light-editor a {
|
|
195
|
+
color: #007acc;
|
|
196
|
+
text-decoration: underline;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.rte-preview-editor-light-editor a:hover {
|
|
200
|
+
color: #0056b3;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/* Responsive design */
|
|
204
|
+
@media (max-width: 768px) {
|
|
205
|
+
.rte-preview-editor-overlay {
|
|
206
|
+
padding: 10px;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.rte-preview-editor-modal {
|
|
210
|
+
max-height: 95vh;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.rte-preview-editor-header {
|
|
214
|
+
padding: 12px 16px;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.rte-preview-editor-body {
|
|
218
|
+
padding: 16px;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.rte-preview-editor-light-editor {
|
|
222
|
+
padding: 12px;
|
|
223
|
+
font-size: 14px;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
`, document.head.appendChild(t);
|
|
227
|
+
}, v = () => {
|
|
228
|
+
const r = window.getSelection();
|
|
229
|
+
if (r && r.rangeCount > 0) {
|
|
230
|
+
let e = r.getRangeAt(0).startContainer;
|
|
231
|
+
for (; e && e !== document.body; ) {
|
|
232
|
+
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
233
|
+
const o = e;
|
|
234
|
+
if (o.getAttribute("contenteditable") === "true")
|
|
235
|
+
return o;
|
|
236
|
+
}
|
|
237
|
+
e = e.parentNode;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const t = document.activeElement;
|
|
241
|
+
if (t) {
|
|
242
|
+
if (t.getAttribute("contenteditable") === "true")
|
|
243
|
+
return t;
|
|
244
|
+
const e = t.closest('[contenteditable="true"]');
|
|
245
|
+
if (e) return e;
|
|
246
|
+
}
|
|
247
|
+
return document.querySelector('[contenteditable="true"]');
|
|
248
|
+
}, h = () => {
|
|
249
|
+
const r = v();
|
|
250
|
+
if (!r) return "";
|
|
251
|
+
const t = r.cloneNode(!0);
|
|
252
|
+
return [
|
|
253
|
+
".rte-floating-toolbar",
|
|
254
|
+
".rte-selection-marker",
|
|
255
|
+
".rte-toolbar",
|
|
256
|
+
".rte-resize-handle",
|
|
257
|
+
"[data-rte-internal]"
|
|
258
|
+
].forEach((o) => {
|
|
259
|
+
t.querySelectorAll(o).forEach((i) => i.remove());
|
|
260
|
+
}), t.innerHTML;
|
|
261
|
+
}, w = (r) => {
|
|
262
|
+
const t = document.createElement("div");
|
|
263
|
+
return t.innerHTML = r, t.querySelectorAll(
|
|
264
|
+
'script, iframe[src^="javascript:"], object, embed, form[action^="javascript:"]'
|
|
265
|
+
).forEach((i) => i.remove()), t.querySelectorAll("*").forEach((i) => {
|
|
266
|
+
Array.from(i.attributes).forEach((n) => {
|
|
267
|
+
n.name.startsWith("on") && i.removeAttribute(n.name), (n.name === "href" || n.name === "src") && n.value.startsWith("javascript:") && i.removeAttribute(n.name);
|
|
268
|
+
});
|
|
269
|
+
}), t.innerHTML;
|
|
270
|
+
}, u = () => {
|
|
271
|
+
if (typeof window > "u" || c) return;
|
|
272
|
+
c = !0, g();
|
|
273
|
+
const r = h(), t = w(r), e = document.createElement("div");
|
|
274
|
+
e.className = "rte-preview-editor-overlay", e.setAttribute("role", "dialog"), e.setAttribute("aria-modal", "true"), e.setAttribute("aria-labelledby", "preview-editor-title");
|
|
275
|
+
const o = document.createElement("div");
|
|
276
|
+
o.className = "rte-preview-editor-modal";
|
|
277
|
+
const i = document.createElement("div");
|
|
278
|
+
i.className = "rte-preview-editor-header", i.innerHTML = `
|
|
279
|
+
<h2 id="preview-editor-title">Preview Editor</h2>
|
|
280
|
+
<div class="rte-preview-editor-header-actions">
|
|
281
|
+
<button class="rte-preview-editor-close-btn" aria-label="Close preview editor">
|
|
282
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
283
|
+
<line x1="18" y1="6" x2="6" y2="18" />
|
|
284
|
+
<line x1="6" y1="6" x2="18" y2="18" />
|
|
285
|
+
</svg>
|
|
286
|
+
</button>
|
|
287
|
+
</div>
|
|
288
|
+
`;
|
|
289
|
+
const n = document.createElement("div");
|
|
290
|
+
n.className = "rte-preview-editor-body";
|
|
291
|
+
const a = document.createElement("div");
|
|
292
|
+
a.className = "rte-preview-editor-content";
|
|
293
|
+
const l = document.createElement("div");
|
|
294
|
+
l.className = "rte-preview-editor-light-editor", l.innerHTML = t, a.appendChild(l), n.appendChild(a), o.appendChild(i), o.appendChild(n), e.appendChild(o);
|
|
295
|
+
const p = () => {
|
|
296
|
+
e.parentNode && e.parentNode.removeChild(e), c = !1, document.removeEventListener("keydown", s);
|
|
297
|
+
}, s = (d) => {
|
|
298
|
+
d.key === "Escape" && (d.preventDefault(), d.stopPropagation(), p());
|
|
299
|
+
}, m = i.querySelector(".rte-preview-editor-close-btn");
|
|
300
|
+
m && m.addEventListener("click", (d) => {
|
|
301
|
+
d.preventDefault(), d.stopPropagation(), p();
|
|
302
|
+
}), e.addEventListener("click", (d) => {
|
|
303
|
+
d.target === e && p();
|
|
304
|
+
}), document.addEventListener("keydown", s), document.body.appendChild(e);
|
|
305
|
+
}, f = () => ({
|
|
306
|
+
name: "preview",
|
|
307
|
+
toolbar: [
|
|
308
|
+
{
|
|
309
|
+
label: "Preview",
|
|
310
|
+
command: "togglePreview",
|
|
311
|
+
icon: '<svg fill="#000000" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 92 92" enable-background="new 0 0 92 92" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path id="XMLID_1239_" d="M91.3,43.8C90.6,42.8,74.4,19,46,19C17.6,19,1.4,42.8,0.7,43.8c-0.9,1.3-0.9,3.1,0,4.5 C1.4,49.2,17.6,73,46,73c28.4,0,44.6-23.8,45.3-24.8C92.2,46.9,92.2,45.1,91.3,43.8z M46,65C26.7,65,13.5,51.4,9,46 c4.5-5.5,17.6-19,37-19c19.3,0,32.5,13.6,37,19C78.4,51.5,65.3,65,46,65z M48.3,29.6c-4.4-0.6-8.7,0.5-12.3,3.2c0,0,0,0,0,0 c-7.3,5.5-8.8,15.9-3.3,23.2c2.7,3.6,6.5,5.8,10.9,6.5c0.8,0.1,1.6,0.2,2.3,0.2c3.6,0,7-1.2,9.9-3.3c7.3-5.5,8.8-15.9,3.3-23.2 C56.6,32.5,52.7,30.2,48.3,29.6z M52.3,54.5c-2.2,1.7-5,2.4-7.8,2c-2.8-0.4-5.3-1.9-7-4.1C34.1,47.7,35,41,39.7,37.5 c2.2-1.7,5-2.4,7.8-2c2.8,0.4,5.3,1.9,7,4.1C57.9,44.3,57,51,52.3,54.5z M51.9,40c0.8,0.7,1.2,1.8,1.2,2.8c0,1-0.4,2.1-1.2,2.8 c-0.7,0.7-1.8,1.2-2.8,1.2c-1.1,0-2.1-0.4-2.8-1.2c-0.8-0.8-1.2-1.8-1.2-2.8c0-1.1,0.4-2.1,1.2-2.8c0.7-0.8,1.8-1.2,2.8-1.2 C50.2,38.9,51.2,39.3,51.9,40z"></path> </g></svg>'
|
|
312
|
+
}
|
|
313
|
+
],
|
|
314
|
+
commands: {
|
|
315
|
+
togglePreview: () => (u(), !0)
|
|
316
|
+
},
|
|
317
|
+
keymap: {}
|
|
318
|
+
});
|
|
319
|
+
export {
|
|
320
|
+
f as PreviewPlugin
|
|
321
|
+
};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
(function(l,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(l=typeof globalThis<"u"?globalThis:l||self,a(l.previewPlugin={}))})(this,(function(l){"use strict";let a=!1;const v=()=>{if(typeof document>"u")return;const r="rte-preview-plugin-styles";if(document.getElementById(r))return;const t=document.createElement("style");t.id=r,t.textContent=`
|
|
2
|
+
/* Preview Editor Dialog Styles */
|
|
3
|
+
.rte-preview-editor-overlay {
|
|
4
|
+
position: fixed !important;
|
|
5
|
+
top: 0 !important;
|
|
6
|
+
left: 0 !important;
|
|
7
|
+
right: 0 !important;
|
|
8
|
+
bottom: 0 !important;
|
|
9
|
+
width: 100vw !important;
|
|
10
|
+
height: 100vh !important;
|
|
11
|
+
background-color: rgba(0, 0, 0, 0.6) !important;
|
|
12
|
+
display: flex !important;
|
|
13
|
+
align-items: center !important;
|
|
14
|
+
justify-content: center !important;
|
|
15
|
+
z-index: 10000 !important;
|
|
16
|
+
padding: 20px !important;
|
|
17
|
+
box-sizing: border-box !important;
|
|
18
|
+
margin: 0 !important;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.rte-preview-editor-modal {
|
|
22
|
+
background: white;
|
|
23
|
+
border-radius: 8px;
|
|
24
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
25
|
+
width: 100%;
|
|
26
|
+
max-width: 1200px;
|
|
27
|
+
max-height: 90vh;
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
position: relative;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.rte-preview-editor-header {
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: space-between;
|
|
38
|
+
padding: 16px 20px;
|
|
39
|
+
border-bottom: 1px solid #e1e5e9;
|
|
40
|
+
background: #f8f9fa;
|
|
41
|
+
border-radius: 8px 8px 0 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.rte-preview-editor-header h2 {
|
|
45
|
+
margin: 0;
|
|
46
|
+
font-size: 18px;
|
|
47
|
+
font-weight: 600;
|
|
48
|
+
color: #1a1a1a;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.rte-preview-editor-header-actions {
|
|
52
|
+
display: flex;
|
|
53
|
+
gap: 8px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.rte-preview-editor-close-btn {
|
|
57
|
+
background: none;
|
|
58
|
+
border: none;
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
padding: 4px;
|
|
61
|
+
border-radius: 4px;
|
|
62
|
+
color: #666;
|
|
63
|
+
font-size: 16px;
|
|
64
|
+
line-height: 1;
|
|
65
|
+
transition: all 0.2s ease;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.rte-preview-editor-close-btn:hover {
|
|
69
|
+
background: #e1e5e9;
|
|
70
|
+
color: #1a1a1a;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.rte-preview-editor-body {
|
|
74
|
+
flex: 1;
|
|
75
|
+
overflow: auto;
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: column;
|
|
78
|
+
padding: 25px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.rte-preview-editor-content {
|
|
82
|
+
flex: 1;
|
|
83
|
+
display: flex;
|
|
84
|
+
flex-direction: column;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.rte-preview-editor-light-editor {
|
|
88
|
+
flex: 1;
|
|
89
|
+
overflow: auto;
|
|
90
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
91
|
+
font-size: 16px;
|
|
92
|
+
line-height: 1.6;
|
|
93
|
+
color: #1a1a1a;
|
|
94
|
+
padding: 20px;
|
|
95
|
+
background: #fafafa;
|
|
96
|
+
border: 1px solid #e1e5e9;
|
|
97
|
+
border-radius: 4px;
|
|
98
|
+
min-height: 400px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.rte-preview-editor-light-editor h1,
|
|
102
|
+
.rte-preview-editor-light-editor h2,
|
|
103
|
+
.rte-preview-editor-light-editor h3,
|
|
104
|
+
.rte-preview-editor-light-editor h4,
|
|
105
|
+
.rte-preview-editor-light-editor h5,
|
|
106
|
+
.rte-preview-editor-light-editor h6 {
|
|
107
|
+
margin-top: 1.5em;
|
|
108
|
+
margin-bottom: 0.5em;
|
|
109
|
+
font-weight: 600;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.rte-preview-editor-light-editor h1 {
|
|
113
|
+
font-size: 2em;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.rte-preview-editor-light-editor h2 {
|
|
117
|
+
font-size: 1.5em;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.rte-preview-editor-light-editor h3 {
|
|
121
|
+
font-size: 1.25em;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.rte-preview-editor-light-editor p {
|
|
125
|
+
margin: 1em 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.rte-preview-editor-light-editor ul,
|
|
129
|
+
.rte-preview-editor-light-editor ol {
|
|
130
|
+
padding-left: 2em;
|
|
131
|
+
margin: 1em 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.rte-preview-editor-light-editor li {
|
|
135
|
+
margin: 0.5em 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.rte-preview-editor-light-editor table {
|
|
139
|
+
border-collapse: collapse;
|
|
140
|
+
width: 100%;
|
|
141
|
+
margin: 1em 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.rte-preview-editor-light-editor table td,
|
|
145
|
+
.rte-preview-editor-light-editor table th {
|
|
146
|
+
border: 1px solid #ddd;
|
|
147
|
+
padding: 0.5em;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.rte-preview-editor-light-editor table th {
|
|
151
|
+
background: #f5f5f5;
|
|
152
|
+
font-weight: 600;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.rte-preview-editor-light-editor blockquote {
|
|
156
|
+
border-left: 4px solid #ddd;
|
|
157
|
+
margin: 1em 0;
|
|
158
|
+
padding-left: 1em;
|
|
159
|
+
color: #666;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.rte-preview-editor-light-editor code {
|
|
163
|
+
background: #f5f5f5;
|
|
164
|
+
padding: 2px 6px;
|
|
165
|
+
border-radius: 3px;
|
|
166
|
+
font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
|
|
167
|
+
font-size: 0.9em;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.rte-preview-editor-light-editor pre {
|
|
171
|
+
background: #f5f5f5;
|
|
172
|
+
padding: 1em;
|
|
173
|
+
border-radius: 4px;
|
|
174
|
+
overflow-x: auto;
|
|
175
|
+
margin: 1em 0;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.rte-preview-editor-light-editor pre code {
|
|
179
|
+
background: none;
|
|
180
|
+
padding: 0;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.rte-preview-editor-light-editor img {
|
|
184
|
+
max-width: 100%;
|
|
185
|
+
height: auto;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.rte-preview-editor-light-editor a {
|
|
189
|
+
color: #007acc;
|
|
190
|
+
text-decoration: underline;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.rte-preview-editor-light-editor a:hover {
|
|
194
|
+
color: #0056b3;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/* Responsive design */
|
|
198
|
+
@media (max-width: 768px) {
|
|
199
|
+
.rte-preview-editor-overlay {
|
|
200
|
+
padding: 10px;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.rte-preview-editor-modal {
|
|
204
|
+
max-height: 95vh;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.rte-preview-editor-header {
|
|
208
|
+
padding: 12px 16px;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.rte-preview-editor-body {
|
|
212
|
+
padding: 16px;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.rte-preview-editor-light-editor {
|
|
216
|
+
padding: 12px;
|
|
217
|
+
font-size: 14px;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
`,document.head.appendChild(t)},h=()=>{const r=window.getSelection();if(r&&r.rangeCount>0){let e=r.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const o=e;if(o.getAttribute("contenteditable")==="true")return o}e=e.parentNode}}const t=document.activeElement;if(t){if(t.getAttribute("contenteditable")==="true")return t;const e=t.closest('[contenteditable="true"]');if(e)return e}return document.querySelector('[contenteditable="true"]')},u=()=>{const r=h();if(!r)return"";const t=r.cloneNode(!0);return[".rte-floating-toolbar",".rte-selection-marker",".rte-toolbar",".rte-resize-handle","[data-rte-internal]"].forEach(o=>{t.querySelectorAll(o).forEach(i=>i.remove())}),t.innerHTML},w=r=>{const t=document.createElement("div");return t.innerHTML=r,t.querySelectorAll('script, iframe[src^="javascript:"], object, embed, form[action^="javascript:"]').forEach(i=>i.remove()),t.querySelectorAll("*").forEach(i=>{Array.from(i.attributes).forEach(n=>{n.name.startsWith("on")&&i.removeAttribute(n.name),(n.name==="href"||n.name==="src")&&n.value.startsWith("javascript:")&&i.removeAttribute(n.name)})}),t.innerHTML},f=()=>{if(typeof window>"u"||a)return;a=!0,v();const r=u(),t=w(r),e=document.createElement("div");e.className="rte-preview-editor-overlay",e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e.setAttribute("aria-labelledby","preview-editor-title");const o=document.createElement("div");o.className="rte-preview-editor-modal";const i=document.createElement("div");i.className="rte-preview-editor-header",i.innerHTML=`
|
|
221
|
+
<h2 id="preview-editor-title">Preview Editor</h2>
|
|
222
|
+
<div class="rte-preview-editor-header-actions">
|
|
223
|
+
<button class="rte-preview-editor-close-btn" aria-label="Close preview editor">
|
|
224
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
225
|
+
<line x1="18" y1="6" x2="6" y2="18" />
|
|
226
|
+
<line x1="6" y1="6" x2="18" y2="18" />
|
|
227
|
+
</svg>
|
|
228
|
+
</button>
|
|
229
|
+
</div>
|
|
230
|
+
`;const n=document.createElement("div");n.className="rte-preview-editor-body";const p=document.createElement("div");p.className="rte-preview-editor-content";const c=document.createElement("div");c.className="rte-preview-editor-light-editor",c.innerHTML=t,p.appendChild(c),n.appendChild(p),o.appendChild(i),o.appendChild(n),e.appendChild(o);const s=()=>{e.parentNode&&e.parentNode.removeChild(e),a=!1,document.removeEventListener("keydown",m)},m=d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),s())},g=i.querySelector(".rte-preview-editor-close-btn");g&&g.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),s()}),e.addEventListener("click",d=>{d.target===e&&s()}),document.addEventListener("keydown",m),document.body.appendChild(e)},b=()=>({name:"preview",toolbar:[{label:"Preview",command:"togglePreview",icon:'<svg fill="#000000" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 92 92" enable-background="new 0 0 92 92" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path id="XMLID_1239_" d="M91.3,43.8C90.6,42.8,74.4,19,46,19C17.6,19,1.4,42.8,0.7,43.8c-0.9,1.3-0.9,3.1,0,4.5 C1.4,49.2,17.6,73,46,73c28.4,0,44.6-23.8,45.3-24.8C92.2,46.9,92.2,45.1,91.3,43.8z M46,65C26.7,65,13.5,51.4,9,46 c4.5-5.5,17.6-19,37-19c19.3,0,32.5,13.6,37,19C78.4,51.5,65.3,65,46,65z M48.3,29.6c-4.4-0.6-8.7,0.5-12.3,3.2c0,0,0,0,0,0 c-7.3,5.5-8.8,15.9-3.3,23.2c2.7,3.6,6.5,5.8,10.9,6.5c0.8,0.1,1.6,0.2,2.3,0.2c3.6,0,7-1.2,9.9-3.3c7.3-5.5,8.8-15.9,3.3-23.2 C56.6,32.5,52.7,30.2,48.3,29.6z M52.3,54.5c-2.2,1.7-5,2.4-7.8,2c-2.8-0.4-5.3-1.9-7-4.1C34.1,47.7,35,41,39.7,37.5 c2.2-1.7,5-2.4,7.8-2c2.8,0.4,5.3,1.9,7,4.1C57.9,44.3,57,51,52.3,54.5z M51.9,40c0.8,0.7,1.2,1.8,1.2,2.8c0,1-0.4,2.1-1.2,2.8 c-0.7,0.7-1.8,1.2-2.8,1.2c-1.1,0-2.1-0.4-2.8-1.2c-0.8-0.8-1.2-1.8-1.2-2.8c0-1.1,0.4-2.1,1.2-2.8c0.7-0.8,1.8-1.2,2.8-1.2 C50.2,38.9,51.2,39.3,51.9,40z"></path> </g></svg>'}],commands:{togglePreview:()=>(f(),!0)},keymap:{}});l.PreviewPlugin=b,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@editora/preview",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Preview plugin for Rich Text Editor",
|
|
5
|
+
"authors": [
|
|
6
|
+
"Ajay Kumar <ajaykr089@gmail.com>"
|
|
7
|
+
],
|
|
8
|
+
"main": "dist/index.cjs.js",
|
|
9
|
+
"module": "dist/index.esm.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "vite build",
|
|
16
|
+
"dev": "vite build --watch",
|
|
17
|
+
"clean": "rm -rf dist"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@editora/core": "^1.0.5"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/react": "^18.0.0",
|
|
24
|
+
"typescript": "^5.0.0",
|
|
25
|
+
"vite": "^7.3.1"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"editora",
|
|
29
|
+
"rich-text-editor",
|
|
30
|
+
"plugin",
|
|
31
|
+
"preview-code",
|
|
32
|
+
"html-editor"
|
|
33
|
+
],
|
|
34
|
+
"author": "",
|
|
35
|
+
"license": "MIT"
|
|
36
|
+
}
|