-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add popup plugin #3128
base: main
Are you sure you want to change the base?
Add popup plugin #3128
Conversation
f20bfee
to
41035ce
Compare
Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-3128/ |
@@ -0,0 +1,35 @@ | |||
import { NodeSpec } from 'prosemirror-model'; | |||
|
|||
export const mention: NodeSpec = { |
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.
I wonder if we should call this thing "mention" already? Or if we should be more generic and design the feature in a way that the consumer can provide limel-text-editor
with a list of items, which will be then shown if @
is entered as an input?
Having "mentions" implemented in a text-editor is not an unusual feature. And probably approaching this feature as "mention" is an easy and straightforward way for going forward. But I'm just thinking about other forms of hotkeys (or short command triggers) such as /
or #
or perhaps custom characters defined by the consumer like $
.
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.
Many aspects of this will be agnostic and generic. However for NodeSpec's they will have to be unique and specific to what they hold.
If we're traversing the Editor State the current Node or group of Nodes needs to tell us exactly what it or they are. So for tags we would create a separate NodeSpec to specify tags.
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.
Not sure if I entirely understand the technical aspects that you mentioned. But what I was trying to say is, should this @-ing or #-ing be called "mentioning" and "tagging"? Or can we find more generic names and functionality-agnostic designs for them, such as at-command
, hashtag-command
etc…
If we call it "mention" and create an entire set of user interactions and components for handling mentions (picking a person from a searchable list while typing a piece of text), our work will be easy and straightforward. The consumer's expectations will also be straightforward. They will only use the @
trigger to implement mentions, where they use the text editor component.
However, in another context for other consumers, the @-ing may be used to link things together maybe… Or to add locations, or dates or whatever the 3rd-party consumers' use-case may be.
Maybe I'm over complicating… but this was just a question that poped in my head.
return triggers.includes(key as Trigger); | ||
}; | ||
|
||
const shouldTrigger = (state: EditorState): boolean => { |
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.
these short command trigger should also work if the previous character is a line-break. So when @
or #
are the first letters of a new paragraph.
Also, they should work when they are the first letter within the text, and there is nothing at all before them.
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.
seems they already do that, right? ;)
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.
Not yet, this comment will hopefully remind me to add that. 😄
|
||
const prevPos = $from.pos - 1; | ||
|
||
if (!prevPos) { |
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.
I think we generally try to avoid abbreviations. So maybe reconsider pos
or char
or prev
and such 😊
98d5d6b
to
0c32b7c
Compare
Fixes https://github.com/Lundalogik/crm-feature/issues/4301