Allow completion detail to accept a Node #13

Closed
nchen63 wants to merge 3 commits from nchen63-patch-1 into main
nchen63 commented 2022-09-09 19:46:10 +02:00 (Migrated from github.com)

Allows more complex styling of the text inside the completion detail.

Allows more complex styling of the text inside the completion detail.
marijnh commented 2022-09-12 08:41:36 +02:00 (Migrated from github.com)

What kind of styling are you planning to use this for? I'm somewhat weary of adding complex data structures like DOM nodes to completion objects, since when there are a lot of completions that could easily become a performance issue.

What kind of styling are you planning to use this for? I'm somewhat weary of adding complex data structures like DOM nodes to completion objects, since when there are a lot of completions that could easily become a performance issue.
nchen63 commented 2022-09-12 18:32:55 +02:00 (Migrated from github.com)

I’d like to add the type’s name with different colors for different types
and a short description in a different font. Since this is opt-in, we can
test for perf issues and it won’t affect other people who don’t use it. CM5
had the ability to do this, and having this allows us to migrate in a more
straightforward way.

On Sun, Sep 11, 2022 at 11:41 PM Marijn Haverbeke @.***>
wrote:

What kind of styling are you planning to use this for? I'm somewhat weary
of adding complex data structures like DOM nodes to completion objects,
since when there are a lot of completions that could easily become a
performance issue.


Reply to this email directly, view it on GitHub
https://github.com/codemirror/autocomplete/pull/13#issuecomment-1243286037,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACG263MMJ453UOIV7BQVXZTV53GCXANCNFSM6AAAAAAQI4C6QI
.
You are receiving this because you authored the thread.Message ID:
@.***>

I’d like to add the type’s name with different colors for different types and a short description in a different font. Since this is opt-in, we can test for perf issues and it won’t affect other people who don’t use it. CM5 had the ability to do this, and having this allows us to migrate in a more straightforward way. On Sun, Sep 11, 2022 at 11:41 PM Marijn Haverbeke ***@***.***> wrote: > What kind of styling are you planning to use this for? I'm somewhat weary > of adding complex data structures like DOM nodes to completion objects, > since when there are a lot of completions that could easily become a > performance issue. > > — > Reply to this email directly, view it on GitHub > <https://github.com/codemirror/autocomplete/pull/13#issuecomment-1243286037>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/ACG263MMJ453UOIV7BQVXZTV53GCXANCNFSM6AAAAAAQI4C6QI> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> >
marijnh commented 2022-09-13 14:42:44 +02:00 (Migrated from github.com)

optionClass can be used to add additional classes to the completion element based on its content (and thus to style the label and the detail text in a custom way). Would that help?

[`optionClass`](https://codemirror.net/docs/ref/#autocomplete.autocompletion^config.optionClass) can be used to add additional classes to the completion element based on its content (and thus to style the label and the detail text in a custom way). Would that help?
nchen63 commented 2022-09-13 17:50:39 +02:00 (Migrated from github.com)

It looks like this gives the ability to add a class for the whole
completion, but not the ability to have separate styles within the detail
text (in my case, the type name and description).

On Tue, Sep 13, 2022 at 5:42 AM Marijn Haverbeke @.***>
wrote:

optionClass
https://codemirror.net/docs/ref/#autocomplete.autocompletion%5Econfig.optionClass
can be used to add additional classes to the completion element based on
its content (and thus to style the label and the detail text in a custom
way). Would that help?


Reply to this email directly, view it on GitHub
https://github.com/codemirror/autocomplete/pull/13#issuecomment-1245358318,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACG263MYKUNFT22GME7X2KDV6BZE5ANCNFSM6AAAAAAQI4C6QI
.
You are receiving this because you authored the thread.Message ID:
@.***>

It looks like this gives the ability to add a class for the whole completion, but not the ability to have separate styles within the detail text (in my case, the type name and description). On Tue, Sep 13, 2022 at 5:42 AM Marijn Haverbeke ***@***.***> wrote: > optionClass > <https://codemirror.net/docs/ref/#autocomplete.autocompletion%5Econfig.optionClass> > can be used to add additional classes to the completion element based on > its content (and thus to style the label and the detail text in a custom > way). Would that help? > > — > Reply to this email directly, view it on GitHub > <https://github.com/codemirror/autocomplete/pull/13#issuecomment-1245358318>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/ACG263MYKUNFT22GME7X2KDV6BZE5ANCNFSM6AAAAAAQI4C6QI> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> >
marijnh commented 2022-09-13 20:37:39 +02:00 (Migrated from github.com)

Right, but those already have other classes (cm-completionLabel and cm-completionInfo) that you can target with a scoped rule, no?

Right, but those already have other classes (`cm-completionLabel` and `cm-completionInfo`) that you can target with a scoped rule, no?
nchen63 commented 2022-09-14 02:08:49 +02:00 (Migrated from github.com)

Here's some examples of what I would like to do, which I can't do by using the other classes:

image

image

Here's some examples of what I would like to do, which I can't do by using the other classes: ![image](https://user-images.githubusercontent.com/9285485/190030569-bd5e6450-2fe2-44a6-b628-c5fe84a7e295.png) ![image](https://user-images.githubusercontent.com/9285485/190030677-6065040b-14d7-4add-8f85-28e56f4f306f.png)
marijnh commented 2022-09-14 06:52:56 +02:00 (Migrated from github.com)

I see. addToOptions is what you want there, I think. Add a new element to options that is rendered based on some extra information you put in the completion object.

I see. [`addToOptions`](https://codemirror.net/docs/ref/#autocomplete.autocompletion^config.addToOptions) is what you want there, I think. Add a new element to options that is rendered based on some extra information you put in the completion object.
nchen63 commented 2022-09-14 18:56:45 +02:00 (Migrated from github.com)

Looks like this is what I need. Thanks.

On Tue, Sep 13, 2022 at 9:53 PM Marijn Haverbeke @.***>
wrote:

I see. addToOptions
https://codemirror.net/docs/ref/#autocomplete.autocompletion%5Econfig.addToOptions
is what you want there, I think. Add a new element to options that is
rendered based on some extra information you put in the completion object.


Reply to this email directly, view it on GitHub
https://github.com/codemirror/autocomplete/pull/13#issuecomment-1246231245,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACG263NBSGU6EV3XX5FFQUTV6FK3HANCNFSM6AAAAAAQI4C6QI
.
You are receiving this because you authored the thread.Message ID:
@.***>

Looks like this is what I need. Thanks. On Tue, Sep 13, 2022 at 9:53 PM Marijn Haverbeke ***@***.***> wrote: > I see. addToOptions > <https://codemirror.net/docs/ref/#autocomplete.autocompletion%5Econfig.addToOptions> > is what you want there, I think. Add a new element to options that is > rendered based on some extra information you put in the completion object. > > — > Reply to this email directly, view it on GitHub > <https://github.com/codemirror/autocomplete/pull/13#issuecomment-1246231245>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/ACG263NBSGU6EV3XX5FFQUTV6FK3HANCNFSM6AAAAAAQI4C6QI> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> >

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/autocomplete!13
No description provided.