From fe4db16a7edaf5e484ac0d2b8d2fba7c673e7c93 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Tue, 19 Oct 2021 19:10:40 +0200 Subject: [PATCH] html editor in books list --- cps/editbooks.py | 5 + .../css/libs/bootstrap-wysihtml5-0.0.3.css | 103 +++++++ .../js/libs/bootstrap-wysihtml5-0.0.3.min.js | 1 + cps/static/js/libs/wysihtml5-0.0.3.js | 140 ++++++++++ cps/static/js/libs/wysihtml5-0.3.0.min.js | 262 ++++++++++++++++++ cps/static/js/table.js | 12 + cps/templates/book_table.html | 23 +- 7 files changed, 544 insertions(+), 2 deletions(-) create mode 100644 cps/static/css/libs/bootstrap-wysihtml5-0.0.3.css create mode 100644 cps/static/js/libs/bootstrap-wysihtml5-0.0.3.min.js create mode 100644 cps/static/js/libs/wysihtml5-0.0.3.js create mode 100644 cps/static/js/libs/wysihtml5-0.3.0.min.js diff --git a/cps/editbooks.py b/cps/editbooks.py index 9ad39373..99d4f69a 100644 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -459,6 +459,7 @@ def edit_book_series_index(series_index, book): modif_date = True return modif_date + # Handle book comments/description def edit_book_comments(comments, book): modif_date = False @@ -1150,6 +1151,10 @@ def edit_list_book(param): book.sort = vals['value'] ret = Response(json.dumps({'success': True, 'newValue': book.sort}), mimetype='application/json') + elif param =='comments': + edit_book_comments(vals['value'], book) + ret = Response(json.dumps({'success': True, 'newValue': book.comments[0].text}), + mimetype='application/json') elif param =='authors': input_authors, __ = handle_author_on_edit(book, vals['value'], vals.get('checkA', None) == "true") helper.update_dir_stucture(book.id, config.config_calibre_dir, input_authors[0]) diff --git a/cps/static/css/libs/bootstrap-wysihtml5-0.0.3.css b/cps/static/css/libs/bootstrap-wysihtml5-0.0.3.css new file mode 100644 index 00000000..04e8e1e4 --- /dev/null +++ b/cps/static/css/libs/bootstrap-wysihtml5-0.0.3.css @@ -0,0 +1,103 @@ +ul.wysihtml5-toolbar { + margin: 0; + padding: 0; + display: block; +} + +ul.wysihtml5-toolbar::after { + clear: both; + display: table; + content: ""; +} + +ul.wysihtml5-toolbar > li { + float: left; + display: list-item; + list-style: none; + margin: 0 5px 10px 0; +} + +ul.wysihtml5-toolbar a[data-wysihtml5-command=bold] { + font-weight: bold; +} + +ul.wysihtml5-toolbar a[data-wysihtml5-command=italic] { + font-style: italic; +} + +ul.wysihtml5-toolbar a[data-wysihtml5-command=underline] { + text-decoration: underline; +} + +ul.wysihtml5-toolbar a.btn.wysihtml5-command-active { + background-image: none; + -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05); + -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05); + background-color: #E6E6E6; + background-color: #D9D9D9; + outline: 0; +} + +ul.wysihtml5-commands-disabled .dropdown-menu { + display: none !important; +} + +ul.wysihtml5-toolbar div.wysihtml5-colors { + display:block; + width: 50px; + height: 20px; + margin-top: 2px; + margin-left: 5px; + position: absolute; + pointer-events: none; +} + +ul.wysihtml5-toolbar a.wysihtml5-colors-title { + padding-left: 70px; +} + +ul.wysihtml5-toolbar div[data-wysihtml5-command-value="black"] { + background: black !important; +} + +ul.wysihtml5-toolbar div[data-wysihtml5-command-value="silver"] { + background: silver !important; +} + +ul.wysihtml5-toolbar div[data-wysihtml5-command-value="gray"] { + background: gray !important; +} + +ul.wysihtml5-toolbar div[data-wysihtml5-command-value="maroon"] { + background: maroon !important; +} + +ul.wysihtml5-toolbar div[data-wysihtml5-command-value="red"] { + background: red !important; +} + +ul.wysihtml5-toolbar div[data-wysihtml5-command-value="purple"] { + background: purple !important; +} + +ul.wysihtml5-toolbar div[data-wysihtml5-command-value="green"] { + background: green !important; +} + +ul.wysihtml5-toolbar div[data-wysihtml5-command-value="olive"] { + background: olive !important; +} + +ul.wysihtml5-toolbar div[data-wysihtml5-command-value="navy"] { + background: navy !important; +} + +ul.wysihtml5-toolbar div[data-wysihtml5-command-value="blue"] { + background: blue !important; +} + +ul.wysihtml5-toolbar div[data-wysihtml5-command-value="orange"] { + background: orange !important; +} + diff --git a/cps/static/js/libs/bootstrap-wysihtml5-0.0.3.min.js b/cps/static/js/libs/bootstrap-wysihtml5-0.0.3.min.js new file mode 100644 index 00000000..e7c9428c --- /dev/null +++ b/cps/static/js/libs/bootstrap-wysihtml5-0.0.3.min.js @@ -0,0 +1 @@ +!function(t,a){"use strict";var l={"font-styles":function(t,a){var l=a&&a.size?" btn-"+a.size:"";return""},emphasis:function(t,a){var l=a&&a.size?" btn-"+a.size:"";return"
  • "},lists:function(t,a){var l=a&&a.size?" btn-"+a.size:"";return"
  • "},link:function(t,a){var l=a&&a.size?" btn-"+a.size:"";return"
  • "},image:function(t,a){var l=a&&a.size?" btn-"+a.size:"";return"
  • "},html:function(t,a){var l=a&&a.size?" btn-"+a.size:"";return"
  • "},color:function(t,a){var l=a&&a.size?" btn-"+a.size:"";return""}},i=function(t,a,i){return l[t](a,i)},s=function(a,i){this.el=a;var s=i||e;for(var o in s.customTemplates)l[o]=s.customTemplates[o];this.toolbar=this.createToolbar(a,s),this.editor=this.createEditor(i),window.editor=this.editor,t("iframe.wysihtml5-sandbox").each(function(a,l){t(l.contentWindow).off("focus.wysihtml5").on({"focus.wysihtml5":function(){t("li.dropdown").removeClass("open")}})})};s.prototype={constructor:s,createEditor:function(l){l=l||{},l=t.extend(!0,{},l),l.toolbar=this.toolbar[0];var i=new a.Editor(this.el[0],l);if(l&&l.events)for(var s in l.events)i.on(s,l.events[s]);return i},createToolbar:function(a,l){var s=this,o=t("