Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions dark-theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,6 @@ cd-el {
display: block;
}

.token.prolog,
.token.doctype,
.token.cdata {
color: hsl(218deg 7% 64% / 72%);
}

.token.punctuation,
.token.interpolation,
.token.important,
Expand Down Expand Up @@ -209,6 +203,12 @@ cd-el {
color: hsl(218deg 7% 64% / 72%) !important;
}

.token.prolog,
.token.doctype,
.token.cdata {
color: hsl(218deg 7% 64% / 72%);
}

.token.string,
.token.string *,
.token.attr-value,
Expand All @@ -217,6 +217,11 @@ cd-el {
color: #c1ffd5cc !important;
}

.token.doctype .token.string,
.token.doctype .token.string * {
color: inherit !important;
}

.token.italic {
font-style: normal;
}
Expand Down
2 changes: 1 addition & 1 deletion full.html
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
<script src="lib/plugins/codeit-match-braces.js"></script>
<script src="lib/plugins/codeit-autolinker.js"></script>

<script src="worker/worker-channel.js"></script>
<script src="worker/client-channel.js"></script>

<script src="utils.js"></script>
<script src="manifest.js"></script>
Expand Down
52 changes: 24 additions & 28 deletions lib/plugins/codeit-autolinker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
return;
}

var url = /\b([a-z]{3,7}:\/\/|tel:)[\w\-+%~/.:=&@]+(?:\?[\w\-+%~/.:=?&!$'()*,;@]*)?(?:#[\w\-+%~/.:#=?&!$'()*,;@]*)?/;
var url = /\b([a-z]{3,7}:\/\/|tel:)[\w\-+%~/.:=&!$'()*,;@]+(?:\?[\w\-+%~/.:=?&!$'()*,;@]*)?(?:#[\w\-+%~/.:#=?&!$'()*,;@]*)?/;
var email = /\b\S+@[\w.]+[a-z]{2}/;
var linkMd = /\[([^\]]+)\]\(([^)]+)\)/;

Expand Down Expand Up @@ -44,40 +44,36 @@
}
};

