-
Notifications
You must be signed in to change notification settings - Fork 35
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
feat(core): support contenteditable inputs #959
feat(core): support contenteditable inputs #959
Conversation
@@ -0,0 +1,25 @@ | |||
import {ChangeDetectionStrategy, Component} from '@angular/core'; |
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 have zero experience in angular, so i just copied TextArea recipe page, and changed <textarea>
to <div contenteditable="true">
projects/core/src/lib/classes/adapters/content-editable-element.ts
Outdated
Show resolved
Hide resolved
@aktanoff Hello! Sorry for late response! |
@nsbarsukov, hi, could you please take a look at this PR? |
projects/core/src/lib/classes/adapters/content-editable-element.ts
Outdated
Show resolved
Hide resolved
projects/core/src/lib/classes/adapters/content-editable-element.ts
Outdated
Show resolved
Hide resolved
projects/core/src/lib/classes/adapters/content-editable-element.ts
Outdated
Show resolved
Hide resolved
projects/core/src/lib/classes/adapters/content-editable-element.ts
Outdated
Show resolved
Hide resolved
projects/core/src/lib/classes/adapters/content-editable-element.ts
Outdated
Show resolved
Hide resolved
projects/core/src/lib/classes/adapters/content-editable-element.ts
Outdated
Show resolved
Hide resolved
projects/core/src/lib/classes/adapters/content-editable-element.ts
Outdated
Show resolved
Hide resolved
projects/core/src/lib/classes/adapters/content-editable-element.ts
Outdated
Show resolved
Hide resolved
projects/core/src/lib/classes/adapters/content-editable-element.ts
Outdated
Show resolved
Hide resolved
projects/core/src/lib/classes/adapters/content-editable-element.ts
Outdated
Show resolved
Hide resolved
projects/core/src/lib/classes/adapters/content-editable-element.ts
Outdated
Show resolved
Hide resolved
a5b1cde
to
b7c6dbf
Compare
@nsbarsukov, Hello! Sorry for the long absence, i've fixed all your issues in this iteration. And also added multiline masks support, the easiest way to implement it been using I've also seen your draft, and copied some code from there. |
14f4da0
to
0467df4
Compare
// declared fields | ||
declare addEventListener: HTMLElement['addEventListener']; | ||
declare removeEventListener: HTMLElement['removeEventListener']; | ||
|
||
declare dispatchEvent: HTMLElement['dispatchEvent']; | ||
declare isContentEditable: HTMLElement['isContentEditable']; | ||
declare nodeName: HTMLElement['nodeName']; | ||
declare matches: HTMLElement['matches']; | ||
declare ownerDocument: HTMLElement['ownerDocument']; |
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.
Could we improve solution somehow and don't iterate all possible properties ?
Actually, plugins can use ANY possible property of HTMLElement
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.
Unfortunately, without fixing this problem we can't merge this solution.
Our users could write their own plugins and use ANY possible properties of HTMLElement
.
It will cause breaking change for them(
} | ||
|
||
get maxLength(): number { | ||
return -1; |
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.
return -1; | |
return Infinity; |
export interface MaskitoElement | ||
extends Pick< | ||
HTMLInputElement, | ||
| 'addEventListener' | ||
| 'dispatchEvent' | ||
| 'isContentEditable' | ||
| 'matches' | ||
| 'maxLength' | ||
| 'nodeName' | ||
| 'ownerDocument' | ||
| 'removeEventListener' | ||
| 'selectionEnd' | ||
| 'selectionStart' | ||
| 'setSelectionRange' | ||
| 'value' | ||
> {} |
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.
export type TextfieldLike = Pick<
HTMLInputElement,
'maxLength' | 'selectionEnd' | 'selectionStart' | 'setSelectionRange' | 'value'
>;
export type MaskitoElement = HTMLElement & TextfieldLike;
@@ -20,6 +20,7 @@ export const DemoPath = { | |||
Card: 'recipes/card', | |||
Phone: 'recipes/phone', | |||
Textarea: 'recipes/textarea', | |||
ContentEditable: 'recipes/contenteditable', |
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.
ContentEditable: 'recipes/contenteditable', | |
ContentEditable: 'recipes/content-editable', |
{ | ||
path: DemoPath.ContentEditable, | ||
loadComponent: () => | ||
import('../pages/recipes/contenteditable/contenteditable-doc.component'), |
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.
import('../pages/recipes/contenteditable/contenteditable-doc.component'), | |
import('../pages/recipes/content-editable/content-editable-doc.component'), |
Closing this PR in favor of #1039 |
Closes # #958