JohnMcLear / ep_page_view

Etherpad Page View plugin
https://npmjs.org/package/ep_page_view
14 stars 17 forks source link

Page break following cursor #34

Open poafernandes opened 6 years ago

poafernandes commented 6 years ago

Hello, I recently started using etherpad and I'm having trouble with page breaks

One of the problems is shown below, where if I go to the line above, the page break dissapears, following the cursor instead of the text already written.

The other problems I think are related to this one, like trying to insert a new page break with enter at the end of the current page and the editor inserting the break for a split second and then removing it instantly. Any tips on how to deal with this?

boooa

lpagliari commented 6 years ago

@poafernandes page break is still a very unstable feature, I would not recommend using it. We've disabled it on our project because of that.

BTW: 2nd problem seems to be the same of #20

JohnMcLear commented 6 years ago

+1 disable it. I don't have time to fix at the moment

jon9m commented 6 years ago

As a solution to this issue I suggest the following.

page_view.js ---------------------------------------------- line 428 - Add a <br> to the div $(this).append("<div class='pageBreakComputed' contentEditable=false><br></div>");

shared.js ---------------------------------------------------

var _ = require('ep_etherpad-lite/static/js/underscore');

var collectContentPre = function(hook, context){
  var tname = context.tname;
  var state = context.state;
  var cls = context.cls;
  var lineAttributes = state.lineAttributes

  console.log("PRE lineAttributes : " + JSON.stringify(lineAttributes));

  var tagIndex = tname;
  if(tagIndex >= 0){
    lineAttributes['pageBreak'] = tagIndex;
  }else if(cls.indexOf('pageBreakComputed') != -1){
    lineAttributes['pageBreak'] = tagIndex;
  }
};

var collectContentPost = function(hook, context){
  var tname = context.tname;
  var state = context.state;
  var lineAttributes = state.lineAttributes
  var cls = context.cls;
  var tagIndex = tname;

  console.log("POST lineAttributes : " + JSON.stringify(lineAttributes));

  if(tagIndex >= 0){
    delete lineAttributes['pageBreak'];
  }else if(cls.indexOf('pageBreakComputed') != -1){
    delete lineAttributes['pageBreak'];
  }
};

exports.collectContentPre = collectContentPre;
exports.collectContentPost = collectContentPost;