guardian / scribe

DEPRECATED: A rich text editor framework for the web platform
http://guardian.github.io/scribe/
Apache License 2.0
3.51k stars 245 forks source link

Can Scribe be applied to multiple fields (e.g. title and body)? #330

Closed ltazmin closed 9 years ago

ltazmin commented 9 years ago

Since Scribe can't accept multiple elements: (i.e var scribe = new Scribe(document.querySelectorAll('.scribe'));)

We tried to create multiple instances for each field instead, but there seems to be a problem with one interfering with the other. For example:

var title = new Scribe(titleEl);
var body = new Scribe(bodyEl);

Is this a known issue or is it actually possible to create multiple instances of Scribe (If so, how)?

hmgibson23 commented 9 years ago

There will likely be issues with the selection when working with multiple scribe instances. Do you get an error when you use more than one or does it just not work?

rrees commented 9 years ago

I believe that we are having issues with some event propagation with multiple Scribe instances but we do have pages that run multiple Scribe instances so it is possible for the bulk of the core functionality.

cc @cutandpastey

cutandpastey commented 9 years ago

Yeah, you used to be able to register multiple identical event handlers in src/event-emitter but thats not such a big deal (and has been fixed, see: https://github.com/guardian/scribe/pull/328).

Also multiple scribe instance used to have a place markers bug, for example if you have three instances and a collapsed selection within a given scribe element, when Selection.placeMarkers was called you would get three <em class='scribe-marker'></em>. This was fixed in https://github.com/guardian/scribe/pull/324 but leads to https://github.com/guardian/scribe/issues/329 which might be effecting you.

What I can tell you is that it is totally possible to have multiple instances of Scribe on a page, @hmgibson23 and @robinedman might be able to let you know about some implementation details, but it would be best to:

If we get these we should be able to help out.

rrees commented 9 years ago

I've created a FAQ in the Scribe wiki with the short answer for the this.

Thanks for asking @ltazmin