feat: Added support maskInputFn with HTMLElement (#1188)
This commit is contained in:
@@ -685,6 +685,7 @@ function serializeElementNode(
|
||||
) {
|
||||
const type = getInputType(n);
|
||||
attributes.value = maskInputValue({
|
||||
element: n,
|
||||
type,
|
||||
tagName,
|
||||
value,
|
||||
|
||||
@@ -154,7 +154,7 @@ export type DataURLOptions = Partial<{
|
||||
}>;
|
||||
|
||||
export type MaskTextFn = (text: string) => string;
|
||||
export type MaskInputFn = (text: string) => string;
|
||||
export type MaskInputFn = (text: string, element: HTMLElement) => string;
|
||||
|
||||
export type KeepIframeSrcFn = (src: string) => boolean;
|
||||
|
||||
|
||||
@@ -154,12 +154,14 @@ export function createMirror(): Mirror {
|
||||
}
|
||||
|
||||
export function maskInputValue({
|
||||
element,
|
||||
maskInputOptions,
|
||||
tagName,
|
||||
type,
|
||||
value,
|
||||
maskInputFn,
|
||||
}: {
|
||||
element: HTMLElement;
|
||||
maskInputOptions: MaskInputOptions;
|
||||
tagName: string;
|
||||
type: string | null;
|
||||
@@ -174,7 +176,7 @@ export function maskInputValue({
|
||||
(actualType && maskInputOptions[actualType as keyof MaskInputOptions])
|
||||
) {
|
||||
if (maskInputFn) {
|
||||
text = maskInputFn(text);
|
||||
text = maskInputFn(text, element);
|
||||
} else {
|
||||
text = '*'.repeat(text.length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user