Skip to content

Commit

Permalink
fix(text-editor): move delegate logic to prosemirror adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
LucyChyzhova authored and civing committed Dec 2, 2024
1 parent 5050f3d commit 4d845bc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions etc/lime-elements.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ export namespace Components {
"contentType": 'markdown' | 'html';
// @alpha
"customElements": CustomElementDefinition[];
"disabled"?: boolean;
"language": Languages;
// @alpha
"triggerCharacters": TriggerCharacter[];
Expand Down Expand Up @@ -1631,6 +1632,7 @@ namespace JSX_2 {
"contentType"?: 'markdown' | 'html';
// @alpha
"customElements"?: CustomElementDefinition[];
"disabled"?: boolean;
"language"?: Languages;
"onChange"?: (event: LimelProsemirrorAdapterCustomEvent<string>) => void;
// @alpha
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ export class ProsemirrorAdapter {
@Prop({ reflect: true })
public language: Languages;

/**
* Set to `true` to disable the field.
* Use `disabled` to indicate that the field can normally be interacted
* with, but is currently disabled. This tells the user that if certain
* requirements are met, the field may become enabled again.
*/
@Prop({ reflect: true })
public disabled?: boolean = false;

/**
* set to private to avoid usage while under development
*
Expand Down Expand Up @@ -456,7 +465,9 @@ export class ProsemirrorAdapter {
};

private handleFocus = () => {
this.view?.focus();
if (!this.disabled) {
this.view?.focus();
}
};

private handleNewLinkSelection = (text: string, href: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/text-editor/text-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ export class TextEditor implements FormComponent<string> {
value={this.value}
aria-controls={this.helperTextId}
id={this.editorId}
tabindex={this.disabled ? -1 : 0}
aria-disabled={this.disabled}
language={this.language}
triggerCharacters={this.triggers}
disabled={this.disabled}
/>,
this.renderPlaceholder(),
this.renderHelperLine(),
Expand Down

0 comments on commit 4d845bc

Please sign in to comment.