diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..496ee2c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.DS_Store
\ No newline at end of file
diff --git a/VSCode/package-lock.json b/VSCode/package-lock.json
index d11280c..793c473 100644
--- a/VSCode/package-lock.json
+++ b/VSCode/package-lock.json
@@ -1,5 +1,5 @@
{
"name": "es6-string-html",
- "version": "1.0",
+ "version": "1.0.1",
"lockfileVersion": 1
-}
\ No newline at end of file
+}
diff --git a/VSCode/package.json b/VSCode/package.json
index 37a3b53..869796b 100644
--- a/VSCode/package.json
+++ b/VSCode/package.json
@@ -2,7 +2,7 @@
"name": "quill",
"displayName": "Quill",
"description": "HTML/CSS Syntax highlighting, best used with the Quill framework",
- "version": "1.0.0",
+ "version": "1.0.1",
"publisher": "capturedsun",
"icon": "docs/Quill.png",
"engines": {
@@ -48,6 +48,12 @@
"category": "HTML"
}
],
+ "snippets": [
+ {
+ "language": "javascript",
+ "path": "./snippets.json"
+ }
+ ],
"grammars": [
{
"injectTo": [
diff --git a/VSCode/quill-1.0.1.vsix b/VSCode/quill-1.0.1.vsix
new file mode 100644
index 0000000..2650158
Binary files /dev/null and b/VSCode/quill-1.0.1.vsix differ
diff --git a/VSCode/snippets.json b/VSCode/snippets.json
new file mode 100644
index 0000000..b1dee2a
--- /dev/null
+++ b/VSCode/snippets.json
@@ -0,0 +1,71 @@
+{
+ "html": {
+ "prefix": "html",
+ "body": [
+ "html(`$1`);"
+ ],
+ "description": "Create a DOM node"
+ },
+
+ "dom": {
+ "prefix": "dom",
+ "body": [
+ "dom;"
+ ],
+ "description": "Use the DOM collection of functions"
+ },
+
+ "*element": {
+ "prefix": "*element",
+ "body": [
+ "class Index extends HTMLElement {",
+ "",
+ " css = /*css*/ `",
+ " index-el {",
+ " ",
+ " }",
+ " `",
+ "",
+ " html = /*html*/ `",
+ " `",
+ "",
+ " constructor() {",
+ " super();",
+ " quill.addStyle(this.css);",
+ " this.innerHTML = this.html;",
+ " }",
+ "",
+ " connectedCallback() {",
+ " }",
+ "",
+ "}",
+ "",
+ "customElements.define('index-el', Index);",
+ "export default Index;"
+ ],
+ "description": "Custom Element Template"
+ },
+
+ "*page": {
+ "prefix": "*page",
+ "body": [
+ "",
+ "",
+ "
",
+ " Index",
+ " ",
+ " ",
+ " ",
+ " ",
+ "",
+ "",
+ " ",
+ ""
+ ],
+ "description": "Use the DOM collection of functions"
+ }
+}
\ No newline at end of file
diff --git a/quill.js b/quill.js
index d1bbb7e..2faf1f1 100644
--- a/quill.js
+++ b/quill.js
@@ -1,11 +1,47 @@
export function addStyle(cssString) {
- let stylesheet = new CSSStyleSheet();
- stylesheet.replaceSync(cssString)
- document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
+ if(quill.detectMobile() || quill.getSafariVersion() < 16.4) {
+ let container = document.querySelector("style#quillStyles");
+ if(!container) {
+ container = document.createElement('style');
+ container.id = "quillStyles";
+ document.head.appendChild(container);
+ }
+
+ let primarySelector = cssString.substring(0, cssString.indexOf("{")).trim();
+ primarySelector = primarySelector.replace(/\*/g, "all");
+ let stylesheet = container.querySelector(`:scope > style#${primarySelector}`)
+ if(!stylesheet) {
+ stylesheet = document.createElement('style');
+ stylesheet.id = primarySelector;
+ stylesheet.appendChild(document.createTextNode(cssString));
+ container.appendChild(stylesheet);
+ } else {
+ stylesheet.innerText = cssString
+ }
+ return;
+ }
+ let stylesheet = new CSSStyleSheet();
+ stylesheet.replaceSync(cssString)
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
+}
+
+export function createElement(elementString) {
+ let parser = new DOMParser();
+ let doc = parser.parseFromString(elementString, 'text/html');
+ return doc.body.firstChild;
+}
+
+export function detectMobile() {
+ const mobileDeviceRegex = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;
+ return mobileDeviceRegex.test(navigator.userAgent);
+}
+
+export function getSafariVersion() {
+ const userAgent = navigator.userAgent;
+ const isSafari = userAgent.includes("Safari") && !userAgent.includes("Chrome");
+ if (isSafari) {
+ const safariVersionMatch = userAgent.match(/Version\/(\d+\.\d+)/);
+ const safariVersion = safariVersionMatch ? parseFloat(safariVersionMatch[1]) : null;
+ return safariVersion;
}
-
-export function html(elementString) {
- let parser = new DOMParser();
- let doc = parser.parseFromString(elementString, 'text/html');
- return doc.body.firstChild;
}
\ No newline at end of file