From be542b51595bcd85f28b3dba403fd9ed1a2f6b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 30 Oct 2024 18:13:32 -0400 Subject: [PATCH] feat: update for nodeb 3.2 and up --- lib/controllers.js | 1 + package.json | 2 +- plugin.json | 11 +- static/lib/client.js | 33 +++- static/lib/quill-nbb.js | 2 +- static/scss/overrides.scss | 31 ++++ static/scss/post.scss | 19 +++ static/scss/quill.scss | 4 + .../admin/plugins/composer-quill.tpl | 70 ++++---- static/templates/composer.tpl | 161 +++--------------- .../partials/composer-formatting.tpl | 75 ++++++++ static/templates/partials/composer-tags.tpl | 17 ++ .../partials/composer-title-container.tpl | 46 +++++ .../partials/composer-write-preview.tpl | 15 ++ 14 files changed, 304 insertions(+), 183 deletions(-) create mode 100644 static/scss/overrides.scss create mode 100644 static/scss/post.scss create mode 100644 static/scss/quill.scss create mode 100644 static/templates/partials/composer-formatting.tpl create mode 100644 static/templates/partials/composer-tags.tpl create mode 100644 static/templates/partials/composer-title-container.tpl create mode 100644 static/templates/partials/composer-write-preview.tpl diff --git a/lib/controllers.js b/lib/controllers.js index 3bfafa9..6b8e63b 100644 --- a/lib/controllers.js +++ b/lib/controllers.js @@ -11,6 +11,7 @@ Controllers.renderAdminPage = function (req, res, next) { } res.render('admin/plugins/composer-quill', { + title: 'Quill Composer', checks: checks, }); }); diff --git a/package.json b/package.json index 5d09554..30af59c 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "readmeFilename": "README.md", "nbbpm": { - "compatibility": "^1.17.0 || ^2.0.0" + "compatibility": "^3.2.0" }, "dependencies": { "async": "^3.2.0", diff --git a/plugin.json b/plugin.json index 0fee33f..cea758b 100644 --- a/plugin.json +++ b/plugin.json @@ -15,11 +15,11 @@ { "hook": "filter:messaging.getFields", "method": "handleMessageEdit" }, { "hook": "filter:messaging.checkContent", "method": "handleMessageCheck" } ], - "less": [ - "../nodebb-plugin-composer-default/static/less/composer.less", - "./static/less/quill.less", - "./static/less/post.less", - "./static/less/overrides.less" + "scss": [ + "../nodebb-plugin-composer-default/static/scss/composer.scss", + "./static/scss/quill.scss", + "./static/scss/post.scss", + "./static/scss/overrides.scss" ], "modules": { "quill.js": "./node_modules/quill/dist/quill.js", @@ -36,6 +36,7 @@ "composer/tags.js": "../nodebb-plugin-composer-default/static/lib/composer/tags.js", "composer/uploads.js": "../nodebb-plugin-composer-default/static/lib/composer/uploads.js", "composer/autocomplete.js": "../nodebb-plugin-composer-default/static/lib/composer/autocomplete.js", + "composer/post-queue.js": "../nodebb-plugin-composer-default/static/lib/composer/post-queue.js", "../admin/plugins/composer-quill.js": "./static/lib/admin.js" }, "scripts": [ diff --git a/static/lib/client.js b/static/lib/client.js index bd1289c..cdf8429 100644 --- a/static/lib/client.js +++ b/static/lib/client.js @@ -23,21 +23,36 @@ $(document).ready(() => { $(window).on('action:composer.topic.new', (ev, data) => { composer.newTopic({ cid: data.cid, + title: data.title || '', + body: data.body || '', + tags: data.tags || [], + }); + }); + + $(window).on('action:composer.post.edit', (ev, data) => { + composer.editPost({ pid: data.pid }); + }); + + $(window).on('action:composer.post.new', (ev, data) => { + data.body = data.body || data.text; + data.title = data.title || data.topicName; + composer.newReply({ + tid: data.tid, + toPid: data.pid, title: data.title, body: data.body, }); }); - $(window).on('action:composer.post.edit', (ev, data) => { - composer.editPost(data.pid); - }); - - $(window).on('action:composer.post.new', (ev, data) => { - composer.newReply(data.tid, data.pid, data.topicName, data.text); - }); - $(window).on('action:composer.addQuote', (ev, data) => { - composer.newReply(data.tid, data.pid, data.topicName, wrapWithBlockquote(data.text)); + data.title = data.title || data.topicName; + data.body = data.body || data.text; + composer.newReply({ + tid: data.tid, + toPid: data.pid, + title: data.title, + body: wrapWithBlockquote(data.body), + }); }); }); }); diff --git a/static/lib/quill-nbb.js b/static/lib/quill-nbb.js index 2417b64..2ffa236 100644 --- a/static/lib/quill-nbb.js +++ b/static/lib/quill-nbb.js @@ -281,7 +281,7 @@ window.quill.init = function (targetEl, data, callback) { if (className === 'picture') { buttonEl.html(''); } else { - buttonEl.html(''); + buttonEl.html(''); } } }); diff --git a/static/scss/overrides.scss b/static/scss/overrides.scss new file mode 100644 index 0000000..30e5e75 --- /dev/null +++ b/static/scss/overrides.scss @@ -0,0 +1,31 @@ +.composer { + .formatting-bar { + display: none!important; + } + + .write-container { + width: 100%!important; + min-width: 0px; // fixes negation of overflow-wrap due this being a flex-item + + textarea { + display: none; + } + } +} + +.ql-toolbar { + button > i { + float: left; + height: 100%; + } +} + +[component="chat/composer"] { + .ql-editor { + padding: 0; + } + + [component="chat/input"] { + display: none; + } +} \ No newline at end of file diff --git a/static/scss/post.scss b/static/scss/post.scss new file mode 100644 index 0000000..0583550 --- /dev/null +++ b/static/scss/post.scss @@ -0,0 +1,19 @@ +[component="post/content"], [component="chat/messages"] { + .ql-align-center { + text-align: center; + } + .ql-align-right { + text-align: right; + } + .ql-align-justify { + text-align: justify; + } + + // Fonts + .ql-font-serif { + font-family: Georgia, "Times New Roman", serif; + } + .ql-font-monospace { + font-family: Monaco, "Courier New", monospace; + } +} \ No newline at end of file diff --git a/static/scss/quill.scss b/static/scss/quill.scss new file mode 100644 index 0000000..c781212 --- /dev/null +++ b/static/scss/quill.scss @@ -0,0 +1,4 @@ +// @import './quill/dist/quill.snow'; +// @import './quill/dist/quill.bubble'; +@import 'nodebb-plugin-composer-quill/node_modules/quill/dist/quill.snow'; +@import 'nodebb-plugin-composer-quill/node_modules/quill/dist/quill.bubble'; \ No newline at end of file diff --git a/static/templates/admin/plugins/composer-quill.tpl b/static/templates/admin/plugins/composer-quill.tpl index f14546b..6cb5828 100644 --- a/static/templates/admin/plugins/composer-quill.tpl +++ b/static/templates/admin/plugins/composer-quill.tpl @@ -1,54 +1,60 @@ -
-
-
-
Quill Composer
-
-

- Quill is a free, open source WYSIWYG editor built for the modern web. With its modular architecture and expressive API, it is completely customizable to fit any need. -

-
-
-
-
-
-
Migration
-
+
+ + + +
+
+

+ Quill is a free, open source WYSIWYG editor built for the modern web. With its modular architecture and expressive API, it is completely customizable to fit any need. +

+ +
+ +
+
Migration
+

If you are switching to Quill from a different composer (i.e. composer-default/markdown), you will need to convert your existing posts to Quill's format. You may use the utilities below to do so.

- - + +
-
-
Compatibility Checks
-
+ +
+ +
+
Compatibility Checks
+
    -
  • +
  • Markdown Compatibility - - + {{{ if checks.markdown }}} +

    The Markdown plugin is either disabled, or HTML sanitization is disabled

    - - + {{{ else }}} +

    In order to render post content correctly, the Markdown plugin needs to have HTML sanitization disabled, or the entire plugin should be disabled altogether.

    - + {{{ end }}}
  • -
  • +
  • Composer Conflicts - - + {{{ if checks.composer }}} +

    Great! Looks like Quill is the only composer active

    - - + {{{ else }}} +

    Quill must be the only composer active. Please disable other composers and reload NodeBB.

    - + {{{ end }}}
+ +
+ diff --git a/static/templates/composer.tpl b/static/templates/composer.tpl index 407876e..f4ee338 100644 --- a/static/templates/composer.tpl +++ b/static/templates/composer.tpl @@ -1,155 +1,46 @@ -
- -
-