-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathindex.html
689 lines (570 loc) · 21.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<link rel="canonical" href="https://stylojs.com" />
<title>Stylo - Another kind of rich text editor</title>
<meta content="Another kind of rich text editor" name="description" />
<meta content="Stylo" property="og:title" />
<meta content="Another kind of rich text editor" property="og:description" />
<meta content="website" property="og:type" />
<meta content="https://stylojs.com" property="og:url" />
<meta content="https://stylojs.com/assets/social-image.jpg" property="og:image" />
<meta content="summary_large_image" name="twitter:card" />
<meta content="David Dal Busco" name="twitter:creator" />
<meta content="Stylo" name="twitter:title" />
<meta content="Another kind of rich text editor" name="twitter:description" />
<meta content="https://stylojs.com/assets/social-image.jpg" name="twitter:image" />
<meta content="@daviddalbusco" name="twitter:creator" />
<link rel="manifest" href="/manifest.webmanifest" crossorigin="anonymous" />
<link href="/sitemap.xml" rel="sitemap" type="application/xml" />
<link rel="apple-touch-icon" sizes="180x180" href="/assets/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon-16x16.png" />
<link rel="mask-icon" href="/assets/safari-pinned-tab.svg" color="#ff65a9" />
<link rel="shortcut icon" href="/assets/favicon.ico" />
<meta name="msapplication-TileColor" content="#ff65a9" />
<meta name="msapplication-config" content="/assets/browserconfig.xml" />
<meta name="theme-color" content="#ffffff" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap"
rel="stylesheet" />
<script type="module" src="/build/stylo.esm.js"></script>
<script nomodule src="/build/stylo.js"></script>
<style>
:root {
font-family: 'Open Sans', sans-serif;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
--light: #f4f5f8;
--light-contrast: #000000;
--medium: #6e6d6f;
--medium-contrast: #000000;
--highlight: #ff65a9;
--highlight-rgb: 255, 101, 169;
--highlight-contrast: #ffffff;
--yellow: #f7ec59;
--yellow-rgb: 247, 236, 89;
--yellow-contrast: #000000;
--stylo-box-shadow: 3px 3px var(--highlight);
--stylo-border: 1px solid var(--highlight);
--stylo-toolbar-button-color-active: var(--highlight);
--stylo-list-background-active: rgba(var(--highlight-rgb), 0.2);
--stylo-toolbar-border-radius: 0;
--stylo-triangle-drop-shadow: 0px 1px 0px var(--highlight);
}
* {
box-sizing: border-box;
}
html {
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-weight: 400;
line-height: 1.75;
}
body,
html {
position: relative;
background: var(--light);
color: var(--light-contrast);
}
header {
display: flex;
justify-content: flex-end;
padding: 1.45rem 2.45rem 0;
width: 100%;
}
header svg,
footer svg {
width: 2rem;
}
section {
padding: 0 2.45rem 4.45rem;
display: block;
}
footer {
padding: 14.45rem 2.45rem 8.45rem;
background: black;
color: white;
}
section:not(.info),
header {
max-width: 1140px;
margin: 0 auto;
}
section.info > div {
max-width: calc(1140px - (2 * 2.45rem));
margin: 0 auto;
}
section.hero {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
text-align: center;
padding: 0 2.45rem 2.45rem;
}
section.hero h1 {
display: flex;
justify-content: center;
align-items: center;
font-size: 10rem;
text-shadow: 3px 3px black;
color: var(--highlight);
}
section.hero h2 {
margin-top: 0.45rem;
margin-bottom: 1.45rem;
}
section.hero div.links {
margin-top: 0.75rem;
}
section.hero div.links a {
text-decoration: none;
}
section.hero div.links a img {
height: 22px;
}
@media (max-width: 768px) {
section.hero h1 {
font-size: 4rem;
}
section.hero h2 {
margin-bottom: 0.45rem;
}
}
h1 {
letter-spacing: -0.036em;
}
h1,
h2,
h3,
h4,
h5 {
margin: 0 0 0.45rem;
font-weight: 400;
line-height: 1.3;
}
h1 {
margin-top: 0;
font-size: 2.488rem;
}
h2 {
font-size: 2.074rem;
}
h3 {
font-size: 1.728rem;
}
h4 {
font-size: 1.44rem;
}
h5 {
font-size: 1.2rem;
}
small {
font-size: 0.833rem;
}
a {
color: inherit;
background-color: transparent;
-webkit-text-decoration-skip: objects;
text-decoration: underline;
cursor: pointer;
}
a:active,
a:hover {
color: var(--highlight);
outline-width: 0;
}
a:hover,
a:focus {
text-decoration: underline;
}
a:focus,
a:focus-visible {
outline: none;
}
button,
a.action {
outline: 0;
cursor: pointer;
font-size: 1.953rem;
user-select: none;
display: inline-flex;
justify-content: center;
align-items: center;
margin: 0.45rem 0;
padding: 0.45rem;
width: fit-content;
text-decoration: none;
transition: color 0.25s ease-out, background 0.25s ease-out, transform 0.15s ease-out,
box-shadow 0.15s ease-out;
}
button:active,
a.action:active {
box-shadow: none;
transform: translateX(3px) translateY(3px);
}
button {
background: var(--highlight);
color: var(--highlight-contrast);
box-shadow: 3px 3px black;
border: 1px solid black;
}
button:hover {
background: var(--yellow);
color: var(--yellow-contrast);
}
a.action {
background: white;
color: black;
box-shadow: 3px 3px var(--highlight);
border: 1px solid var(--highlight);
}
a.action:hover {
background: var(--highlight);
color: var(--highlight-contrast);
box-shadow: 3px 3px var(--highlight-contrast);
border: 1px solid var(--highlight-contrast);
}
button:active,
a.action:active {
box-shadow: none;
transform: translateX(3px) translateY(3px);
}
hr {
height: 4em;
margin: 0 auto;
overflow: visible;
position: relative;
display: block;
border: none;
outline: none;
}
hr:before {
content: '...';
display: inline-block;
color: var(--medium);
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 1.6rem;
margin-top: -0.25rem;
margin-left: 0.6em;
letter-spacing: 0.6em;
}
code {
background: var(--light);
color: var(--light-contrast);
margin: 0.75rem 0;
padding: 1.25rem;
display: block;
box-shadow: 2px 2px #000;
border: 1px solid black;
}
section.editor {
position: relative;
}
section.editor article {
padding: 2.75rem;
outline: none;
margin: 0;
background: white;
box-shadow: 3px 3px #000;
border: 1px solid black;
position: relative;
}
@media (max-width: 768px) {
section.editor article {
padding: 2.75rem 1.25rem;
}
}
section.editor article > div,
section.editor article p {
margin: 0 0 0.45rem;
}
section.editor article img {
max-width: 100%;
margin: 0 auto;
display: block;
}
section.editor article mark {
font-family: Menlo, monospace;
background: rgba(0, 0, 0, 0.05);
padding: 0.5px 4px;
}
section.editor article blockquote {
border-left: 3px solid #000;
padding-left: 20px;
padding-bottom: 2px;
margin: 0.75rem 0 0.75rem -23px;
font-weight: bold;
font-style: italic;
}
section.editor article.highlight:after {
content: 'This content is editable!';
position: absolute;
inset: 0;
background: rgba(var(--yellow-rgb), 0.9);
color: var(--yellow-contrast);
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
font-size: 2.488rem;
text-align: center;
}
section.try {
display: flex;
justify-content: center;
padding: 0.45rem 2.45rem 5.45rem;
}
section.info {
background: white;
padding: 6.45rem 2.45rem;
border: 1px solid black;
}
section.info > div {
display: grid;
grid-template-columns: repeat(2, calc((100% - 4.45rem) / 2));
grid-column-gap: 4.45rem;
grid-row-gap: 0.75rem;
}
@media (max-width: 768px) {
section.info > div {
display: block;
}
}
section.info article {
padding: 1.25rem 1rem;
margin-bottom: 2.45rem;
}
section.info article:nth-of-type(1) {
box-shadow: 3px 3px #7371fc;
border: 1px solid #7371fc;
}
section.info article:nth-of-type(2) {
box-shadow: 3px 3px #b96bd3;
border: 1px solid #b96bd3;
}
section.info article:nth-of-type(3) {
box-shadow: 3px 3px #dc68be;
border: 1px solid #dc68be;
}
section.info article:nth-of-type(4) {
box-shadow: 3px 3px #ee67b4;
border: 1px solid #ee67b4;
}
footer {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: var(--light);
}
footer svg {
margin-right: 0.45rem;
}
footer a:hover svg {
color: inherit;
}
footer .made {
margin: 8.45rem 0 0.75rem;
}
footer a.papyrs {
display: flex;
justify-content: center;
align-items: center;
font-size: 1.44rem;
text-decoration: none;
}
</style>
</head>
<body>
<header>
<a aria-label="GitHub" href="https://github.com/papyrs/stylo" rel="noopener noreferrer">
<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
<path
d="M256 32C132.3 32 32 134.9 32 261.7c0 101.5 64.2 187.5 153.2 217.9a17.56 17.56 0 003.8.4c8.3 0 11.5-6.1 11.5-11.4 0-5.5-.2-19.9-.3-39.1a102.4 102.4 0 01-22.6 2.7c-43.1 0-52.9-33.5-52.9-33.5-10.2-26.5-24.9-33.6-24.9-33.6-19.5-13.7-.1-14.1 1.4-14.1h.1c22.5 2 34.3 23.8 34.3 23.8 11.2 19.6 26.2 25.1 39.6 25.1a63 63 0 0025.6-6c2-14.8 7.8-24.9 14.2-30.7-49.7-5.8-102-25.5-102-113.5 0-25.1 8.7-45.6 23-61.6-2.3-5.8-10-29.2 2.2-60.8a18.64 18.64 0 015-.5c8.1 0 26.4 3.1 56.6 24.1a208.21 208.21 0 01112.2 0c30.2-21 48.5-24.1 56.6-24.1a18.64 18.64 0 015 .5c12.2 31.6 4.5 55 2.2 60.8 14.3 16.1 23 36.6 23 61.6 0 88.2-52.4 107.6-102.3 113.3 8 7.1 15.2 21.1 15.2 42.5 0 30.7-.3 55.5-.3 63 0 5.4 3.1 11.5 11.4 11.5a19.35 19.35 0 004-.4C415.9 449.2 480 363.1 480 261.7 480 134.9 379.7 32 256 32z"
fill="currentColor" />
</svg>
</a>
</header>
<section class="hero">
<h1>Stylo</h1>
<h2>Another kind of rich text editor.</h2>
<div class="links">
<a
href="https://github.com/papyrs/stylo/releases/latest"
aria-label="Last GitHub release version"
rel="noopener noreferrer"
><img
src="https://img.shields.io/github/release/papyrs/stylo/all?logo=GitHub&color=lightgrey"
/></a>
<a
href="https://twitter.com/intent/tweet?url=https%3A%2F%2Fstylojs.com&text=Another%20kind%20of%20rich%20text%20editor%20by%20%40PapyrsApp"
aria-label="Share a tweet about Stylo"
rel="noopener noreferrer">
<img src="https://img.shields.io/twitter/url?url=https%3A%2F%2Fstylojs.com" />
</a>
</div>
</section>
<section class="editor">
<!-- prettier-ignore -->
<article contenteditable="true">
<h2 paragraph_id><span style="color: rgb(255, 101, 169);">Stylo</span></h2>
<div paragraph_id>Stylo is an open source <a href="https://en.wikipedia.org/wiki/WYSIWYG" rel="noopener noreferrer">WYSIWYG</a> interactive editor for JavaScript. Its goal is to bring great user experience and interactivity to the web, for everyone, with no dependencies. Stylo is a <a href="https://papy.rs" rel="noopener noreferrer">Papyrs</a> project.</div>
<hr paragraph_id />
<div paragraph_id>This is an <span style="font-weight: bold">​alpha</span>​ version! ⚠️ The project is under active development and contributions on <a href="https://github.com/papyrs/stylo" rel="noopener noreferrer">GitHub</a> are most welcome.</div>
<hr paragraph_id/>
<h2 paragraph_id>Features</h2>
<ul paragraph_id><li>Interactive design 🎯</li><li>Customizable 💪</li><li>Framework agnostic 😎</li><li>Lightweight (30kb gzipped, 0 deps) 🪶</li><li>Future Proof 🚀</li><li>Open Source (MIT license) ⭐️</li></ul>
<hr paragraph_id/>
<div paragraph_id>Select text and use the floating toolbar to apply style or transform to url. It supports keyboard shortcuts as well: Control or Command-{b, i, u, k} for bold, italic, underline & insert hyperlink.</div>
<hr paragraph_id/>
<div paragraph_id>Pro tips: trigger <span style="font-weight: bold;">bold</span> mode with "**", <span style="font-style: italic">italic</span> mode with whitespace and "_", and <mark>mark</mark> mode with "`" while you are typing. 👾</div>
<div paragraph_id>​</div>
<div paragraph_id>Cheers<br/>David</div>
<div paragraph_id>​</div>
<img paragraph_id src="/assets/mogwai.jpg" loading="lazy" style="width: 50%;" />
</article>
<stylo-editor> </stylo-editor>
</section>
<section class="try"><button>Try it out!</button></section>
<section class="info">
<div>
<article>
<h3>Interactive design 🎯</h3>
<p>
Stylo aims first and foremost for a <strong>clean design</strong> and an intuitive
<strong>user experience</strong>. We want users to have the feature they need, right at
their fingertips.
</p>
</article>
<article>
<h3>Customizable 💪</h3>
<p>
Based on a set of plugins that can be <strong>fully customized</strong>, enabling
additional functionality or disabling default features is made easy.
</p>
</article>
<article>
<h3>Framework agnostic 😎</h3>
<p>
The editor is a <strong>lightweight</strong> (30k gzipped) and
<strong>framework agnostic</strong> library of reusable components.
</p>
<p>No 3rd party runtime dependencies. Works on all modern browsers.</p>
<p>The code is published under the MIT license and contributions are most welcome!</p>
</article>
<article>
<h3>Future Proof 🚀</h3>
<p>
Stylo controls what happens on every mutation. While a handful of actions in the alpha
version still rely on
<a
href="https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand"
rel="noopener noreferrer"
>execCommand</a
>
to apply styles (e.g. bold, italic) - the core of the library does not. Stylo is built
for the <strong>future</strong>.
</p>
</article>
</div>
</section>
<footer>
<a
aria-label="GitHub"
href="https://github.com/papyrs/stylo"
rel="noopener noreferrer"
class="action">
<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
<path
d="M256 32C132.3 32 32 134.9 32 261.7c0 101.5 64.2 187.5 153.2 217.9a17.56 17.56 0 003.8.4c8.3 0 11.5-6.1 11.5-11.4 0-5.5-.2-19.9-.3-39.1a102.4 102.4 0 01-22.6 2.7c-43.1 0-52.9-33.5-52.9-33.5-10.2-26.5-24.9-33.6-24.9-33.6-19.5-13.7-.1-14.1 1.4-14.1h.1c22.5 2 34.3 23.8 34.3 23.8 11.2 19.6 26.2 25.1 39.6 25.1a63 63 0 0025.6-6c2-14.8 7.8-24.9 14.2-30.7-49.7-5.8-102-25.5-102-113.5 0-25.1 8.7-45.6 23-61.6-2.3-5.8-10-29.2 2.2-60.8a18.64 18.64 0 015-.5c8.1 0 26.4 3.1 56.6 24.1a208.21 208.21 0 01112.2 0c30.2-21 48.5-24.1 56.6-24.1a18.64 18.64 0 015 .5c12.2 31.6 4.5 55 2.2 60.8 14.3 16.1 23 36.6 23 61.6 0 88.2-52.4 107.6-102.3 113.3 8 7.1 15.2 21.1 15.2 42.5 0 30.7-.3 55.5-.3 63 0 5.4 3.1 11.5 11.4 11.5a19.35 19.35 0 004-.4C415.9 449.2 480 363.1 480 261.7 480 134.9 379.7 32 256 32z"
fill="currentColor" />
</svg>
View on GitHub
</a>
<span class="made"><small>Made by</small></span>
<a aria-label="Papyrs" href="https://papy.rs" rel="noopener noreferrer" class="papyrs">
<svg width="100%" height="100%" viewBox="0 0 33 34" xmlns="http://www.w3.org/2000/svg">
<g transform="matrix(1,0,0,1,30,10.596)">
<path
d="M0,8.808L0,-10.596L-30,-10.596L-30,19.404L-10.596,19.404L0,8.808Z"
style="fill: black; fill-rule: nonzero" />
</g>
<g transform="matrix(1,0,0,1,12.5867,15.7577)">
<path
d="M0,-1.296L1.782,-1.296C2.358,-1.296 2.817,-1.455 3.159,-1.774C3.501,-2.091 3.672,-2.514 3.672,-3.042C3.672,-3.57 3.501,-3.993 3.159,-4.312C2.817,-4.629 2.358,-4.788 1.782,-4.788L0,-4.788L0,-1.296ZM-2.7,5.922L-2.7,-7.218L1.782,-7.218C2.706,-7.218 3.513,-7.044 4.203,-6.696C4.893,-6.348 5.427,-5.862 5.805,-5.238C6.183,-4.614 6.372,-3.882 6.372,-3.042C6.372,-2.214 6.18,-1.485 5.796,-0.856C5.412,-0.226 4.878,0.264 4.194,0.612C3.51,0.96 2.706,1.134 1.782,1.134L0,1.134L0,5.922L-2.7,5.922Z"
style="fill: currentColor; fill-rule: nonzero" />
</g>
<g transform="matrix(1,0,0,1,2,31.0005)">
<path
d="M0,-29L26,-29L26,-12.925L15.958,-12.925L15.958,-3L0,-3L0,-29ZM28,-28L28,-31L-2,-31L-2,-1L1,-1L1,2L17.404,2L31,-11.596L31,-28L28,-28Z"
style="fill: currentColor; fill-rule: nonzero" />
</g>
<g transform="matrix(1,0,0,1,19.9584,20.0762)">
<path
d="M0,8.094L0,0L8.094,0L0,8.094Z"
style="fill: currentColor; fill-rule: nonzero" />
</g>
</svg>
Papyrs
</a>
</footer>
<script type="module">
import {imgMenu} from './build/index.esm.js';
const isTouchScreen = () => window.matchMedia('(any-pointer:coarse)').matches;
const initStylo = () => {
const stylo = document.querySelector('stylo-editor');
// Wait until hydrated and init
const styloObserver = new MutationObserver(() => {
styloObserver.disconnect();
const article = document.querySelector('article');
stylo.containerRef = article;
stylo.config = {
menus: [imgMenu]
};
// stylo.addEventListener('addParagraphs', ($event) => console.log('addParagraphs', $event));
// stylo.addEventListener('deleteParagraphs', ($event) =>
// console.log('deleteParagraphs', $event)
// );
// stylo.addEventListener('updateParagraphs', ($event) =>
// console.log('updateParagraphs', $event)
// );
});
styloObserver.observe(stylo, {attributes: true});
};
const onTry = () => {
const article = document.querySelector('article');
article?.scrollIntoView({behavior: 'smooth', block: 'center', inline: 'start'});
article?.classList.add('highlight');
article?.setAttribute('contenteditable', 'true');
setTimeout(() => article?.classList.remove('highlight'), 1250);
};
document.addEventListener('DOMContentLoaded', () => {
initStylo();
document
.querySelector('section.try button')
?.addEventListener('click', onTry, {passive: true});
if (isTouchScreen()) {
document
.querySelector('section.editor article')
?.setAttribute('contenteditable', 'false');
}
});
</script>
</body>
</html>