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

Show Bubble theme toolbar on single click #1120

Closed
bleutzinn opened this issue Nov 20, 2016 · 5 comments
Closed

Show Bubble theme toolbar on single click #1120

bleutzinn opened this issue Nov 20, 2016 · 5 comments

Comments

@bleutzinn
Copy link

For the user to see the Bubble theme toolbar he has to select text first.
However, to insert an image and to 'turn on' bold or italic writing there is no need to select text.

So, I think, it would be nice to have an option to let the toolbar show on a single click in the editor area.

@jhchen
Copy link
Member

jhchen commented Nov 22, 2016

I'm not sure the insert image button inside the Bubble tooltip is a good user experience for the reason you mentioned. The problem with opening on click is users typically click around while reading and the persistent tooltip would be very annoying. I would suggest adding external UI like Medium does for inserting images.

@jhchen jhchen closed this as completed Nov 22, 2016
@mauteri
Copy link

mauteri commented Apr 16, 2017

Old and closed topic, but thought I'd share my two cents. Though I agree a single left click can be a strange UI, I feel a single right-click would be a good UI for a such a think... That said this is the solution I came up with. There might be a better one for doing the same thing, but I'm still pretty new to Quill...

$(document).on('contextmenu', '#quill-editor-container', function(e) {
	e.preventDefault();
	quill.theme.tooltip.edit();
	quill.theme.tooltip.show();
	return false;
});

I found quill.theme.tooltip.edit() puts the Bubble editor in the correct position, while quill.theme.tooltip.show() showed it in the right context. If there's a better way, would love to know it. Thx!

@madhavan-sundararaj
Copy link

Thanks for the solution @mauteri, how to make editor show the selected formats?

@yaayes
Copy link

yaayes commented Dec 3, 2019

Thank you @mauteri helped me a lot, one thing to note, when the editor is empty and you try to add a link without any selected text things go weird! the placeholder persists and console shows errors, in addition to your solution we should add a custom handler for link and prevent applying link format on nothing!

handlers: {
  link: value => {
    // Prevent links format when no text is selected
    let range = this.quill.getSelection();
    if(!range || range.length == 0){
      return;
    }

    if (!value) {
      this.quill.format("link", false);
    } else {
      this.quill.theme.tooltip.edit();
    }
  }
}

@mkamalkayani
Copy link

mkamalkayani commented Mar 26, 2021

The Bubble theme can be extended to achieve the single click behaviour. Here is how I have implemented it.

const BubbleTheme = Quill.import('themes/bubble');

class ExtendBubbleTheme extends BubbleTheme {
  constructor(quill, options) {
    super(quill, options);

    quill.on('selection-change', range => {
      if (range) {
        quill.theme.tooltip.show();
        quill.theme.tooltip.position(quill.getBounds(range));
      }
    });
  }
}

Quill.register('themes/bubble', ExtendBubbleTheme);

Edit quill-bubble-tooltip

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

6 participants