From e6320789a434f4a21ac5ce41e97473edaecac0a7 Mon Sep 17 00:00:00 2001 From: Marcus Hitchins Date: Sun, 2 Apr 2017 10:42:51 +0100 Subject: [PATCH 01/22] Update polymer-quill.html --- polymer-quill.html | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/polymer-quill.html b/polymer-quill.html index 3918b67..c7ed853 100644 --- a/polymer-quill.html +++ b/polymer-quill.html @@ -220,7 +220,6 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e storeAs: { type: String, value: 'delta', - notify: true, }, /** * Save Interval in milliseconds. @@ -229,7 +228,6 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e saveInterval: { type: Number, value: 2000, - notify: true, }, /** * Delay load of content in milliseconds. @@ -239,7 +237,6 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e delay: { type: Number, value: 10, - notify: true, }, /** * Show Results below editor of saves in Delta or HMTL format. @@ -248,7 +245,6 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e showResults: { type: Boolean, value: false, - notify: true, }, /** * Show Results below editor of saves in HMTL format. @@ -257,7 +253,6 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e showHtml: { type: Boolean, value: false, - notify: true, }, /** * Editor toolbar type. @@ -266,7 +261,6 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e toolbarType: { type: String, value: 'standard', - notify: true, }, /** * Standard Tool @@ -275,7 +269,6 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e standardToolbar: { type: Boolean, value: true, - notify: true, }, /** * Enable tracks if editing is enabled. @@ -284,7 +277,6 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e enable: { type: String, value: 'true', - notify: true, }, /** * Whether to instantiate the editor to read-only mode. @@ -293,7 +285,6 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e readOnly: { type: Boolean, value: false, - notify: true, }, /** * Disable Class title. @@ -310,7 +301,6 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e useContentReset: { type: Boolean, value: false, - notify: true, }, /** * Placeholder for empty editor. @@ -319,7 +309,6 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e placeholder: { type: String, value: 'Compose an epic...', - notify: true, } }, @@ -418,6 +407,18 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e // Fire custom event change this.fire('change', {delta: change, change: JSON.stringify(change), content: this.content, html: this.html, entireDelta: this.quill.getContents()}); change = new Delta(); + } else { + if (this.content !== JSON.stringify(this.quill.getContents())) { + if (this.storeAs === 'delta') { + if (Array.isArray(this.content)) + this.quill.setContents(this.content) + } else { + this.quill.setContents(JSON.parse(this.content)) + } + } else { // html + this.quill.root.innerHTML = this.content + } + } } }.bind(this), this.saveInterval); From 8c6a0d350e03ca0d5a19855b892a338f484be73a Mon Sep 17 00:00:00 2001 From: Marcus Hitchins Date: Sun, 2 Apr 2017 10:58:22 +0100 Subject: [PATCH 02/22] Two-way data binding --- polymer-quill.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polymer-quill.html b/polymer-quill.html index c7ed853..90fc2d2 100644 --- a/polymer-quill.html +++ b/polymer-quill.html @@ -407,7 +407,7 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e // Fire custom event change this.fire('change', {delta: change, change: JSON.stringify(change), content: this.content, html: this.html, entireDelta: this.quill.getContents()}); change = new Delta(); - } else { + } else { // Allow changes from the Two-way data binding system if (this.content !== JSON.stringify(this.quill.getContents())) { if (this.storeAs === 'delta') { if (Array.isArray(this.content)) From b35c17d7e66c75428e7859043b5952fae849ddb0 Mon Sep 17 00:00:00 2001 From: Marcus Hitchins Date: Sun, 2 Apr 2017 11:50:49 +0100 Subject: [PATCH 03/22] Update polymer-quill.html --- polymer-quill.html | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/polymer-quill.html b/polymer-quill.html index 90fc2d2..1895ab9 100644 --- a/polymer-quill.html +++ b/polymer-quill.html @@ -407,17 +407,15 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e // Fire custom event change this.fire('change', {delta: change, change: JSON.stringify(change), content: this.content, html: this.html, entireDelta: this.quill.getContents()}); change = new Delta(); - } else { // Allow changes from the Two-way data binding system - if (this.content !== JSON.stringify(this.quill.getContents())) { - if (this.storeAs === 'delta') { - if (Array.isArray(this.content)) - this.quill.setContents(this.content) - } else { - this.quill.setContents(JSON.parse(this.content)) - } - } else { // html - this.quill.root.innerHTML = this.content + } else if (this.content !== JSON.stringify(this.quill.getContents())) { // Allow changes from the Two-way data binding system + if (this.storeAs === 'delta') { + if (Array.isArray(this.content)) { + this.quill.setContents(this.content) + } else { + this.quill.setContents(JSON.parse(this.content)) } + } else { // html + this.quill.root.innerHTML = this.content } } }.bind(this), this.saveInterval); From e053393e573cef06567b426e7496f95d8ea3bc80 Mon Sep 17 00:00:00 2001 From: Marcus Hitchins Date: Mon, 3 Apr 2017 18:14:50 +0100 Subject: [PATCH 04/22] Update polymer-quill.html --- polymer-quill.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/polymer-quill.html b/polymer-quill.html index 1895ab9..5b4ffcb 100644 --- a/polymer-quill.html +++ b/polymer-quill.html @@ -412,7 +412,9 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e if (Array.isArray(this.content)) { this.quill.setContents(this.content) } else { - this.quill.setContents(JSON.parse(this.content)) + if (this.content.length > 1) { + this.quill.setContents(JSON.parse(this.content),'api') + } } } else { // html this.quill.root.innerHTML = this.content From 416a3e3eed25e2d51d6c7c98a0c0b02e878b6248 Mon Sep 17 00:00:00 2001 From: Marcus Hitchins Date: Mon, 3 Apr 2017 19:22:44 +0100 Subject: [PATCH 05/22] Update polymer-quill.html --- polymer-quill.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/polymer-quill.html b/polymer-quill.html index 5b4ffcb..6f9c1d4 100644 --- a/polymer-quill.html +++ b/polymer-quill.html @@ -413,7 +413,14 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e this.quill.setContents(this.content) } else { if (this.content.length > 1) { - this.quill.setContents(JSON.parse(this.content),'api') + var a = "" + try { + if (Array.isArray(JSON.parse(this.content))){ + this.quill.setContents(JSON.parse(this.content),'api') + } + } catch(e) { + console.log(e, this.content) + } } } } else { // html From 00462f37643f3679fac95110c0cb3e1c02846cda Mon Sep 17 00:00:00 2001 From: Marcus Hitchins Date: Mon, 3 Apr 2017 19:30:29 +0100 Subject: [PATCH 06/22] Update polymer-quill.html --- polymer-quill.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/polymer-quill.html b/polymer-quill.html index 6f9c1d4..4679332 100644 --- a/polymer-quill.html +++ b/polymer-quill.html @@ -413,13 +413,13 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e this.quill.setContents(this.content) } else { if (this.content.length > 1) { - var a = "" try { if (Array.isArray(JSON.parse(this.content))){ - this.quill.setContents(JSON.parse(this.content),'api') + this.quill.setContents(JSON.parse(this.content),'api') } } catch(e) { console.log(e, this.content) + this.content = "{}" } } } From 529e3f64562e9a82ed1a23325bb99f1dbe0b1fae Mon Sep 17 00:00:00 2001 From: Marcus Hitchins Date: Tue, 4 Apr 2017 16:21:45 +0100 Subject: [PATCH 07/22] Update polymer-quill.html --- polymer-quill.html | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/polymer-quill.html b/polymer-quill.html index 4679332..4116abe 100644 --- a/polymer-quill.html +++ b/polymer-quill.html @@ -389,10 +389,13 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e } } change = change.compose(delta); - }.bind(this)); + }.bind(this)) + var typingTimer + + // Save periodically - setInterval(function() { + var savePeriodically = function() { if (change.length() > 0) { if (this.showResults) { console.log('Saving changes', change); @@ -427,8 +430,12 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e this.quill.root.innerHTML = this.content } } - }.bind(this), this.saveInterval); - + }.bind(this) + var saveInterval = this.saveInterval + this.quill.on('text-change', function() { + clearTimeout(typingTimer) + typingTimer = setTimeout(savePeriodically, saveInterval) + }) // Check for unsaved data window.onbeforeunload = function() { if (change.length() > 0) { From f98eb9eac02570212ad8ec56198e16aa0e49233b Mon Sep 17 00:00:00 2001 From: Marcus Hitchins Date: Wed, 5 Apr 2017 11:21:35 +0100 Subject: [PATCH 08/22] Update polymer-quill.html --- polymer-quill.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/polymer-quill.html b/polymer-quill.html index 4116abe..124c9c8 100644 --- a/polymer-quill.html +++ b/polymer-quill.html @@ -526,7 +526,9 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e // Set content this.async(function() { if (this.storeAs === 'delta') { - if (this.content.length > 1) { + if (Array.isArray(this.content)) { + this.quill.setContents(this.content,'api') + } else if (this.content.length > 1) { this.quill.setContents(JSON.parse(this.content),'api'); } } else { // HTML From f5c021ff1fd654d03ce8b28be67b6403c1e8ca81 Mon Sep 17 00:00:00 2001 From: Marcus Hitchins Date: Wed, 5 Apr 2017 12:56:46 +0100 Subject: [PATCH 09/22] Update polymer-quill.html --- polymer-quill.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/polymer-quill.html b/polymer-quill.html index 124c9c8..0804b22 100644 --- a/polymer-quill.html +++ b/polymer-quill.html @@ -478,7 +478,11 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e var notset = true; if (this.content && this.content.length > 1 && this.content != undefined && this.content !="

undefined

" ) { if (this.storeAs === 'delta') { - this.quill.setContents(JSON.parse(this.content),'api'); + if (Array.isArray(this.content)) { + this.quill.setContents(this.content,'api'); + } else { + this.quill.setContents(JSON.parse(this.content),'api'); + } } else { // HTML this.quill.root.innerHTML = this.content; } From f162378fd1bf13767720036b9e17cdb2e9055428 Mon Sep 17 00:00:00 2001 From: Marcus Hitchins Date: Wed, 5 Apr 2017 13:55:36 +0100 Subject: [PATCH 10/22] Update polymer-quill.html --- polymer-quill.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/polymer-quill.html b/polymer-quill.html index 0804b22..041980f 100644 --- a/polymer-quill.html +++ b/polymer-quill.html @@ -86,22 +86,21 @@

Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save e --calculated-polymer-quill-editor-overflow: var(--polymer-quill-editor-overflow, scroll); display: block; @apply(--polymer-quill); - } + }; #editor { max-height: var(--calculated-polymer-quill-editor-max-height); min-height: var(--calculated-polymer-quill-editor-min-height); overflow: var(--calculated-polymer-quill-editor-overflow); border: var(--calculated-polymer-quill-editor-border); - } + }; .results { padding: 20px 10px; overflow-x: scroll; - } + }; .disabled { border: 1px solid #ccc !important; opacity: 0.85; - } - + };