0

http://kusoma.org.uk/write.html

Me and a friend are making a book community where users come together and write and share there book idea.

I am currently creating the text editor for them to create/edit there books.

What I want to do is when the first page is full it will create another one and you will continue to type into that one.

Im not sure what code you need to see to help me with a solution so request it and I will add it onto this post.

  • Is there a particular reason you're using `iframe` instead of just `div`? That would make it a lot simpler IMO. – Siguza Apr 30 '15 at 09:08
  • I didn't know you could do div's in design mode. I'm new to JavaScript. – Kyle Somerset Apr 30 '15 at 09:11
  • Well, you can use `contentEditable` on a div instead of `designMode`. Question is, do you need a WYSIWYG editor or just a text editor? Because websites do not really have a concept of pages, so you need to create that "effect" yourself, which is a lot easier when you only have text. – Siguza Apr 30 '15 at 09:27
  • How would I do the effect. I don't have a clue where to start with it? – Kyle Somerset Apr 30 '15 at 09:36
  • You need to calculate how many lines your text is going to occupy and split it into party accordingly, which you can then render in different divs. I suggest doing that by first putting the entire text into an invisible div and dividing the div's height by the text line height to get the number of lines. Then you know the amount of pages you need to draw. And then you need to start searching for where the lines actually end. I suggest doing that by inserting a span with dimensions 0x0 and reading its position relative to the outer div. – Siguza Apr 30 '15 at 10:17
  • (Comment are too short for me -.-) Start by inserting it at 50% of the words. If it is below the line you need, go to 25%, otherwise 75%, and so on util you reach the line you're looking for. – Siguza Apr 30 '15 at 10:17
  • It seems quite complicated, isn't they away to check if if its possible to scroll or not and work from that. – Kyle Somerset Apr 30 '15 at 11:18
  • Sure, but checking whether you can scroll only tells you if the text is longer than one page or not. You could use that together with dynamically removing and inserting parts of your text instead of working with a span, but the basic principle remains the same. – Siguza Apr 30 '15 at 11:52

0 Answers0