diff --git a/src/screens/EPub/models/data_reducer.js b/src/screens/EPub/models/data_reducer.js
index 47ed486a3..2e54d54a5 100644
--- a/src/screens/EPub/models/data_reducer.js
+++ b/src/screens/EPub/models/data_reducer.js
@@ -324,9 +324,9 @@ export default {
chapters[chapterIdx].title = value;
return { ...state, epub: { ...state.epub, ...nextStateOfChapters([...chapters]) } };
},
- splitChaptersByScreenshots(state, {payload: {wc}}) {
+ splitChaptersByScreenshots(state, {payload: {wc}}) { // Enforces Word Count
console.log(`Splitting chapters by screenshots`);
- const new_items = [];
+ const new_items = []; // duplicating some sentences (sentences with less than wc words)
// min word count that each chapter should have
const default_word_count = 25;
let min_word_count = wc;
@@ -338,30 +338,31 @@ export default {
if (min_word_count > total_word_count) {
min_word_count = default_word_count;
}
- // loop through chapters and enforce minimum wc
+ // loop through chapters and enforce minimum wc
(state.items).forEach(function(elem) {
- let words = (elem.text).split(' ').length;
- if (words < min_word_count && new_items.length!==0 ) {
+ if (new_items.length!==0) {
const oldelem = new_items.pop();
+ let words = (oldelem.text).split(' ').length;
+ if(words < min_word_count ) {
// append shorter text to previous chapter
- oldelem.text += " ";
- oldelem.text += elem.text;
- new_items.push(oldelem);
+ oldelem.text += " ";
+ oldelem.text += elem.text;
+ new_items.push(oldelem);
+ }
+ else {
+ new_items.push(oldelem);
+ new_items.push(elem)
+ }
} else {
new_items.push(elem);
}
});
// makes sure the first element also has a min of min_word_count words
- const first_elem = new_items.shift();
- let words = (first_elem.text).split(' ').length;
+ const last_elem = new_items.pop();
+ let words = (last_elem.text).split(' ').length;
if(words < min_word_count) {
- if(new_items.length !== 0) {
- let elem_next_text = "";
- // append first chapter's text to next chapter
- elem_next_text += " ";
- elem_next_text += new_items.shift().text;
- first_elem.text += elem_next_text;
- new_items.unshift(first_elem);
+ if(new_items.length !== 0 && words.length !== 0) {
+ new_items.push(last_elem);
}
}
let splitChapters = _.map(
diff --git a/src/screens/EPub/views/EditEPubChapter/index.js b/src/screens/EPub/views/EditEPubChapter/index.js
index 0e0b16e65..9d395e5a6 100644
--- a/src/screens/EPub/views/EditEPubChapter/index.js
+++ b/src/screens/EPub/views/EditEPubChapter/index.js
@@ -19,7 +19,6 @@ function EditEPubChapter({ dispatch }) {
-
{epubData.title}
-
+
{itemViewElem}
+
);
diff --git a/src/screens/EPub/views/EditINote/INoteEditor/INoteChapter.js b/src/screens/EPub/views/EditINote/INoteEditor/INoteChapter.js
index fd6a6ae4d..ed40c2a41 100644
--- a/src/screens/EPub/views/EditINote/INoteEditor/INoteChapter.js
+++ b/src/screens/EPub/views/EditINote/INoteEditor/INoteChapter.js
@@ -199,24 +199,24 @@ function INoteChapter ({
{addTextElement(itemIdx)}
- {typeof content === "object" ? ( // image
-
-
-
+ {typeof content === "object" ? ( // image
+
+
+
) : ( // text
-
-
-
+
+
+
)}
))}
diff --git a/src/screens/EPub/views/EditINote/QuickActionsEditNote.js b/src/screens/EPub/views/EditINote/QuickActionsEditNote.js
new file mode 100644
index 000000000..986031d18
--- /dev/null
+++ b/src/screens/EPub/views/EditINote/QuickActionsEditNote.js
@@ -0,0 +1,87 @@
+import React, {useState} from 'react';
+import cx from 'classnames';
+import Button from '@material-ui/core/Button';
+import TextField from '@material-ui/core/TextField';
+
+import ButtonGroup from '@material-ui/core/ButtonGroup';
+import { CTHeading, CTFragment, useButtonStyles } from 'layout';
+import { connect } from 'dva'
+
+function QuickActionsEditNote({ chapters = {}, items, currChIndex = 0, dispatch }) {
+ const btnStyles = useButtonStyles();
+ const btnClasses = cx(btnStyles.tealLink, 'justify-content-start');
+ if (currChIndex >= chapters.length) {currChIndex = 0;}
+ const showResetBtn = chapters.length > 1 || chapters[0].subChapters.length > 0;
+ const showSplitAllBtn = chapters.length !== items.length;
+
+ // default state is min word count of 25 for split by screenshots
+ const [wordInput, setWordInput] = useState("25");
+ const handleOnSubmit = (event) => {
+ event.preventDefault();
+ dispatch({type: 'epub/splitChaptersByScreenshots', payload:{wc: wordInput}});
+ };
+ const handleOnWcChange = (event) => {
+ setWordInput(event.target.value);
+ };
+
+ return (
+
+ Quick Split
+
+
+ {
+ showResetBtn
+ &&
+
+ }
+ {
+ showSplitAllBtn
+ &&
+
+ }
+ {/* {
+ showSubdivideAllBtn
+ &&
+
+ } */}
+
+
+
+
+
+
+ );
+}
+
+export default connect(({ epub: { currChIndex, epub: { chapters }, items }, loading }) => ({
+ currChIndex, chapters, items
+}))(QuickActionsEditNote);
diff --git a/src/screens/EPub/views/EditINote/index.js b/src/screens/EPub/views/EditINote/index.js
index eea9d38b4..7158cacad 100644
--- a/src/screens/EPub/views/EditINote/index.js
+++ b/src/screens/EPub/views/EditINote/index.js
@@ -1,25 +1,51 @@
import React, { useEffect, useState } from 'react';
import _ from 'lodash'
-import { CTFragment, CTHeading, CTText } from 'layout';
+
+import ButtonGroup from '@material-ui/core/ButtonGroup';
+import { CTFragment, CTHeading} from 'layout';
import { connect } from 'dva'
+import Button from '@material-ui/core/Button';
import { EPubNavigationProvider } from '../../components';
import { epub as epubController} from '../../controllers';
import INoteEditor from './INoteEditor';
+import QuickActionsEditNote from './QuickActionsEditNote';
+
// import './index.scss';
function EditINote ({epub: epubData, dispatch}) {
const dispatchScroll = _.debounce((e) => dispatch({ type: 'epub/onScroll', payload: e }), 300)
const onScroll = (e) => dispatchScroll(e.target)
-
+
const [iNoteItem, setINoteItem] = useState(null);
+ const [hidden, setHidden] = useState(true);
return (
-
+
{epubData.title}
setINoteItem={setINoteItem} dispatch={dispatch}
+ {hidden ?
+ <>
+
+
+
+
+
+
+
+ >
+ : <>
+
+
+
+
+
+
+
+
+ >}
)