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

Add popup plugin #3128

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft

Add popup plugin #3128

wants to merge 9 commits into from

Conversation

john-traas
Copy link
Contributor

Copy link

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 = {
Copy link
Contributor

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 $.

Copy link
Contributor Author

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.

Copy link
Contributor

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 => {
Copy link
Contributor

@Kiarokh Kiarokh Aug 26, 2024

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.

Copy link
Contributor

@Kiarokh Kiarokh Aug 29, 2024

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? ;)

Copy link
Contributor Author

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) {
Copy link
Contributor

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 😊

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

Successfully merging this pull request may close these issues.

2 participants