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 }) {
-
= chapters.length) {currChIndex = 0;}
+ const { start, end, title } = chapters[currChIndex];
+ const startTimeStr = timestr.toPrettierTimeString(start);
+ const endTimeStr = timestr.toPrettierTimeString(end);
+ const showResetBtn = chapters.length > 1 || chapters[0].subChapters.length > 0;
+ const showSplitAllBtn = chapters.length !== items.length;
+
+ const watchInPlayer = () => {
+ dispatch({
+ type: 'epub/openPlayer', payload: {
+ title: `Chapter ${currChIndex + 1}: ${title}`, start, end
+ }
+ });
+ };
+
+ const onEditChapters = () => {
+ dispatch({ type: 'epub/setView', payload: epubOld.const.EpbEditChapter });
+ };
+
+ // 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/EditEPubStructure/index.js b/src/screens/EPub/views/EditEPubStructure/index.js
index bb70220ac..a631f383b 100644
--- a/src/screens/EPub/views/EditEPubStructure/index.js
+++ b/src/screens/EPub/views/EditEPubStructure/index.js
@@ -43,12 +43,13 @@ function EditEPubStructure({ epub: epubData, dispatch }) {
{epubData.title}
-
+
{itemViewElem}
+
);
diff --git a/src/screens/EPub/views/EditINote/index.js b/src/screens/EPub/views/EditINote/index.js
index eea9d38b4..a62a3dec5 100644
--- a/src/screens/EPub/views/EditINote/index.js
+++ b/src/screens/EPub/views/EditINote/index.js
@@ -1,25 +1,88 @@
import React, { useEffect, useState } from 'react';
import _ from 'lodash'
-import { CTFragment, CTHeading, CTText } from 'layout';
+import cx from 'classnames';
+
+import ButtonGroup from '@material-ui/core/ButtonGroup';
+import { CTFragment, CTHeading, CTText, altEl, useButtonStyles } from 'layout';
import { connect } from 'dva'
import { EPubNavigationProvider } from '../../components';
-import { epub as epubController} from '../../controllers';
+import { epub as epubController, generateEPubGuide} from '../../controllers';
import INoteEditor from './INoteEditor';
+import Instruction from '../EditEPubStructure/Instruction';
+import EPubItemView from '../EditEPubStructure/EPubItemView';
+import QuickActionsEditNote from '../EditEPubStructure/QuickActionsEditNote';
+import Button from '@material-ui/core/Button';
// 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 [ePubItem, setEPubItem] = useState(null);
+ const [instExp, setInstExp] = useState(true);
+
+ const toggleInstExp = (e, newExpanded) => setInstExp(newExpanded);
+
+ useEffect(() => {
+ // show the user onboard guide if possible
+ setTimeout(() => {
+ const guide = generateEPubGuide();
+ guide.start();
+ }, 1000);
+ }, []);
+
+ useEffect(() => {
+ if (Boolean(ePubItem) && instExp) {
+ setInstExp(false);
+ }
+ }, [ePubItem]);
+ const itemViewElem = altEl(EPubItemView, Boolean(ePubItem), {
+ item: ePubItem, setEPubItem
+ });
+ const btnStyles = useButtonStyles();
+ const btnClasses = cx(btnStyles.tealLink, 'justify-content-start');
const [iNoteItem, setINoteItem] = useState(null);
+ const [hidden, setHidden] = useState(true);
return (
-
+
{epubData.title}
setINoteItem={setINoteItem} dispatch={dispatch}
+
+ {hidden ?
+ <>
+
+
+
+
+
+
+
+ >
+
+ :
+ <>
+
+
+
+
+
+
+
+
+
+
+
+ >
+ }
+
+
+
+
+
)