Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions components/typography/Base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface EditConfig {
tooltip?: boolean;
onStart?: () => void;
onChange?: (value: string) => void;
onSave?: (value: string) => void;
onCancel?: () => void;
onEnd?: () => void;
maxlength?: number;
Expand Down Expand Up @@ -219,6 +220,11 @@ const Base = defineComponent({
}

function onEditChange(value: string) {
const { onSave } = editable.value;
if (value !== props.content) {
emit('save', value);
onSave?.(value);
}
onContentChange(value);
triggerEdit(false);
}
Expand Down
6 changes: 4 additions & 2 deletions components/typography/demo/interactive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ title:
Provide additional interactive capacity of editable and copyable.
</docs>
<template>
<a-typography-paragraph v-model:content="editableStr" editable />
<a-typography-paragraph v-model:content="editableStr" :editable="{ onSave: saveText }" />
<a-typography-paragraph v-model:content="customIconStr" editable>
<template #editableIcon><HighlightOutlined /></template>
<template #editableTooltip>click to edit text</template>
Expand Down Expand Up @@ -85,7 +85,9 @@ watch(editableStr, () => {
console.log('editableStr', editableStr.value);
});
const chooseTrigger = ref<('icon' | 'text')[]>(['icon']);

const saveText = (value: string) => {
console.log('saveText', value);
};
const radioToState = (input: string): ('icon' | 'text')[] => {
switch (input) {
case 'text':
Expand Down
2 changes: 2 additions & 0 deletions components/typography/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Basic text writing, including headings, body text, lists, and more.
autoSize: boolean | { minRows: number, maxRows: number },
onStart: function,
onChange: function(string),
onSave: function(string),
onCancel: function,
onEnd: function,
triggerType: ('icon' | 'text')[],
Expand All @@ -118,6 +119,7 @@ Basic text writing, including headings, body text, lists, and more.
| triggerType | Edit mode trigger - icon, text or both (not specifying icon as trigger hides it) | Array&lt;`icon`\|`text`> | \[`icon`] | |
| onCancel | Called when type ESC to exit editable state | function | - | |
| onChange | Called when input at textarea | function(event) | - | |
| onSave | Called when exit editable state,Contains text fields that are converted back to text | function(event) | - | |
| onEnd | Called when type ENTER to exit editable state | function | - | |
| onStart | Called when enter editable state | function | - | |

Expand Down
2 changes: 2 additions & 0 deletions components/typography/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*LT2jR41Uj2EAAA
autoSize: boolean | { minRows: number, maxRows: number },
onStart: function,
onChange: function(string),
onSave: function(string),
onCancel: function,
onEnd: function,
triggerType: ('icon' | 'text')[],
Expand All @@ -119,6 +120,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*LT2jR41Uj2EAAA
| triggerType | 编辑模式触发器类型,图标、文本或者两者都设置(不设置图标作为触发器时它会隐藏) | Array&lt;`icon`\|`text`> | \[`icon`] | |
| onCancel | 按 ESC 退出编辑状态时触发 | function | - | |
| onChange | 文本域编辑时触发 | function(event) | - | |
| onSave | 文本域编辑结束时触发,包含文本域变回文字 | function(event) | - | |
| onEnd | 按 ENTER 结束编辑状态时触发 | function | - | |
| onStart | 进入编辑中状态时触发 | function | - | |

Expand Down