Prism.hooks.add('before-tokenize', function (env) {
if (env.language !== 'markdown') {
Prism.plugins.autolinker.processGrammar(env.grammar);
}
Prism.hooks.add('before-highlight', function (env) {
Prism.plugins.autolinker.processGrammar(env.grammar);
});

Prism.hooks.add('wrap', function (env) {
if (env.language !== 'markdown') {
if (/-link$/.test(env.type)) {
env.tag = 'a';

var href = env.content;
Prism.hooks.add('wrap', function (env) {
if (/-link$/.test(env.type)) {
env.tag = 'a';

if (env.type == 'email-link' && href.indexOf('mailto:') != 0) {
href = 'mailto:' + href;
} else if (env.type == 'md-link') {
// Markdown
var match = env.content.match(linkMd);
var href = env.content;

href = match[2];
env.content = match[1];
}
if (env.type == 'email-link' && href.indexOf('mailto:') != 0) {
href = 'mailto:' + href;
} else if (env.type == 'md-link') {
// Markdown
var match = env.content.match(linkMd);

var isMac = navigator.platform.indexOf('Mac') > -1;
href = match[2];
env.content = match[1];
}

env.attributes.href = href.replaceAll('\'','').replaceAll('"','').replaceAll('`','');
env.attributes.onclick = 'if ((event.ctrlKey || event.metaKey) && event.shiftKey) { event.preventDefault(); window.open(this.href, "_blank") }';
env.attributes.title = isMac ? '⌘ + Shift + click to open link' : 'Ctrl + Shift + click to open link';
env.attributes.href = href;

//env.attributes.href = href.replaceAll('\'','').replaceAll('"','').replaceAll('`','');
env.attributes.onclick = 'if ((event.ctrlKey || event.metaKey) && event.shiftKey) { event.preventDefault(); window.open(this.href, "_blank") }';
env.attributes.title = isMac ? '⌘ + ⇧ + click to open link' : 'Ctrl + Shift + click to open link';

// Silently catch any error thrown by decodeURIComponent (#1186)
try {
env.content = decodeURIComponent(env.content);
} catch (e) { /* noop */ }
}
// Silently catch any error thrown by decodeURIComponent (#1186)
try {
env.content = decodeURIComponent(env.content);
} catch (e) {}
}
});

Expand Down
12 changes: 6 additions & 6 deletions live-view/live-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ if (isMobile) {
if (!isEmbed) {

// get live view URL
const liveViewURL = livePath +'?'+ workerClientId +'/';
const liveViewURL = livePath +'?'+ worker.clientId +'/';

// open a new window with live view URL
window.open(liveViewURL, '_blank');
Expand Down Expand Up @@ -1109,17 +1109,17 @@ async function renderLiveViewHTML(file) {


// if service worker isn't installed yet
if (workerInstallPromise) {
if (worker.installPromise) {

// wait until finished installing
await workerInstallPromise;
await worker.installPromise;

}

if (!workerClientId) await workerInstallPromise;
if (!worker.clientId) await worker.installPromise;


liveView.innerHTML = '<iframe src="'+ livePath +'?'+ workerClientId +'/" name="Live view" title="Live view" class="live-frame" allow="accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write" allowfullscreen="true" allowpaymentrequest="true" loading="lazy" sandbox="allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation" scrolling="yes" frameborder="0"></iframe>';
liveView.innerHTML = '<iframe src="'+ livePath +'?'+ worker.clientId +'/" name="Live view" title="Live view" class="live-frame" allow="accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write" allowfullscreen="true" allowpaymentrequest="true" loading="lazy" sandbox="allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation" scrolling="yes" frameborder="0"></iframe>';


liveFile = file;
Expand All @@ -1146,7 +1146,7 @@ async function renderLiveViewHTML(file) {
// render live view for Markdown files
async function renderLiveViewMarkdown(file) {

liveView.innerHTML = '<iframe srcdoc="<!DOCTYPE html><html><head></head><body></body></html>" name="Live view" title="Live view" style="background: hsl(228deg 16% 12%);" class="live-frame" loading="lazy" scrolling="yes" frameborder="0"></iframe>';
liveView.innerHTML = '<iframe srcdoc="<!DOCTYPE html><html><head></head><body ontouchstart></body></html>" name="Live view" title="Live view" style="background: hsl(228deg 16% 12%);" class="live-frame" loading="lazy" scrolling="yes" frameborder="0"></iframe>';

const liveFrame = liveView.querySelector('.live-frame');

Expand Down
14 changes: 8 additions & 6 deletions service-worker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

self.importScripts('/worker/client-channel.js');
self.importScripts('/worker/worker-channel.js');

// list of files to cache
const FILES_TO_CACHE = [
Expand All @@ -11,12 +10,11 @@ const FILES_TO_CACHE = [
'/lib/plugins/codeit-line-numbers.js',
'/lib/plugins/codeit-match-braces.js',
'/lib/plugins/codeit-autolinker.js',
'/lib/plugins/codeit-autocomplete.js',

'/full',
'/full.css',

'/worker/worker-channel.js',
'/worker/client-channel.js',

'/utils.js',
'/manifest.js',
Expand Down Expand Up @@ -63,23 +61,27 @@ const FILES_TO_CACHE = [
// remove previous cached data
caches.keys().then((keyList) => {
return Promise.all(keyList.map((key) => {
if (key !== WORKER_NAME) {
if (key !== worker.name) {
return caches.delete(key);
}
}));
});

// precache static resources
caches.open(WORKER_NAME).then((cache) => {
caches.open(worker.name).then((cache) => {
return cache.addAll(FILES_TO_CACHE);
});


self.addEventListener('install', (evt) => {

self.skipWaiting();

});

self.addEventListener('activate', (evt) => {

self.clients.claim();

});

Loading