bespokejs / bespoke

DIY Presentation Micro-Framework
http://markdalgleish.com/projects/bespoke.js/
MIT License
4.69k stars 442 forks source link

plugin run when before hook events. #36

Closed suisho closed 10 years ago

suisho commented 10 years ago

Hello. I tried to create plugin that modify sections before bespoke start hook event. But currently cannot that.

Out of necessity, I implement this function as outside plugin. But that so dirty. :sob: like this

beforeBespke('article', function(from){
  bespoke.from(from, {
    keys: true,
    touch: true,
  });
})
var beforeBespke = function(from, callback){
  // emulate bespoke from
  var parent = selectorOrElement.nodeType === 1 ? selectorOrElement : document.querySelector(selectorOrElement)
  var slides = [].filter.call(parent.children, function(el) { return el.nodeName !== 'SCRIPT'; })
  var deck = {
    slides : slides
  }

  //  :
  // do something modification to slide.
  // (This is a point want to plugin)
  //  :

  callback(from)
}

Please tell me if you have more good idea

markdalgleish commented 10 years ago

What is your plugin attempting to do? I've considered this functionality in the past, but I've never personally had a need for this so I've avoided complicating things.

suisho commented 10 years ago

Sorry, my case is actually rare case, not commonly.

In detail, I need print out PDF and use that on the presentation. And split bullets page when print out. (I omit the reason for must use PDF, because complex and shitty..)

For example,

origin

<article>
  <section>
    <ul>
      <li> list 1 </li>
      <li> list 2 </li>
      <li> list 3 </li>
    </ul>
  </section>
</article>

after convert

<article>
  <section>
    <ul>
      <li> list 1 </li>
    </ul>
  </section>
  <section>
    <ul>
      <li> list 1 </li>
      <li> list 2 </li>
    </ul>
  </section>
  <section>
    <ul>
      <li> list 1 </li>
      <li> list 2 </li>
      <li> list 3 </li>
    </ul>
  </section>
</article>

This is sample http://suisho.github.io/bespoke-printable-bullete/

markdalgleish commented 10 years ago

I've actually discussed this functionality with a couple of other Bespoke users and it's possible without modifying the slide markup.

Our idea was to use PhantomJS to take a screenshot of every state, calling deck.next() until the presentation finishes. The benefit of this approach is that it would allow all custom themes to be printable without the need for a special print styles.

Sorry, but I'm going to close this issue. I'm open to the idea if a compelling use case comes along, but I'm afraid this isn't it.

suisho commented 10 years ago

Ok, Thank you.