-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOn-Page-Editing.html
608 lines (504 loc) · 51.2 KB
/
On-Page-Editing.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="manifest" href="/manifest.json" />
<link rel="icon" href="/images/icons/icon-152x152.png" />
<!-- theme-color defines the top bar color-->
<meta name="theme-color" content="#575757" />
<meta
http-equiv="X-Content-Security-Policy"
content="default-src 'self'; script-src 'report-sample' 'self' https://app.posthog.com/static/array.js https://www.googletagmanager.com/gtag/js; style-src 'report-sample' 'self' https://fonts.googleapis.com; object-src 'none'; base-uri 'self'; connect-src 'self' https://app.posthog.com; font-src 'self'; frame-src 'self'; img-src 'self'; manifest-src 'self'; media-src 'self'; report-uri https://pauldambra.report-uri.com/r/d/csp/enforce; worker-src 'self';"
/>
<!-- Add to home screen for Safari on iOS-->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
<meta name="apple-mobile-web-app-title" content="MiRaNo" />
<link rel="apple-touch-icon" href="/images/icons/icon-152x152.png" />
<!-- Add to home screen for Windows-->
<meta
name="msapplication-TileImage"
content="/images/icons/icon-152x152.png"
/>
<meta name="msapplication-TileColor" content="#575757" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Websites != CMS Platform - On Page Editing</title>
<link rel="canonical" href="https://pauldambra.dev/On-Page-Editing.html" />
<meta property="og:url" content="https://pauldambra.dev/On-Page-Editing.html" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Websites != CMS Platform - On Page Editing" />
<meta
property="og:description"
content="using contenteditable in HTML5 to make pages editable"
/>
<meta
property="og:image"
content="https://pauldambra.dev/images/cardboard.jpg"
/>
<meta name="twitter:creator" content="@pauldambra" />
<meta property="fb:app_id" content="1029758320473951" />
<meta name="viewport" content="width=device-width" />
<meta
name="description"
content="using contenteditable in HTML5 to make pages editable"
/>
<meta property="fb:pages" content="1029758320473951" />
<link
rel="alternate"
type="application/rss+xml"
title="Mindless Rambling Nonsense"
href="https://pauldambra.dev/feed.xml"
/>
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="prefetch" href="/images/cardboard.jpg" />
<link rel="stylesheet" href="/assets/css/main.css">
<link rel="stylesheet" href="/assets/css/syntax.css">
<meta name="msvalidate.01" content="54691C3C7B863CEE60F0305D6EDFF7A8" />
<meta
name="google-site-verification"
content="hLKEdujpXNQ9PSZWEcQkwxCgL2z1tWxVedeaUmttH7c"
/>
<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.crossOrigin="anonymous",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="init capture register register_once register_for_session unregister unregister_for_session getFeatureFlag getFeatureFlagPayload isFeatureEnabled reloadFeatureFlags updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures on onFeatureFlags onSessionId getSurveys getActiveMatchingSurveys renderSurvey canRenderSurvey getNextSurveyStep identify setPersonProperties group resetGroups setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags reset get_distinct_id getGroups get_session_id get_session_replay_url alias set_config startSessionRecording stopSessionRecording sessionRecordingStarted captureException loadToolbar get_property getSessionProperty createPersonProfile opt_in_capturing opt_out_capturing has_opted_in_capturing has_opted_out_capturing clear_opt_in_out_capturing debug".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('phc_xcwOfYtGDcfv8619HtTWgHEfVMeTqS5YKkBsVEpy1ns', {
api_host:'https://ph.pauldambra.dev',
person_profiles: 'identified_only' // or 'always' to create profiles for anonymous users as well
})
</script>
</head>
<body class="flex flex-col h-screen">
<header class="flex flex-col px-8 pt-4 text-white text-xl" role="banner">
<div class="flex flex-col sm:flex-row">
<div class="no-underline hover:underline">
<a href="/">Mindless Rambling Nonsense</a>
</div>
<div class="flex-grow my-2 sm:m-0"></div>
<div class="flex justify-start items-end flex-col text-sm">
<div class="flex items-center">
<div class="mr-4">Paul D'Ambra</div>
<a href="https://github.com/pauldambra" rel="noopener">
<img
src="/images/GitHub-Mark-Light-32px.png"
alt="pauldambra on github"
width="32"
height="32"
/>
</a>
</div>
<div class="flex items-center">
<div class="mr-4">Fangler</div>
<a href="https://twitter.com/pauldambra" rel="noopener">
<img
src="/images/twitter-32.png"
alt="pauldambra on twitter"
width="32"
height="32"
/>
</a>
</div>
<div class="flex items-center">
<div class="mr-4"></div>
<a rel="me" href="https://mastodon.me.uk/@pauldambra">
</a>
</div>
</div>
</div>
<div class="flex-grow"></div>
<div
class="flex align-middle items-start px-2 py-4 text-white space-x-4 text-lg"
>
<nav role="navigation">
<a class="underline" href="/">Blog Posts</a>
<a class="underline ml-5" href="/weeknotes.html">Week Notes</a>
<a class="underline ml-5" href="/kids-games.html">Kids games</a>
</nav>
</div>
</header>
<main role="main" class="bg-white p-4 w-11/12 m-auto flex-auto flex-grow">
<script type="application/ld+json">
{
"@context":"http://schema.org",
"@type":"BlogPosting",
"headline":"Websites != CMS Platform - On Page Editing",
"genre":"",
"keywords":"",
"wordCount":"2172",
"url":"https://pauldambra.dev/On-Page-Editing.html",
"datePublished":"2014-06-11",
"author":{
"@type":"Person",
"name":"Paul D'Ambra",
"sameAs":[
"https://twitter.com/pauldambra",
"https://github.com/pauldambra",
"https://plus.google.com/u/0/+PaulDAmbraPlus"
]
},
"publisher":{
"@type": "Organization",
"name": "Paul D'Ambra",
"sameAs": [
"https://twitter.com/pauldambra",
"https://github.com/pauldambra",
"https://plus.google.com/u/0/+PaulDAmbraPlus"
],
"logo": {
"@type": "ImageObject",
"contentUrl": "https://pauldambra.dev/images/logo.png",
"url": "https://pauldambra.dev"
}
},
"image":{
"@type":"ImageObject",
"contentUrl":"https://pauldambra.dev/images/cardboard.jpg",
"url":"https://pauldambra.dev",
"height":"450",
"width":"1000"
},
"mainEntityOfPage":{
"@type":"WebPage",
"@id":"https://pauldambra.dev/On-Page-Editing.html"
},
"articleBody":"This post is part of a series where I'm hoping to prove to myself that building a dynamic website with NodeJS is much more fun than using a CMS platform. See the first post for an explanation of why\n\nThe code can be found on GitHub\n\nPrevious Post\n\nA.K.A. No More CMS-y Admin Section?\n\nA traditional CMS framework or website has an admin section for logged in users. That section has a menu showing them which sections the user can edit and each section has a list of the pages they can edit and then the user can edit the text or upload images using a WYSIWYG editor.\n\nDon't fix it if it aint broken but… but… HTML5 includes the contenteditable attribute which makes (the text of) almost any element editable.\n\nIf the admin section exists (in large part) to allow editing of content and editing of content can be completed in the page itself could this replace the admin section?\n\n\n\nCould it?!\n\nThe benefit I can see here is that your edits are in place. They're immediately reflected on screen so the editing user can see the impact they're having. A user may not grok why a developer has put a 25 character limit on a title field. But if they only change a title and it pushes the rest of the page out then it's their call whether that's OK.\n\nI can think of two problems with this:\n\n1. Users expect an admin interface.\n\nThey don't expect to edit in the page\nI've previously referenced \"Don't Make Me Think\" (shameless affiliate link) and that approach would drive the position that there's no point confusing a user only to be funky. This may be doing that…\n\n2. Is it discoverable?\n\nThe visual affordance to indicate that a user is able to edit an element needs to be worked in to the design.\n\nIf the user can't find what to edit then this doesn't work. Also, since part of the benefit is that the edits are in the page and the page has to change to indicate where edits are possible does that water down the benefit.\n\nI'm well out of my depth as far as design goes right now! If this was a real project I'd want to get a real designer or some actual users at this point and find out if this is a developer only idea…\n\nso how does it work?\n\nAs part of this piece of development I switched view engine to the hbs engine. I wanted partials and handlebars and this appears to offer both with little pain.\n\nrequire(\"./server/handlebars\").init(hbs, app.locals);\nhbs.registerPartials(__dirname + \"/views/partials\");\napp.engine(\"html\", hbs.__express);\n\n\nThis setup allows .hbs files stored in /views/partials to be used in {{>partialName }} handlebars blocks\n\nThe feature here is to have three columns of editable content. That's expressed in the home page layout…\n\n\n<div class=\"row info\">\n {{>panel panels.[0]}} {{>panel panels.[1]}} {{>panel panels.[2]}}\n</div>\n\n\n\nEach line calls for the panel partial and passes the given element from the panels array (or undefined)\n\nand a panel partial would be\n\n\n<div class=\"col-md-4\">\n <div class=\"panel panel-info\">\n <div class=\"panel-heading\">\n <h1 {{elementShouldBeEditable}}>{{safeString title}}</h1>\n </div>\n <div\n class=\"panel-body\"\n {{elementShouldBeEditable}}\n >\n {{safeString body}}\n </div>\n </div>\n</div>\n\n\n\nEach element that should be editable is marked with an {{elementShouldBeEditable}} handlebars helper and the content from the model is marked as safeString so that any HTML entered in the WYSIWYG editor is not escaped.\n\nThe Helpers\n\nAn editable element\n\nhandlebars.registerHelper(\"elementShouldBeEditable\", function () {\n if (appLocals.user) {\n return \"contenteditable=true\";\n }\n});\n\n\nThis is a standard Handlebars helper which checks if a user is set and if it is renders contenteditable=true in place.\n\nSafe Strings\n\nIf a WYSIWYG editor saves ` some bold text ` then that is exactly what will be printed on screen as handlebars will escape the HTML to protect you from l33t haxxors.\n\nhandlebars.registerHelper(\"safeString\", function (value) {\n return new handlebars.handlebars.SafeString(value);\n});\n\n\nreturning a handlebars safeString instead means that handlebars will trust the content and render some bold text\n\nThe JS\n\nThis is the first JS I've added to the client. So, while I initially wrote the JS directly in the HTML, I eventually moved it into its own files and hooked up gulp to concat and uglify it.\n\nGulp\n\nvar concat = require(\"gulp-concat\");\nvar uglify = require(\"gulp-uglify\");\n\ngulp.task(\"processJS\", function () {\n gulp\n .src([\"./public/js/*.js\"])\n .pipe(concat(\"app.js\"))\n .pipe(uglify())\n .pipe(gulp.dest(\"./public/js/\"));\n});\n\n\nThe gulp task is straightforward. On any change in a JS file in the public/js folder concat all the js files in that folder into a file called app.js, uglify that file and save it.\n\nThe main HTML page is then set to include that JS when a user is logged in\n\n {{#if user}}\n<script src=\"/js/app.js\"></script>\n{{/if}} \n\n\nMonitor the page for changes\n\nThe first task is to watch any contenteditable elements for changes to their content and to do something when a change is detected\n\n(function (omniclopse, $) {\n \"use strict\";\n\n //shamelessly borrowed from http://stackoverflow.com/a/14027188/222163\n omniclopse.bindEvents = function () {\n var before;\n var timer;\n $(\"*[contenteditable]\")\n .on(\"focus\", function () {\n before = $(this).html();\n })\n .on(\"keyup paste\", function () {\n if (before != $(this).html()) {\n clearTimeout(timer);\n timer = setTimeout(omniclopse.onContentEdited, 500);\n }\n });\n };\n})((window.omniclopse = window.omniclopse || {}), $);\n\n\nThis JS watched any element with a contenteditable attribute and if an element gets focus stores the HTML content as it was on focus. On keyup or paste if the content has changed then queue a call to the onContentEdited event handler.\n\nThis has a 500 millisecond delay so that the system waits until a person has stopped editing before taking any action.\n\nRespond to changes\n\nWhen a change is detected then the page is PUT to the server to persist those changes\n\n(function (omniclopse, $) {\n \"use strict\";\n\n //snip out addMessage for clarity of example\n\n omniclopse.onContentEdited = function () {\n var panels = $(\".panel\")\n .map(function (index, el) {\n var title = $(el).find(\"h1\");\n var body = $(el).find(\".panel-body\");\n return {\n title: title ? title.text() : \"\",\n body: body ? body.html() : \"\",\n };\n })\n .get();\n\n var putData = { panels: panels };\n $.ajax({\n url: \"/pages/home\",\n dataType: \"json\",\n contentType: \"application/json\",\n data: JSON.stringify(putData),\n type: \"PUT\",\n })\n .fail(function (xhr, status) {\n addMessage(\"could not save your changes\", \"alert-danger\");\n })\n .done(function () {\n addMessage(\"saved changes\", \"alert-success\");\n });\n };\n})((window.omniclopse = window.omniclopse || {}), $);\n\n\nSo here the page object expected by the server is gathered from the page and PUT using $.ajax. This bit of code is bound directly to the Home page at the moment but that can be remedied when necessary.\n\nAn addMessage function shows a bootstrap alert to keep the user informed of what is happening. This is a pretty dull piece of code!\n\nfunction alertTimeout(wait) {\n setTimeout(function () {\n $(\"#messageHolder\").children(\".alert:first-child\").alert().alert(\"close\");\n }, wait);\n}\n\nvar addMessage = function (message, bootstrapType) {\n var outer = $(\"<div/>\", {\n class: \"alert alert-dismissable \" + bootstrapType,\n });\n var button = $(\"<button/>\", {\n type: \"button\",\n class: \"close\",\n \"data-dismiss\": \"alert\",\n \"aria-hidden\": \"true\",\n });\n button.append(\"&times;\");\n outer.append(button);\n outer.append(message);\n $(\"#messageHolder\").append(outer);\n alertTimeout(3000);\n};\n\n\nVisual Affordance\n\nI found this a pretty hard design decision. I'm not sure I'm happy it really calls out what is happening to a user and I think I'll grab a designer the next time I'm next to one and ask their opinion but…\n\n\n\n\n\n@mixin editorPencil($size) {\n content: \"\\270f \";\n font-family: \"Glyphicons Halflings\";\n font-style: normal;\n font-size: $size;\n}\n\ndiv[contenteditable]:before {\n @include editorPencil(1em);\n}\n\nh1[contenteditable]:before {\n @include editorPencil(0.5em);\n}\n\n\nSince the site is already using bootstrap CSS was added that uses :before to add a pencil icon to any contenteditable div or H1.\n\nCKEditor\n\nAnother little bonus is that CKEditor is aware of contenteditable elements so including that in the page gives you WYSIWYG power directly on any contenteditable.\n\n\n\nAll that was necessary to hook it up was to include it in the page and to switch from using the valid <div content contenteditable/> to using <div content contenteditable=true/> a change I can live with to get the power of WYSIWYG directly on page elements\n\n(How) does it work?\n\nIf you watch the GIF below it's clear this is a working prototype and not a finished product. But it does work!\n\nThe page content is jumping about as alert messages are added and that's not OK so a better mechanism is necessary for highlighting that changes have been persisted.\n\nBut this was really fun to add and it needed very little code to do so.\n\n\n"
}
</script>
<article>
<header class="flex flex-col border-b-black border-b-2 bg-white text-black">
<div class="heading">
<div class="date">Wed Jun 11 2014</div>
<h1 class="title leading-10 pt-2 mb-0 mt-1">Websites != CMS Platform - On Page Editing</h1>
</div>
<div class="meta flex-grow flex flex-row">
<div class="share-this flex self-end space-x-2">
<a
id="facebook-share-link"
class="social-share"
target="_blank"
rel="noopener"
href="https://www.facebook.com/dialog/share?app_id=305449093152216&href=https://pauldambra.dev/On-Page-Editing.html"
>
<img
class="w-8"
src="/images/facebook-black-32.png"
alt="share on facebook"
width="32"
height="32"
/>
</a>
<a
id="twitter-share-link"
class="social-share"
target="_blank"
rel="noopener"
href="https://twitter.com/intent/tweet?text=Websites+%21%3D+CMS+Platform+-+On+Page+Editing&via=pauldambra&url=https://pauldambra.dev/On-Page-Editing.html"
>
<img
class="w-8"
src="/images/twitter-black-32.png"
alt="share on twitter"
width="32"
height="32"
/>
</a>
</div>
<div class="more-like-this text-right content-end flex-grow">
<a
class="post-metadata"
href="/categories.html#cms"
>
in: cms
</a>
<div>
<span class="text-slate-500">
<img class="w-6 h-6 inline-block" src="/images/tag.svg" alt="tag-icon" />
<a class="no-underline hover:underline" href="/tags.html#learning">
learning
</a>
</span>
<span class="text-slate-500">
<img class="w-6 h-6 inline-block" src="/images/tag.svg" alt="tag-icon" />
<a class="no-underline hover:underline" href="/tags.html#cms">
cms
</a>
</span>
<span class="text-slate-500">
<img class="w-6 h-6 inline-block" src="/images/tag.svg" alt="tag-icon" />
<a class="no-underline hover:underline" href="/tags.html#design">
design
</a>
</span>
<span class="text-slate-500">
<img class="w-6 h-6 inline-block" src="/images/tag.svg" alt="tag-icon" />
<a class="no-underline hover:underline" href="/tags.html#web">
web
</a>
</span>
<span class="text-slate-500">
<img class="w-6 h-6 inline-block" src="/images/tag.svg" alt="tag-icon" />
<a class="no-underline hover:underline" href="/tags.html#series">
series
</a>
</span>
</div>
</div>
</div>
</header>
<div class="post">
<p>This post is part of a series where I'm hoping to prove to myself that building a dynamic website with NodeJS is much more fun than using a CMS platform. <a href="/2014/02/websites-cms.html">See the first post for an explanation of why</a></p>
<p>The code can be found on <a href="https://github.com/pauldambra/omniclopse">GitHub</a></p>
<p><a href="/Websites-CMS-Platform-Storing-Data2.html">Previous Post</a></p>
<p>A.K.A. No More CMS-y Admin Section?</p>
<p>A traditional CMS framework or website has an admin section for logged in users. That section has a menu showing them which sections the user can edit and each section has a list of the pages they can edit and then the user can edit the text or upload images using a WYSIWYG editor.</p>
<p>Don't fix it if it aint broken but… but… HTML5 includes <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_Editable">the <code class="language-plaintext highlighter-rouge">contenteditable</code> attribute</a> which makes (the text of) almost any element editable.</p>
<p>If the admin section exists (in large part) to allow editing of content and editing of content can be completed in the page itself could this replace the admin section?</p>
<!--more-->
<h3 id="could-it">Could it?!</h3>
<p>The benefit I can see here is that your edits are in place. They're immediately reflected on screen so the editing user can see the impact they're having. A user may not grok why a developer has put a 25 character limit on a title field. But if they only change a title and it pushes the rest of the page out then it's their call whether that's OK.</p>
<p>I can think of two problems with this:</p>
<h4 id="1-users-expect-an-admin-interface">1. Users expect an admin interface.</h4>
<p>They don't expect to edit in the page
I've previously referenced "Don't Make Me Think" <a href="https://www.amazon.co.uk/Dont-Make-Me-Think-Usability/dp/B00HJUBRPG/ref=sr_1_1?s=books&ie=UTF8&qid=1473701528&sr=1-1&keywords=Don%27t+Make+Me+Think%3A+A+Common+Sense+Approach+to+Web+Usability+%28Voices+That+Matter%29">(shameless affiliate link)</a> and that approach would drive the position that there's no point confusing a user only to be funky. This may be doing that…</p>
<h4 id="2-is-it-discoverable">2. Is it discoverable?</h4>
<p>The visual affordance to indicate that a user is able to edit an element needs to be worked in to the design.</p>
<p>If the user can't find what to edit then this doesn't work. Also, since part of the benefit is that the edits are in the page and the page has to change to indicate where edits are possible does that water down the benefit.</p>
<p>I'm well out of my depth as far as design goes right now! If this was a real project I'd want to get a real designer or some actual users at this point and find out if this is a developer only idea…</p>
<h1 id="so-how-does-it-work">so how does it work?</h1>
<p>As part of this piece of development I switched view engine to the <a href="https://github.com/donpark/hbs">hbs engine</a>. I wanted partials and handlebars and this appears to offer both with little pain.</p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nf">require</span><span class="p">(</span><span class="dl">"</span><span class="s2">./server/handlebars</span><span class="dl">"</span><span class="p">).</span><span class="nf">init</span><span class="p">(</span><span class="nx">hbs</span><span class="p">,</span> <span class="nx">app</span><span class="p">.</span><span class="nx">locals</span><span class="p">);</span>
<span class="nx">hbs</span><span class="p">.</span><span class="nf">registerPartials</span><span class="p">(</span><span class="nx">__dirname</span> <span class="o">+</span> <span class="dl">"</span><span class="s2">/views/partials</span><span class="dl">"</span><span class="p">);</span>
<span class="nx">app</span><span class="p">.</span><span class="nf">engine</span><span class="p">(</span><span class="dl">"</span><span class="s2">html</span><span class="dl">"</span><span class="p">,</span> <span class="nx">hbs</span><span class="p">.</span><span class="nx">__express</span><span class="p">);</span>
</code></pre></div></div>
<p>This setup allows .hbs files stored in <code class="language-plaintext highlighter-rouge">/views/partials</code> to be used in <code class="language-plaintext highlighter-rouge">{{>partialName }}</code> handlebars blocks</p>
<p>The feature here is to have three columns of editable content. That's expressed in the home page layout…</p>
<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"row info"</span><span class="nt">></span>
{{>panel panels.[0]}} {{>panel panels.[1]}} {{>panel panels.[2]}}
<span class="nt"></div></span>
</code></pre></div></div>
<p>Each line calls for the panel partial and passes the given element from the panels array (or undefined)</p>
<p>and a panel partial would be</p>
<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"col-md-4"</span><span class="nt">></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"panel panel-info"</span><span class="nt">></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"panel-heading"</span><span class="nt">></span>
<span class="nt"><h1</span> <span class="err">{{</span><span class="na">elementShouldBeEditable</span><span class="err">}}</span><span class="nt">></span>{{safeString title}}<span class="nt"></h1></span>
<span class="nt"></div></span>
<span class="nt"><div</span>
<span class="na">class=</span><span class="s">"panel-body"</span>
<span class="err">{{</span><span class="na">elementShouldBeEditable</span><span class="err">}}</span>
<span class="nt">></span>
{{safeString body}}
<span class="nt"></div></span>
<span class="nt"></div></span>
<span class="nt"></div></span>
</code></pre></div></div>
<p>Each element that should be editable is marked with an <code class="language-plaintext highlighter-rouge">{{elementShouldBeEditable}}</code> handlebars helper and the content from the model is marked as <code class="language-plaintext highlighter-rouge">safeString</code> so that any HTML entered in the WYSIWYG editor is not escaped.</p>
<h2 id="the-helpers">The Helpers</h2>
<h2 id="an-editable-element">An editable element</h2>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">handlebars</span><span class="p">.</span><span class="nf">registerHelper</span><span class="p">(</span><span class="dl">"</span><span class="s2">elementShouldBeEditable</span><span class="dl">"</span><span class="p">,</span> <span class="nf">function </span><span class="p">()</span> <span class="p">{</span>
<span class="k">if </span><span class="p">(</span><span class="nx">appLocals</span><span class="p">.</span><span class="nx">user</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="dl">"</span><span class="s2">contenteditable=true</span><span class="dl">"</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">});</span>
</code></pre></div></div>
<p>This is a standard Handlebars helper which checks if a user is set and if it is renders <code class="language-plaintext highlighter-rouge">contenteditable=true</code> in place.</p>
<h3 id="safe-strings">Safe Strings</h3>
<p>If a WYSIWYG editor saves ` <b>some bold text</b> ` then that is exactly what will be printed on screen as handlebars will escape the HTML to protect you from l33t haxxors.</p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">handlebars</span><span class="p">.</span><span class="nf">registerHelper</span><span class="p">(</span><span class="dl">"</span><span class="s2">safeString</span><span class="dl">"</span><span class="p">,</span> <span class="nf">function </span><span class="p">(</span><span class="nx">value</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">new</span> <span class="nx">handlebars</span><span class="p">.</span><span class="nx">handlebars</span><span class="p">.</span><span class="nc">SafeString</span><span class="p">(</span><span class="nx">value</span><span class="p">);</span>
<span class="p">});</span>
</code></pre></div></div>
<p>returning a handlebars safeString instead means that handlebars will trust the content and render <strong>some bold text</strong></p>
<h1 id="the-js">The JS</h1>
<p>This is the first JS I've added to the client. So, while I initially wrote the JS directly in the HTML, I eventually moved it into its own files and hooked up gulp to concat and uglify it.</p>
<h3 id="gulp">Gulp</h3>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">concat</span> <span class="o">=</span> <span class="nf">require</span><span class="p">(</span><span class="dl">"</span><span class="s2">gulp-concat</span><span class="dl">"</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">uglify</span> <span class="o">=</span> <span class="nf">require</span><span class="p">(</span><span class="dl">"</span><span class="s2">gulp-uglify</span><span class="dl">"</span><span class="p">);</span>
<span class="nx">gulp</span><span class="p">.</span><span class="nf">task</span><span class="p">(</span><span class="dl">"</span><span class="s2">processJS</span><span class="dl">"</span><span class="p">,</span> <span class="nf">function </span><span class="p">()</span> <span class="p">{</span>
<span class="nx">gulp</span>
<span class="p">.</span><span class="nf">src</span><span class="p">([</span><span class="dl">"</span><span class="s2">./public/js/*.js</span><span class="dl">"</span><span class="p">])</span>
<span class="p">.</span><span class="nf">pipe</span><span class="p">(</span><span class="nf">concat</span><span class="p">(</span><span class="dl">"</span><span class="s2">app.js</span><span class="dl">"</span><span class="p">))</span>
<span class="p">.</span><span class="nf">pipe</span><span class="p">(</span><span class="nf">uglify</span><span class="p">())</span>
<span class="p">.</span><span class="nf">pipe</span><span class="p">(</span><span class="nx">gulp</span><span class="p">.</span><span class="nf">dest</span><span class="p">(</span><span class="dl">"</span><span class="s2">./public/js/</span><span class="dl">"</span><span class="p">));</span>
<span class="p">});</span>
</code></pre></div></div>
<p>The gulp task is straightforward. On any change in a JS file in the public/js folder concat all the js files in that folder into a file called app.js, uglify that file and save it.</p>
<p>The main HTML page is then set to include that JS <strong>when a user is logged in</strong></p>
<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code> {{#if user}}
<span class="nt"><script </span><span class="na">src=</span><span class="s">"/js/app.js"</span><span class="nt">></script></span>
{{/if}}
</code></pre></div></div>
<h3 id="monitor-the-page-for-changes"><a name="edit-event-js">Monitor the page for changes</a></h3>
<p>The first task is to watch any contenteditable elements for changes to their content and to do <em>something</em> when a change is detected</p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nf">function </span><span class="p">(</span><span class="nx">omniclopse</span><span class="p">,</span> <span class="nx">$</span><span class="p">)</span> <span class="p">{</span>
<span class="dl">"</span><span class="s2">use strict</span><span class="dl">"</span><span class="p">;</span>
<span class="c1">//shamelessly borrowed from http://stackoverflow.com/a/14027188/222163</span>
<span class="nx">omniclopse</span><span class="p">.</span><span class="nx">bindEvents</span> <span class="o">=</span> <span class="nf">function </span><span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">before</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">timer</span><span class="p">;</span>
<span class="nf">$</span><span class="p">(</span><span class="dl">"</span><span class="s2">*[contenteditable]</span><span class="dl">"</span><span class="p">)</span>
<span class="p">.</span><span class="nf">on</span><span class="p">(</span><span class="dl">"</span><span class="s2">focus</span><span class="dl">"</span><span class="p">,</span> <span class="nf">function </span><span class="p">()</span> <span class="p">{</span>
<span class="nx">before</span> <span class="o">=</span> <span class="nf">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nf">html</span><span class="p">();</span>
<span class="p">})</span>
<span class="p">.</span><span class="nf">on</span><span class="p">(</span><span class="dl">"</span><span class="s2">keyup paste</span><span class="dl">"</span><span class="p">,</span> <span class="nf">function </span><span class="p">()</span> <span class="p">{</span>
<span class="k">if </span><span class="p">(</span><span class="nx">before</span> <span class="o">!=</span> <span class="nf">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nf">html</span><span class="p">())</span> <span class="p">{</span>
<span class="nf">clearTimeout</span><span class="p">(</span><span class="nx">timer</span><span class="p">);</span>
<span class="nx">timer</span> <span class="o">=</span> <span class="nf">setTimeout</span><span class="p">(</span><span class="nx">omniclopse</span><span class="p">.</span><span class="nx">onContentEdited</span><span class="p">,</span> <span class="mi">500</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">});</span>
<span class="p">};</span>
<span class="p">})((</span><span class="nb">window</span><span class="p">.</span><span class="nx">omniclopse</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">omniclopse</span> <span class="o">||</span> <span class="p">{}),</span> <span class="nx">$</span><span class="p">);</span>
</code></pre></div></div>
<p>This JS watched any element with a contenteditable attribute and if an element gets focus stores the HTML content as it was on focus. On keyup or paste if the content has changed then queue a call to the onContentEdited event handler.</p>
<p>This has a 500 millisecond delay so that the system waits until a person has stopped editing before taking any action.</p>
<h3 id="respond-to-changes">Respond to changes</h3>
<p>When a change is detected then the page is PUT to the server to persist those changes</p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nf">function </span><span class="p">(</span><span class="nx">omniclopse</span><span class="p">,</span> <span class="nx">$</span><span class="p">)</span> <span class="p">{</span>
<span class="dl">"</span><span class="s2">use strict</span><span class="dl">"</span><span class="p">;</span>
<span class="c1">//snip out addMessage for clarity of example</span>
<span class="nx">omniclopse</span><span class="p">.</span><span class="nx">onContentEdited</span> <span class="o">=</span> <span class="nf">function </span><span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">panels</span> <span class="o">=</span> <span class="nf">$</span><span class="p">(</span><span class="dl">"</span><span class="s2">.panel</span><span class="dl">"</span><span class="p">)</span>
<span class="p">.</span><span class="nf">map</span><span class="p">(</span><span class="nf">function </span><span class="p">(</span><span class="nx">index</span><span class="p">,</span> <span class="nx">el</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">title</span> <span class="o">=</span> <span class="nf">$</span><span class="p">(</span><span class="nx">el</span><span class="p">).</span><span class="nf">find</span><span class="p">(</span><span class="dl">"</span><span class="s2">h1</span><span class="dl">"</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">body</span> <span class="o">=</span> <span class="nf">$</span><span class="p">(</span><span class="nx">el</span><span class="p">).</span><span class="nf">find</span><span class="p">(</span><span class="dl">"</span><span class="s2">.panel-body</span><span class="dl">"</span><span class="p">);</span>
<span class="k">return</span> <span class="p">{</span>
<span class="na">title</span><span class="p">:</span> <span class="nx">title</span> <span class="p">?</span> <span class="nx">title</span><span class="p">.</span><span class="nf">text</span><span class="p">()</span> <span class="p">:</span> <span class="dl">""</span><span class="p">,</span>
<span class="na">body</span><span class="p">:</span> <span class="nx">body</span> <span class="p">?</span> <span class="nx">body</span><span class="p">.</span><span class="nf">html</span><span class="p">()</span> <span class="p">:</span> <span class="dl">""</span><span class="p">,</span>
<span class="p">};</span>
<span class="p">})</span>
<span class="p">.</span><span class="nf">get</span><span class="p">();</span>
<span class="kd">var</span> <span class="nx">putData</span> <span class="o">=</span> <span class="p">{</span> <span class="na">panels</span><span class="p">:</span> <span class="nx">panels</span> <span class="p">};</span>
<span class="nx">$</span><span class="p">.</span><span class="nf">ajax</span><span class="p">({</span>
<span class="na">url</span><span class="p">:</span> <span class="dl">"</span><span class="s2">/pages/home</span><span class="dl">"</span><span class="p">,</span>
<span class="na">dataType</span><span class="p">:</span> <span class="dl">"</span><span class="s2">json</span><span class="dl">"</span><span class="p">,</span>
<span class="na">contentType</span><span class="p">:</span> <span class="dl">"</span><span class="s2">application/json</span><span class="dl">"</span><span class="p">,</span>
<span class="na">data</span><span class="p">:</span> <span class="nx">JSON</span><span class="p">.</span><span class="nf">stringify</span><span class="p">(</span><span class="nx">putData</span><span class="p">),</span>
<span class="na">type</span><span class="p">:</span> <span class="dl">"</span><span class="s2">PUT</span><span class="dl">"</span><span class="p">,</span>
<span class="p">})</span>
<span class="p">.</span><span class="nf">fail</span><span class="p">(</span><span class="nf">function </span><span class="p">(</span><span class="nx">xhr</span><span class="p">,</span> <span class="nx">status</span><span class="p">)</span> <span class="p">{</span>
<span class="nf">addMessage</span><span class="p">(</span><span class="dl">"</span><span class="s2">could not save your changes</span><span class="dl">"</span><span class="p">,</span> <span class="dl">"</span><span class="s2">alert-danger</span><span class="dl">"</span><span class="p">);</span>
<span class="p">})</span>
<span class="p">.</span><span class="nf">done</span><span class="p">(</span><span class="nf">function </span><span class="p">()</span> <span class="p">{</span>
<span class="nf">addMessage</span><span class="p">(</span><span class="dl">"</span><span class="s2">saved changes</span><span class="dl">"</span><span class="p">,</span> <span class="dl">"</span><span class="s2">alert-success</span><span class="dl">"</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">};</span>
<span class="p">})((</span><span class="nb">window</span><span class="p">.</span><span class="nx">omniclopse</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">omniclopse</span> <span class="o">||</span> <span class="p">{}),</span> <span class="nx">$</span><span class="p">);</span>
</code></pre></div></div>
<p>So here the page object expected by the server is gathered from the page and PUT using <code class="language-plaintext highlighter-rouge">$.ajax</code>. This bit of code is bound directly to the Home page at the moment but that can be remedied when necessary.</p>
<p>An addMessage function shows a bootstrap alert to keep the user informed of what is happening. This is a pretty dull piece of code!</p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">function</span> <span class="nf">alertTimeout</span><span class="p">(</span><span class="nx">wait</span><span class="p">)</span> <span class="p">{</span>
<span class="nf">setTimeout</span><span class="p">(</span><span class="nf">function </span><span class="p">()</span> <span class="p">{</span>
<span class="nf">$</span><span class="p">(</span><span class="dl">"</span><span class="s2">#messageHolder</span><span class="dl">"</span><span class="p">).</span><span class="nf">children</span><span class="p">(</span><span class="dl">"</span><span class="s2">.alert:first-child</span><span class="dl">"</span><span class="p">).</span><span class="nf">alert</span><span class="p">().</span><span class="nf">alert</span><span class="p">(</span><span class="dl">"</span><span class="s2">close</span><span class="dl">"</span><span class="p">);</span>
<span class="p">},</span> <span class="nx">wait</span><span class="p">);</span>
<span class="p">}</span>
<span class="kd">var</span> <span class="nx">addMessage</span> <span class="o">=</span> <span class="nf">function </span><span class="p">(</span><span class="nx">message</span><span class="p">,</span> <span class="nx">bootstrapType</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">outer</span> <span class="o">=</span> <span class="nf">$</span><span class="p">(</span><span class="dl">"</span><span class="s2"><div/></span><span class="dl">"</span><span class="p">,</span> <span class="p">{</span>
<span class="na">class</span><span class="p">:</span> <span class="dl">"</span><span class="s2">alert alert-dismissable </span><span class="dl">"</span> <span class="o">+</span> <span class="nx">bootstrapType</span><span class="p">,</span>
<span class="p">});</span>
<span class="kd">var</span> <span class="nx">button</span> <span class="o">=</span> <span class="nf">$</span><span class="p">(</span><span class="dl">"</span><span class="s2"><button/></span><span class="dl">"</span><span class="p">,</span> <span class="p">{</span>
<span class="na">type</span><span class="p">:</span> <span class="dl">"</span><span class="s2">button</span><span class="dl">"</span><span class="p">,</span>
<span class="na">class</span><span class="p">:</span> <span class="dl">"</span><span class="s2">close</span><span class="dl">"</span><span class="p">,</span>
<span class="dl">"</span><span class="s2">data-dismiss</span><span class="dl">"</span><span class="p">:</span> <span class="dl">"</span><span class="s2">alert</span><span class="dl">"</span><span class="p">,</span>
<span class="dl">"</span><span class="s2">aria-hidden</span><span class="dl">"</span><span class="p">:</span> <span class="dl">"</span><span class="s2">true</span><span class="dl">"</span><span class="p">,</span>
<span class="p">});</span>
<span class="nx">button</span><span class="p">.</span><span class="nf">append</span><span class="p">(</span><span class="dl">"</span><span class="s2">&times;</span><span class="dl">"</span><span class="p">);</span>
<span class="nx">outer</span><span class="p">.</span><span class="nf">append</span><span class="p">(</span><span class="nx">button</span><span class="p">);</span>
<span class="nx">outer</span><span class="p">.</span><span class="nf">append</span><span class="p">(</span><span class="nx">message</span><span class="p">);</span>
<span class="nf">$</span><span class="p">(</span><span class="dl">"</span><span class="s2">#messageHolder</span><span class="dl">"</span><span class="p">).</span><span class="nf">append</span><span class="p">(</span><span class="nx">outer</span><span class="p">);</span>
<span class="nf">alertTimeout</span><span class="p">(</span><span class="mi">3000</span><span class="p">);</span>
<span class="p">};</span>
</code></pre></div></div>
<h1 id="visual-affordance">Visual Affordance</h1>
<p>I found this a pretty hard design decision. I'm not sure I'm happy it really calls out what is happening to a user and I think I'll grab a designer the next time I'm next to one and ask their opinion but…</p>
<p><img src="/images/affordance-loggedout.png" alt="editable sections for anonymous users" loading="lazy" /></p>
<p><img src="/images/affordance-loggedin.png" alt="editable sections for anonymous users" loading="lazy" /></p>
<div class="language-scss highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">@mixin</span> <span class="nf">editorPencil</span><span class="p">(</span><span class="nv">$size</span><span class="p">)</span> <span class="p">{</span>
<span class="nl">content</span><span class="p">:</span> <span class="s2">"\270f "</span><span class="p">;</span>
<span class="nl">font-family</span><span class="p">:</span> <span class="s2">"Glyphicons Halflings"</span><span class="p">;</span>
<span class="nl">font-style</span><span class="p">:</span> <span class="nb">normal</span><span class="p">;</span>
<span class="nl">font-size</span><span class="p">:</span> <span class="nv">$size</span><span class="p">;</span>
<span class="p">}</span>
<span class="nt">div</span><span class="o">[</span><span class="nt">contenteditable</span><span class="o">]</span><span class="nd">:before</span> <span class="p">{</span>
<span class="k">@include</span> <span class="nd">editorPencil</span><span class="p">(</span><span class="m">1em</span><span class="p">);</span>
<span class="p">}</span>
<span class="nt">h1</span><span class="o">[</span><span class="nt">contenteditable</span><span class="o">]</span><span class="nd">:before</span> <span class="p">{</span>
<span class="k">@include</span> <span class="nd">editorPencil</span><span class="p">(</span><span class="m">0</span><span class="mi">.5em</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div></div>
<p>Since the site is already using bootstrap CSS was added that uses <code class="language-plaintext highlighter-rouge">:before</code> to add a pencil icon to any contenteditable div or H1.</p>
<h1 id="ckeditor">CKEditor</h1>
<p>Another little bonus is that CKEditor is aware of contenteditable elements so including that in the page gives you WYSIWYG power directly on any contenteditable.</p>
<!--alex ignore hook --->
<p>All that was necessary to hook it up was to include it in the page and to switch from using the valid <code class="language-plaintext highlighter-rouge"><div content contenteditable/></code> to using <code class="language-plaintext highlighter-rouge"><div content contenteditable=true/></code> a change I can live with to get the power of WYSIWYG directly on page elements</p>
<h1 id="how-does-it-work">(How) does it work?</h1>
<p>If you watch the GIF below it's clear this is a working prototype and not a finished product. But it does work!</p>
<p>The page content is jumping about as alert messages are added and that's not OK so a better mechanism is necessary for highlighting that changes have been persisted.</p>
<p>But this was really fun to add and it needed very little code to do so.</p>
<p><img src="/images/editing.gif" alt="editing the page" loading="lazy" /></p>
</div>
<div class="mt-8">
<h1>More like this...</h1>
<div class="grid grid-cols-3 gap-4"> <a href="/wrapping_up.html">
<div class="article-tile inline-block w-full border p-4 text-ellipsis align-top relative">
<h3>
Websites != CMS Platform - Wrapping Up
</h3>
<small>
03 Aug 2014
</small>
</div>
</a> <a href="/better-affordance-js.html">
<div class="article-tile inline-block w-full border p-4 text-ellipsis align-top relative">
<h3>
Websites != CMS Platform - Better Editable Affordance with JS for great good
</h3>
<small>
30 Jul 2014
</small>
</div>
</a> <a href="/better-affordance.html">
<div class="article-tile inline-block w-full border p-4 text-ellipsis align-top relative">
<h3>
Websites != CMS Platform - Better Editable Affordance
</h3>
<small>
20 Jul 2014
</small>
</div>
</a> </div>
</div>
</article>
</main>
<footer class="w-full h-4 bg-black text-white py-8 px-4">
<a class="no-underline text-white" href="https://pauldambra.dev/feed.xml">
<img class="inline w-6 h-6" src="/images/rss.svg" alt="the rss feed" />
<span>Subscribe to RSS feed</span>
</a>
</footer>
<script>
var tsl = document.getElementById("twitter-share-link");
tsl.addEventListener("click", function () {
ga("send", {
hitType: "social",
socialNetwork: "twitter",
socialAction: "tweet",
socialTarget: "https://pauldambra.dev/On-Page-Editing.html",
});
});
var fsl = document.getElementById("facebook-share-link");
fsl.addEventListener("click", function () {
ga("send", {
hitType: "social",
socialNetwork: "facebook",
socialAction: "share",
socialTarget: "https://pauldambra.dev/On-Page-Editing.html",
});
});
</script>
<script defer src="/register-service-worker.js"></script>
<link
href="https://fonts.googleapis.com/css?family=Khula&display=swap"
rel="stylesheet"
/>
</body>
</html>