Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notation on multiple elements? #36

Open
alienzhou opened this issue Jun 10, 2020 · 3 comments
Open

Notation on multiple elements? #36

alienzhou opened this issue Jun 10, 2020 · 3 comments

Comments

@alienzhou
Copy link

Great thanks for this awesome library! 🎉

In my project, I want to add a notation on multiple elements. However, it would generate multiple notations. An example below

My HTML:

<p>
  I would like to add
  <span class="bright">a notation</span><span class="emphasis"> here</span>.
</p>

And I want to add only one notation on the last two span elements. How can I make this?

@pshihn
Copy link
Collaborator

pshihn commented Jun 16, 2020

You could create a span around the two spans, or create an animation group.

const config = { type: 'underline', color: 'red' };
const a1 = annotate(span1, config);
const a2 = annotate(span2, config);

const ag = annotationGroup([a1, a2]);
ag.show();

Does that solve your use case?

@alienzhou
Copy link
Author

Thanks for your reply. Actually I'm trying to combine rough-notation with my library (which enables users to highlight some words on a website).

I have tried annotationGroup. But the notations are not visually continuous.

image

Beside, there is a case that creating a span around the two spans fails.

<span>I would like to<i> add </i></span><span><i>a </i>notation here</span>.

When users want to highlighting the two i elements, I can't easily wrap them in one element.

@pshihn
Copy link
Collaborator

pshihn commented Jun 17, 2020

My main concern is that if we allow multiple elements then I am not guaranteed that the elements are continuous or even have the same parent. They may also have margins between them. RoughNotation injects SVG relative to the element, but if there are multiple elements without a common parent it may get tricky where to inject the svg. Also, what happens when the selected text spans multiple elements across multiple lines?

I am trying to consider when someone else comes along whose use case is different than yours, and they pass two elements, what are their expectations? what if those elements are not next to each other.

Anyways, now that I understand your use case, let me think about it a bit more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants