-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Update the authorship module from 0.20.1 to 1.0.0 #1049
Conversation
@benbro I still believe there is an issue with this module. The cursor disappears as soon as you start typing. I set the background to transparent and still the cursor disappears. So this is not due to the cursor blending in with background.
I am positive it is the authorship module, because when I comment out the authorship module when initializing quill, the cursor does not disappear. The cursor disappears yet the editor remains focused. If you press the back arrow key, the cursor reappears again. When you start typing, it disappears. This is not an issue for you? Can you test again? When quill is updating the content silently maybe the cursor disappears. |
Solution: #1057 (comment) |
I'd like to see if we can not inject |
I wasn't aware of CSP. How do you check what compatible with CSP directive of style-src: self? What about using a style attributor instead of a class attributor? Do you want this module in core? |
@@ -28,6 +28,7 @@ import CodeBlock, { Code as InlineCode } from './formats/code'; | |||
import Formula from './modules/formula'; | |||
import Syntax from './modules/syntax'; | |||
import Toolbar from './modules/toolbar'; | |||
import Authorship from './modules/authorship'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other modules are imported in a alphabetical order; so this should be at the top.
@@ -89,6 +90,7 @@ Quill.register({ | |||
'modules/formula': Formula, | |||
'modules/syntax': Syntax, | |||
'modules/toolbar': Toolbar, | |||
'modules/authorship': Authorship, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
Since the authorship module is unavailable in Quill, I tried adding this code as a custom module. I am having trouble getting quill.updateContents to work: It returns nothing instead of what was in authorDelta and I don't see the author attribute when I call getContents to view the data. If I remove the author attribute from the delta, then updateContents works just fine. Is there something missing to register author as an attribute? I'm not sure how to get quill to accept a custom attribute. |
The module needs to be built with Quill. I don't think you can add as custom module. |
@benbro just a heads up, this version of the Authorship causes a weird document state when applying/unapplying formatting (tested on Quill@v1.1.7): Given a line that looks like this: <p>
<span class="ql-author-1">See 2015 Q4 Goals</span>
</p> Make "See" bold so that the line now looks like this: <p>
<b class="ql-author-1">See</b>
<span class="ql-author-1"> 2015 Q4 Goals</span>
</p> Then unbold "See" and notice that the line now looks like the following instead of reverting to the initial example: <p>
<span class="ql-author-1">See</span> 2015 Q4 Goals
</p> |
Using quill 1.1.9 I found a new issue with the authorship module. I also have a hack (code below) which serves as a solution to this issue. Say 2 different users are editing a quill document. Each user has a different authorClass. When 2 different authors edit content you get dom html that looks like this: <span class="ql-author-guest">Hello from Guest Author</span>
<span class="ql-author-ph3MwMWaGGMbP2qdR">Main Author is typing here</span> Now imagine that I am author I think this might be due to a browser bug? But now sure.... I was able to come up with a fix sel = rangy.getSelection()
node = sel?.nativeSelection.anchorNode
if sel.isCollapsed
if node? and !$(node).hasClass('ql-clipboard')
if Meteor.userId()
authorClass = 'ql-author-' + Meteor.userId()
else
authorClass = 'ql-author-guest'
if !$(node).hasClass(authorClass) and $(node).is('span') and ($(node).attr('class').indexOf('ql-author') isnt -1)
if sel.rangeCount and sel.anchorOffset > 0
if node.nextSibling? and $(node.nextSibling).hasClass(authorClass)
range = sel.getRangeAt(0)
range.collapse false
range.collapseToPoint(node.nextSibling, 1)
sel.setSingleRange range
# The code above explains the issue and I should only need the code above.
# But for some reason I have to add the code below because otherwise
# the cursor gets placed at the end of the next span element instead of the beggining.
# Even though I specify the beggining at index 1.
sel = rangy.getSelection()
node = sel?.nativeSelection.anchorNode
range.refresh()
range.collapseToPoint(node, 1)
sel.setSingleRange range As you can see I am checking if the node you are typing in has your own authorClass. If not, that's an issue, and we need to move the cursor over to the next node at index 1. This is the newly created span element with your authorClass and the cursor is positioned right after the first character you started to type. From that point on everything is good because you are typing in the correct span element of your own authorClass. The hack kicks in only when it detects that you are not typing in a span element of your own authorClass, which is the issue. Tested with Quill 1.1.9 and all seems to be working with this fix. Let me know if I should open a new issue for this and link it back to this one. |
Another issue I notice with the current authorship module has to do with the selection. This seems to be related to #1152 which @sbevels mentioned. When you use the toolbar to format a word in the middle of a sentence, for example making a word bold. And then while the toolbar is still open, un-bold the word, the selection highlights the entire div. You can try it here, I am running quill 1.1.9 with the authorship module. I am not sure what is going on or how to fix this. Any advice @sbevels ? |
@sbevels And also after making the changes I saw in that commit you referred to the original hack is also not needed anymore! Thanks |
An issue that needs to be fixed with authorship before official integration is to account for authorship in the history module. Right now when you undo and redo edits with the history module, it does not account for authorship module class tags. Like if you undo 20 steps and the redo 20 steps, Quill will render all the edits under your authors username, instead of redoing the actual author that originally made the edit. Basically the history module needs to save authorship classes as well. I have moved this issue over to a new issue thread. |
Quill 2.0 has been released (announcement post) with many changes and fixes. If this is still an issue please create a new issue after reviewing our updated Contributing guide 🙏 |
Test with: