Skip to content

Enhancement/add link textbox - #106

Open
strendafilov wants to merge 7 commits into
mainfrom
enhancement/add-link-textbox
Open

Enhancement/add link textbox#106
strendafilov wants to merge 7 commits into
mainfrom
enhancement/add-link-textbox

Conversation

@strendafilov

Copy link
Copy Markdown
Collaborator

No description provided.

title="Link"
onClose={onClose}
cancel={{ text: 'Edit', onClick: () => onEdit() }}
extraTrailingButtons={

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the confirm button instead of a new trailing one? Or swap the remove and edit buttons

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue here is that I want the remove button to have a different style than the confirmation button. In case I swap them the remove button will be with primary color.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but we can pass it additional styling with the confirm={{ ... }} attribute

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes. Okay I will change it, but should I also remove the different positioning of the additional buttons, or leave it?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need them since the extra buttons were enough

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean yes, we should remove the different positioning and bring back the single extraButtons prop


const TRAILING_EMPTY_PARAGRAPHS_REGEX = /(<p>(\s|<br\s*\/?>)*<\/p>)+$/gi

interface LinkModalState {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw this interface twice, and some duplicated logic at places. Is there a way to remove the duplication?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there will be a way, but I can't come up with a scenario where I can devise a good abstraction.

@zmarinov-astea zmarinov-astea Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The easiest way to do it is to extract a hook useTextboxLink, which receives the editorAPI, and isEditMode, internally handles the LinkModalState and returns the modal UI as a single JSX variable, and also returns the addLink function. See client/src/components/item-picker/use-item-picker.tsx, should have similarities with it...

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