@@ -377,7 +377,7 @@
workspace_set_widths (request, widths);
workspace_set_heights (request, row_heights);
- urls[0] = editone_index_url ();
+ urls[0] = editone2_index_url ();
urls[1] = resource_index_url ();
request->database_config_user()->setActiveWorkspace (demo_workspace ());
diff -Nru bibledit-5.0.912/developer/index.html bibledit-5.0.922/developer/index.html
--- bibledit-5.0.912/developer/index.html 2020-09-19 18:30:19.000000000 +0000
+++ bibledit-5.0.922/developer/index.html 2020-11-26 16:21:00.000000000 +0000
@@ -15,6 +15,7 @@
Show alert and block keyboard for a short time
+Chapter editor version 2 beta
##success##
##error##
diff -Nru bibledit-5.0.912/edit/edit.cpp bibledit-5.0.922/edit/edit.cpp
--- bibledit-5.0.912/edit/edit.cpp 2020-09-19 18:30:19.000000000 +0000
+++ bibledit-5.0.922/edit/edit.cpp 2020-11-22 13:57:08.000000000 +0000
@@ -64,5 +64,5 @@
if (alive) return translate ("The passage has been opened in the existing Bible editor");
- return "" + translate ("Open a Bible editor to edit the passage") + "";
+ return "" + translate ("Open a Bible editor to edit the passage") + "";
}
diff -Nru bibledit-5.0.912/edit/index.js bibledit-5.0.922/edit/index.js
--- bibledit-5.0.912/edit/index.js 2020-09-19 18:30:19.000000000 +0000
+++ bibledit-5.0.922/edit/index.js 2020-11-15 19:26:10.000000000 +0000
@@ -55,6 +55,9 @@
}
$ ("#editor").on ("click", editorNoteCitationClicked);
+
+ $ ("#editor").bind ("paste", editorClipboardPasteHandler);
+
});
@@ -99,6 +102,18 @@
}
+// This fixes an issue where upon pasting text in the editor,
+// the editor scrolls to the very top of the text.
+// If the text is long, then the focused verse is thrown off the screen.
+// Here it fixes that.
+// https://github.com/bibledit/cloud/issues/428
+function editorClipboardPasteHandler (event)
+{
+ var currentScrollTop = $("#workspacewrapper").scrollTop();
+ $("#workspacewrapper").animate({ scrollTop: currentScrollTop }, 100);
+}
+
+
/*
Section for the new Passage event from the Navigator.
@@ -196,7 +211,11 @@
response = checksum_receive (response);
if (response !== false) {
// Only load new text when it is different.
- if (response != editorGetHtml ()) {
+ // Extract the plain text from the html and compare that.
+ // https://github.com/bibledit/cloud/issues/449
+ var responseText = $(response).text();
+ var editorText = $(editorGetHtml ()).text();
+ if (responseText != editorText) {
// Destroy existing editor.
if (quill) delete quill;
// Load the html in the DOM.
@@ -209,20 +228,21 @@
css4embeddedstyles ();
// Feedback.
editorStatus (editorChapterLoaded);
- }
- // Reference for comparison at save time.
- editorReferenceText = editorGetHtml ();
- // Position caret straightaway.
- if (reload) {
- positionCaret (editorCaretPosition);
- }
- editorScheduleCaretPositioning ();
- // Alert on reloading soon after save, or after text reload.
- // https://github.com/bibledit/cloud/issues/346
- editorLoadDate = new Date();
- var seconds = (editorLoadDate.getTime() - editorSaveDate.getTime()) / 1000;
- if ((seconds < 2) || reload) {
- if (editorWriteAccess) editorReloadAlert (editorChapterVerseUpdatedLoaded);
+ // Reference for comparison at save time.
+ editorReferenceText = editorGetHtml ();
+ // Position caret straightaway.
+ if (reload) {
+ positionCaret (editorCaretPosition);
+ }
+ editorScheduleCaretPositioning ();
+ // Alert on reloading soon after save, or after text reload.
+ // https://github.com/bibledit/cloud/issues/346
+ editorLoadDate = new Date();
+ var seconds = (editorLoadDate.getTime() - editorSaveDate.getTime()) / 1000;
+ seconds = 2; // Disable timer.
+ if ((seconds < 2) || reload) {
+ if (editorWriteAccess) editorReloadAlert (editorChapterVerseUpdatedLoaded);
+ }
}
} else {
// Checksum error: Reload.
@@ -278,6 +298,7 @@
editorSaving = false;
editorSaveDate = new Date();
var seconds = (editorSaveDate.getTime() - editorLoadDate.getTime()) / 1000;
+ seconds = 2; // Disable timer.
if (seconds < 2) {
if (editorWriteAccess) editorReloadAlert (editorChapterVerseUpdatedLoaded);
}
@@ -1078,6 +1099,7 @@
function editorReloadAlert (message)
{
+ return;
// Take action only if the editor has focus and the user can type in it.
if (quill.hasFocus ()) {
notifyItSuccess (message)
diff -Nru bibledit-5.0.912/edit/load.cpp bibledit-5.0.922/edit/load.cpp
--- bibledit-5.0.912/edit/load.cpp 2020-09-19 18:30:19.000000000 +0000
+++ bibledit-5.0.922/edit/load.cpp 2020-11-09 19:39:42.000000000 +0000
@@ -66,7 +66,6 @@
Editor_Usfm2Html editor_usfm2html;
editor_usfm2html.load (usfm);
editor_usfm2html.stylesheet (stylesheet);
- editor_usfm2html.quill ();
editor_usfm2html.run ();
string html = editor_usfm2html.get ();
diff -Nru bibledit-5.0.912/edit/navigate.cpp bibledit-5.0.922/edit/navigate.cpp
--- bibledit-5.0.912/edit/navigate.cpp 2020-09-19 18:30:19.000000000 +0000
+++ bibledit-5.0.922/edit/navigate.cpp 2020-11-09 20:00:52.000000000 +0000
@@ -68,7 +68,6 @@
Editor_Usfm2Html editor_usfm2html;
editor_usfm2html.load (usfm);
editor_usfm2html.stylesheet (stylesheet);
- editor_usfm2html.quill ();
editor_usfm2html.run ();
diff -Nru bibledit-5.0.912/edit/position.cpp bibledit-5.0.922/edit/position.cpp
--- bibledit-5.0.912/edit/position.cpp 2020-09-19 18:30:19.000000000 +0000
+++ bibledit-5.0.922/edit/position.cpp 2020-11-09 20:00:52.000000000 +0000
@@ -66,7 +66,6 @@
Editor_Usfm2Html editor_usfm2html;
editor_usfm2html.load (usfm);
editor_usfm2html.stylesheet (stylesheet);
- editor_usfm2html.quill ();
editor_usfm2html.run ();
int startingOffset = 0;
diff -Nru bibledit-5.0.912/edit/save.cpp bibledit-5.0.922/edit/save.cpp
--- bibledit-5.0.912/edit/save.cpp 2020-09-19 18:30:19.000000000 +0000
+++ bibledit-5.0.922/edit/save.cpp 2020-11-08 19:42:28.000000000 +0000
@@ -98,7 +98,6 @@
string stylesheet = Database_Config_Bible::getEditorStylesheet (bible);
Editor_Html2Usfm editor_export;
- editor_export.quill ();
editor_export.load (html);
editor_export.stylesheet (stylesheet);
editor_export.run ();
diff -Nru bibledit-5.0.912/edit2/edit.cpp bibledit-5.0.922/edit2/edit.cpp
--- bibledit-5.0.912/edit2/edit.cpp 1970-01-01 00:00:00.000000000 +0000
+++ bibledit-5.0.922/edit2/edit.cpp 2020-11-22 13:57:08.000000000 +0000
@@ -0,0 +1,68 @@
+/*
+ Copyright (©) 2003-2020 Teus Benschop.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+string edit2_edit_url ()
+{
+ return "edit2/edit";
+}
+
+
+bool edit2_edit_acl (void * webserver_request)
+{
+ if (Filter_Roles::access_control (webserver_request, Filter_Roles::translator ())) return true;
+ bool read, write;
+ access_a_bible (webserver_request, read, write);
+ return read;
+}
+
+
+string edit2_edit (void * webserver_request)
+{
+ Webserver_Request * request = (Webserver_Request *) webserver_request;
+
+
+ string href = request->query ["href"];
+ Passage passage = filter_integer_to_passage (convert_to_int (href));
+ Ipc_Focus::set (request, passage.book, passage.chapter, convert_to_int (passage.verse));
+ Navigation_Passage::recordHistory (request, passage.book, passage.chapter, convert_to_int (passage.verse));
+
+
+ // Check whether a Bible editor is alive.
+ int timestamp = request->database_config_user()->getLiveBibleEditor ();
+ bool alive = (timestamp > (filter_date_seconds_since_epoch () - 5));
+
+
+ if (alive) return translate ("The passage has been opened in the existing Bible editor");
+ return "" + translate ("Open a Bible editor to edit the passage") + "";
+}
diff -Nru bibledit-5.0.912/edit2/edit.h bibledit-5.0.922/edit2/edit.h
--- bibledit-5.0.912/edit2/edit.h 1970-01-01 00:00:00.000000000 +0000
+++ bibledit-5.0.922/edit2/edit.h 2020-09-26 17:03:22.000000000 +0000
@@ -0,0 +1,32 @@
+/*
+ Copyright (©) 2003-2020 Teus Benschop.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#ifndef INCLUDED_EDIT2_EDIT_H
+#define INCLUDED_EDIT2_EDIT_H
+
+
+#include
+
+
+string edit2_edit_url ();
+bool edit2_edit_acl (void * webserver_request);
+string edit2_edit (void * webserver_request);
+
+
+#endif
diff -Nru bibledit-5.0.912/edit2/embed.js bibledit-5.0.922/edit2/embed.js
--- bibledit-5.0.912/edit2/embed.js 1970-01-01 00:00:00.000000000 +0000
+++ bibledit-5.0.922/edit2/embed.js 2020-09-26 16:56:34.000000000 +0000
@@ -0,0 +1,106 @@
+/*
+ Copyright (©) 2003-2020 Teus Benschop.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+
+var embedded_classnames = [];
+
+
+// Creates CSS for embedded character styles.
+function css4embeddedstyles ()
+{
+ var spans = $ (".ql-editor span");
+ spans.each (function () {
+ var classname = $ (this).attr ("class");
+ if (classname) {
+ var index = classname.indexOf ("0");
+ if (index > 0) {
+ if ($.inArray (classname, embedded_classnames) < 0) {
+ embedded_classnames.push (classname);
+ var name = classname.substring (2);
+ var bits = name.split ("0");
+ var font_style = null;
+ var font_weight = null;
+ var font_variant = null;
+ // var font_size = null;
+ var text_decoration = null;
+ var vertical_align = null;
+ var color = null;
+ var background_color = null;
+ for (i = 0; i < bits.length; i++) {
+ name = bits [i];
+ var element = document.createElement("span");
+ element.className = name;
+ document.body.appendChild (element);
+ var properties = window.getComputedStyle (element, null);
+ var value = properties.getPropertyValue ("font-style");
+ if (value != "normal") font_style = value;
+ value = properties.getPropertyValue ("font-weight");
+ if (value != "normal") font_weight = value;
+ value = properties.getPropertyValue ("font-variant");
+ if (value != "normal") font_variant = value;
+ // The font-size is calculated in "px", and is not very important, so is left out.
+ // value = properties.getPropertyValue ("font-size");
+ // if (value != "12px") font_size = value;
+ value = properties.getPropertyValue ("text-decoration");
+ if (value != "none") text_decoration = value;
+ value = properties.getPropertyValue ("vertical-align");
+ if (value != "baseline") vertical_align = value;
+ value = properties.getPropertyValue ("color");
+ if (value != "rgb(0, 0, 0)") color = value;
+ value = properties.getPropertyValue ("background-color");
+ if (value != "rgba(0, 0, 0, 0)") background_color = value;
+ }
+ if (font_style) $.stylesheet ("." + classname, "font-style", font_style);
+ if (font_weight) $.stylesheet ("." + classname, "font-weight", font_weight);
+ if (font_variant) $.stylesheet ("." + classname, "font-variant", font_variant);
+ //if (font_size) $.stylesheet ("." + classname, "font-size", font_size);
+ if (text_decoration) $.stylesheet ("." + classname, "text-decoration", text_decoration);
+ if (vertical_align) $.stylesheet ("." + classname, "vertical-align", vertical_align);
+ if (color) $.stylesheet ("." + classname, "color", color);
+ if (background_color) $.stylesheet ("." + classname, "background-color", background_color);
+ }
+ }
+ }
+ });
+}
+
+
+// Returns the character style to apply based on the actual and desired style.
+function editor_determine_character_style (actual, desired)
+{
+ // Deal with undefined actual style.
+ if (!actual) actual = "";
+
+ // If the desired style is already applied, remove it again.
+ if (desired == actual) return "";
+
+ // If no character style has been applied yet, apply it.
+ if (actual == "") return desired;
+
+ // If the applied style is embedded already, just apply the desired style only.
+ if (actual.indexOf ("0") > 0) return desired;
+
+ // Add the desired style to the one already there.
+ return actual + "0" + desired;
+}
+
+
+function post_embedded_style_application (style)
+{
+ if (style.indexOf ("0") >= 0) css4embeddedstyles ();
+}
diff -Nru bibledit-5.0.912/edit2/index.cpp bibledit-5.0.922/edit2/index.cpp
--- bibledit-5.0.912/edit2/index.cpp 1970-01-01 00:00:00.000000000 +0000
+++ bibledit-5.0.922/edit2/index.cpp 2020-11-30 06:23:49.000000000 +0000
@@ -0,0 +1,191 @@
+/*
+ Copyright (©) 2003-2020 Teus Benschop.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include