Text selection/Quotation feature

I got the chance to look at our text selection/quotation feature again. I have an updated version working on staging with the quote popup button.

Selecting a text brings up a quote button, clicking that button gives you a link and another button which lets you copy the link directly to the clipboard (this requires flash, but you can also manually copy the link). I have done only minimal styling of the popup as I know @sujato will have better ideas than me on how to style it ;).

There are unfortunately quite a few bugs as the feature is quite complex and fiddly. For example I don’t believe the copy link function always actually works, and it has issues when you start/end the selection on punctuation. Also, it works in Chrome, but I would not be at all surprised if it doesn’t work properly or even at all on lesser used browsers.

I would be interested in what people think of the usefulness of different precisions, at the one it has character level precision (basically the maximum), but it could also conceivably work at word or paragraph level precision meaning the quotation would be expanded from the original selection to include entire words, or the entire paragraph.

1 Like

Looking nice. Works fairly for me on Chrome, not at all in Firefox. But maybe best to just develop for Chrome to start with, figure out what we want, then see about extending support.

Would it not be better to simply select the passage, which brings up the highlighted link, which you can then copy? No buttons. Would this also mean no flash? (I’m not sure what exactly flash is required for, but if we can do without it, we should).

As for precision, I would have thought per word was good. Does this make it simpler or more complex?

Okay I’ve made some updates. Now the requested link only
behavior is implemented. The copy to clipboard is working fine, perfectly as far as I can tell. I haven’t tested it with flash unavailable but it should let you copy the url normally.

I am attempting to implement selection at a word level. Note that it needs special handling for CJK. Also I know that some langauges, such as thai, is often written without spaces. It seems the texts on SC have spaces added, but I suppose there could be cases of languages which do not fit neatly into either ‘break on spaces’ or ‘break into glyphs’.

very impressive

works pretty viable even with the punctuation bug

in current iteration might not be intuitive for a newcomer, took me a few tries to figure out how copying into the clipboard is performed

if it’s not the final version, i apologize for the critique

Looks great.

If this is a complication, perhaps better not to worry about it. Like you said, defining “word” is pretty hard for different languages. How is this handled in Bengali or Farsi? I have no idea! And there might be instances where this is undesirable: for example, you might want to select a specific term inside a long compound in Pali or Sanskrit.

Some more thoughts on it, and again I would suggest that we are better off just getting rid of the Flash component completely if that is possible. Reasons:

  1. Flash is being deprecated on mobiles.
  2. When I copy something, I highlight it and copy. That’s a behavior I’ve done thousands of times. I understand it and it makes me happy. “Click to copy” is not a behavior I’m used to. I don’t trust it, and it makes me think, did that work?
  3. Yes, you save a tiny bit of effort using “click to copy”, but so what? It’s not like you’re doing this hundreds of times. Simple, reliable, and predictable are more important.
  4. The only place it would be really helpful would be on touchscreens. But most touch devices don’t have flash anyway.

So I’m still thinking just have the popup and copy it the normal way, sans flash.

I’ve become kind of fond of the zeroclipboard method from github, photobucket and some other sites. It took some trust-building but once I realized it does work extremely reliably I started to like it a lot and it’s how I copy things now if a site permits it. If the only possible interaction you could want to perform with a field is to copy it, it’s very nice if a single click performs the copy action. I took the ‘Copied’ thing from Photobucket, because that was the site which ‘converted’ me from insisting on manually selecting and copying. (Photobucket now actually prevents you from manually selecting a hyperlink input field if zeroclipboard successfully loads, copy-on-click becomes the only mechanism you can use to copy the URL. This is how photobucket convinced me that it really does work. Also I’ve been using photobucket for about 12 years, it’s never lost a single image I’ve uploaded which is quite an accomplishment on the web for a free service, and so I consider it a site which does things in sensible and proven ways)

The contra argument to flash being depreciated is the new HTML5 clipboard API functions available now in IE, Chrome and Opera, i.e. http://updates.html5rocks.com/2015/04/cut-and-copy-commands, http://caniuse.com/#feat=clipboard

This is extremely new so I would be wary of using it. In contrast, zeroclipboard is extremely mature and extremely reliable and used by important websites such as github. But my point here is that it is not like ‘copy on click’ is a technique as a whole which is being depreciated, rather it is being standardized and being made more widely available. There is an upgrade path and soon flash solutions like zeroclipboard will be the fallback when the native HTML5 javascript functions aren’t available.

Well we know it’s not going to cover every case perfectly. Question is though, in those numerous cases where it does work well, is it superior? I think it does work better in making tidy references, the 11th though 19th words, is better than the 89th through 167th alphabetical characters. A scheme which references additionally by sentence would be even more human-parsable (i.e. 1.1.1 would be the first word of the first sentence of the first paragraph) and less frail in the face of minor modifications. For instance, if you decided to change ‘bhikkhus’ into ‘monks’ or vice-verca then that would completely throw off a character based reference, but a word-based one would be unfazed. A way of referencing sentences would also be useful in general I think, as after all the sentence is the smallest translatable unit. Code which can pick out the nth sentence of a paragraph would be useful I think. This is well worth considering now because we’re going to be somewhat stuck with the referencing scheme.

The feature as a whole is insanely complicated but most of that complexity is in the DOM and selection handling code. Counting words rather than characters doesn’t make it much more complicated nor even making it do sentences. It’s just the whole thing is kind of frail at the moment and needs a bit of refactoring to make it more robust.

Okay, fine that all makes sense. Meanwhile I’ve tweaked a few bits of CSS and deployed the latest version live; it seems you forgot to deploy the latest version.

When any changes are made to a text, it would make sense if it would fall back to the next coarsest level, rather than break entirely:

From glyph>word>sentence>paragraph.

That is, assuming we can select glyphs, if not then start with the word.

So if I select “monks” then change it to “bhikkhus”, the glyph select fails, but it will fall back to the word. If I change it to “beggarly inclined individuals”, then the word breaks but I still get the sentence. Of course, in the latter case it should trigger an automatic “Buddhist Hybrid English” warning as well… :unamused:

Fallbacks aren’t possible because in the majority of cases there will be no way to know that the underlying document has actually changed - at least not without formally versioning the texts and including a version parameter in the quotation link.

Which would become still more complicated…

So I think the intrinsic fall-backing from a paragraph/sentence/word is going to the best bet. Especially if I can make it as smart as possible about detecting when a whole sentence or paragraph is selected. The less unnecessary precision included in the reference, the more robust it will be.