This commit is contained in:
Martin Kleinschrodt 2022-07-18 08:22:29 +02:00
parent 30f75294b0
commit 1c1085247f
2 changed files with 35 additions and 13 deletions

View File

@ -305,6 +305,16 @@ export class FieldElement extends LitElement {
private _renderEditValue() {
switch (this.field.type) {
case "text":
return html`
<pl-textarea
class="value-input"
autosize
.value=${this.field.value}
@input=${() => (this.field.value = this._valueInput.value)}
></pl-textarea>
`;
case "note":
return html`
<pl-rich-input

View File

@ -179,6 +179,17 @@ export const FIELD_DEFS: { [t in FieldType]: FieldDef } = {
return masked ? value.replace(/./g, "\u2022") : value;
},
},
[FieldType.Text]: {
type: FieldType.Text,
pattern: /.*/,
matchPattern: /.*/,
mask: false,
multiline: true,
icon: "text",
get name() {
return $l("Plain Text");
},
},
[FieldType.Note]: {
type: FieldType.Note,
pattern: /.*/,
@ -187,23 +198,12 @@ export const FIELD_DEFS: { [t in FieldType]: FieldDef } = {
multiline: true,
icon: "note",
get name() {
return $l("Note");
return $l("Richtext / Markdown");
},
format(value: string) {
return value.split("\n")[0] || "";
},
},
[FieldType.Text]: {
type: FieldType.Text,
pattern: /.*/,
matchPattern: /.*/,
mask: false,
multiline: false,
icon: "text",
get name() {
return $l("Other");
},
},
[FieldType.Totp]: {
type: FieldType.Totp,
pattern: /^([A-Z2-7=]{8})+$/i,
@ -212,7 +212,7 @@ export const FIELD_DEFS: { [t in FieldType]: FieldDef } = {
multiline: false,
icon: "totp",
get name() {
return $l("Authenticator");
return $l("2FA Code");
},
async transform(value: string) {
return await totp(base32ToBytes(value));
@ -572,6 +572,18 @@ export const ITEM_TEMPLATES: ItemTemplate[] = [
},
],
},
{
toString: () => $l("Authenticator"),
icon: "totp",
fields: [
{
get name() {
return $l("2FA Code");
},
type: FieldType.Totp,
},
],
},
{
toString: () => $l("Document"),
icon: "attachment",