zotero / zoterobib

ZoteroBib is a free online bibliography generator from the makers of Zotero
https://zbib.org
Other
70 stars 19 forks source link

In-text citations #177

Closed dstillman closed 6 years ago

dstillman commented 6 years ago

When the current style is an author or author-date style (so, as a hacky but sufficient test, when the style code contains citation-format="author), we should add a button in each entry to copy an in-text citation.

Later we could extend this with a popup that allowed the addition of page numbers and perhaps other modifications, but for now just copying the basic citation would keep people from needing to retype the author's name for every citation.

We can generate the necessary HTML and text like this:

async handleCopyCitation(itemId) {
    var citeproc = await getCiteproc(
        this.state.citationStyle,
        this.bib,
        false
    );
    var citation = {
        citationItems: [{ id: itemId }],
        properties: {}
    };
    var html = citeproc.previewCitationCluster(citation, [], [], "html"); 
    var text = citeproc.previewCitationCluster(citation, [], [], "text");

    […]
}

As a temporary solution, we could just show (…) to the left of the delete-entry button. @flachware will probably have better longer-term ideas.

flachware commented 6 years ago

I’d say let’s go back what we had in the first drafts. We switched to the × icon because we wanted to optimized for the case when there is just Edit and Delete. Now that we have Edit, Copy Citation/Copy note, and Delete we could put Edit back to the dropdown menu (would be good for touch devices, as there is no hover state to indicate the clickable citation entries in the bibliography) and have three menu entries at least. I guess there will be even more options in that menu in the future.

I wouldn’t add the (…) icon in addition to the × because we would lose way to much space on mobiles.

screen shot 2018-04-20 at 16 01 18
dstillman commented 6 years ago

Were you thinking that entries would still be editable by click, though, with a redundant Edit menu option for discoverability? I might be OK with that. I don't think it's worth losing tap-to-edit — editing entries will be a very frequent action, so it's important that that stays seamless. (It looks like GitHub just buried Edit in a menu in order to add Hide and I'm already annoyed, and I edit GitHub comments less than you would need to edit ZBib entries.)

My main concern is that, if we're going to have citation copying at all, having it be in a menu is kind of annoying for something you'll be using constantly as you write, so it might be worth exploring other options for keeping it visible. To be clear, optimizing for phones really isn't important here, so I'd be fine with using a menu there but still keeping a visible copy button on desktop/iPad if we thought we had the room (and a better indicator than (…), which isn't accurate anyway if this supports notes).

flachware commented 6 years ago

Yes I would keep the click/tap-to edit in any case (even if that means a redundant option in a menu).

I’d like to try some UI ideas around the copy functionality (without cluttering the interface with a lot of permanent icons). But before doing that I’d like to check back: do you think a copy icon is good enough do convey either 'copy (in-text) citation' / 'copy (foot)note'? (As opposed to just copying the citation text you can see in the bibliography) We will probably end up with a generic 'copy' or 'quote' icon (which would copy citation or note, depending on the style), both are not really specific. I just want to make sure that we don’t realize at the end that we actually need a dropdown menu, because the text in there can be more specific than an icon.

(and a better indicator than (…), which isn't accurate anyway if this supports notes)

I fear I don’t quite understand – could you elaborate on that?

dstillman commented 6 years ago

do you think a copy icon is good enough do convey either 'copy (in-text) citation' / 'copy (foot)note'? […] We will probably end up with a generic 'copy' or 'quote' icon

I think the increased usability of not being in the menu is worth any initial confusion. We can also of course have a tooltip here, and even a custom one that appears immediately on hover to make it explicit.

'Quote' isn't totally accurate — you can cite something without quoting it — but might be clearer as an icon than 'copy', and it's what we've used in the word processor plugins. (The latest word processor plugin icons, which I think were contributed, use "[-]", but I don't think we want to use that here.)

Re: '(…)', while in-text styles uses parentheses, note styles don't — the note format is generally just a shortened form of the reference. Note styles are arguably one of the more compelling uses of this, so parentheses probably don't make sense.

tnajdek commented 6 years ago

We should probably add some sort of feedback on successful copy in the modal.

dstillman commented 6 years ago

So this just needs some basic styling of the dialog (with, for example, the locator selector on the same line as the input).

(For styling, note that "Omit Author" is only present for some styles.)

flachware commented 6 years ago

@tnajdek we would need a conditional disabled attribute on the 'copy citation' button when the preview is empty (which i think can only happen when the user ticks 'omit author').