Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Add support for autolink (typing and pasting) #233

Closed
Natim opened this issue Sep 18, 2017 · 5 comments
Closed

Add support for autolink (typing and pasting) #233

Natim opened this issue Sep 18, 2017 · 5 comments
Milestone

Comments

@Natim
Copy link
Collaborator

Natim commented Sep 18, 2017

Refs slab/quill#109 (comment)

@johngruen johngruen added this to the Next milestone Sep 21, 2017
@vladikoff
Copy link
Contributor

vladikoff commented Sep 21, 2017

We need 2 things for this:

1. pasting urls

We need url support but without the Quill editing UI:
links

To enable ability to see urls in Quill add:

diff --git a/src/sidebar/panel.js b/src/sidebar/panel.js
index e34b085..7353b85 100644
--- a/src/sidebar/panel.js
+++ b/src/sidebar/panel.js
@@ -1,6 +1,7 @@
 const formats = [
   'bold',
   'font',
+  'link',
   'italic',
   'size',
   'strike',

2. typing

When you type a url or copy something like this: https://github.com/mozilla/notes it should turn it into a URL. See slab/quill#109 (comment) for details

Also:

  • Clicking on links should open a new tab, right now it opens a new window with link enabled.
  • Measure link click events

cc @johngruen @cedricium

@cedricium
Copy link
Collaborator

cedricium commented Sep 25, 2017

As far as typing goes, I used the code outlined in this answer and it works pretty well. Based on the regex used in that code, only text beginning with http:// or https:// will be recognized, whereas Google Docs matches text beginning with just www. as well.

Another note with the example code given in the above comment is that the typed text should be followed by whitespace (either a space or newline will do), otherwise any proceeding text may become a part of the link itself. One way of preventing this would be to implement the Cmd/CtrlK shortcut to allow toggling on and off linking for highlighted text.

need url support but without the Quill editing UI

Do you suggest removing that editing tooltip entirely, or replacing it with our own?  

@vladikoff
Copy link
Contributor

only text beginning with http:// or https:// will be recognized

That sounds good for starters 👍

Another note with the example code given in the above comment is that the typed text should be followed by whitespace (either a space or newline will do)

That's also fine. I think G Docs might do this too.

Do you suggest removing that editing tooltip entirely, or replacing it with our own?

If we can avoid the tooltip entirely that would be great. Due to the sidebar nature of the project we are trying to stay away from these tooltips :)

cedricium added a commit to cedricium/notes that referenced this issue Sep 25, 2017
This is the initial implementation for supporting links (mozilla#233). With these changes,
links will automatically be created from anything that begins with `http://`
or `https://`. That includes any typed or pasted text.

The changes in the CSS make it so that the Quill link editing UI tooltip is
no longer shown. In order to open a link, the user must mouse over the link
and right-click for the context menu or `Ctrl/Cmd + Click` to open in a new tab.
@cedricium cedricium mentioned this issue Sep 25, 2017
2 tasks
@cedricium
Copy link
Collaborator

Created a pull request with the basic support for links. Still need to add link mouse click events to the analytics.

@Natim
Copy link
Collaborator Author

Natim commented Sep 29, 2017

Fixed with 75c7514

@Natim Natim closed this as completed Sep 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants