pull/8385/merge
lijh 2025-11-18 09:29:21 +08:00 committed by GitHub
commit 6d5b5c2826
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 2 deletions

View File

@ -49,6 +49,7 @@ export interface EditConfig {
tooltip?: boolean; tooltip?: boolean;
onStart?: () => void; onStart?: () => void;
onChange?: (value: string) => void; onChange?: (value: string) => void;
onSave?: (value: string) => void;
onCancel?: () => void; onCancel?: () => void;
onEnd?: () => void; onEnd?: () => void;
maxlength?: number; maxlength?: number;
@ -219,6 +220,11 @@ const Base = defineComponent({
} }
function onEditChange(value: string) { function onEditChange(value: string) {
const { onSave } = editable.value;
if (value !== props.content) {
emit('save', value);
onSave?.(value);
}
onContentChange(value); onContentChange(value);
triggerEdit(false); triggerEdit(false);
} }

View File

@ -15,7 +15,7 @@ title:
Provide additional interactive capacity of editable and copyable. Provide additional interactive capacity of editable and copyable.
</docs> </docs>
<template> <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> <a-typography-paragraph v-model:content="customIconStr" editable>
<template #editableIcon><HighlightOutlined /></template> <template #editableIcon><HighlightOutlined /></template>
<template #editableTooltip>click to edit text</template> <template #editableTooltip>click to edit text</template>
@ -85,7 +85,9 @@ watch(editableStr, () => {
console.log('editableStr', editableStr.value); console.log('editableStr', editableStr.value);
}); });
const chooseTrigger = ref<('icon' | 'text')[]>(['icon']); const chooseTrigger = ref<('icon' | 'text')[]>(['icon']);
const saveText = (value: string) => {
console.log('saveText', value);
};
const radioToState = (input: string): ('icon' | 'text')[] => { const radioToState = (input: string): ('icon' | 'text')[] => {
switch (input) { switch (input) {
case 'text': case 'text':

View File

@ -103,6 +103,7 @@ Basic text writing, including headings, body text, lists, and more.
autoSize: boolean | { minRows: number, maxRows: number }, autoSize: boolean | { minRows: number, maxRows: number },
onStart: function, onStart: function,
onChange: function(string), onChange: function(string),
onSave: function(string),
onCancel: function, onCancel: function,
onEnd: function, onEnd: function,
triggerType: ('icon' | 'text')[], triggerType: ('icon' | 'text')[],
@ -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`] | | | 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 | - | | | onCancel | Called when type ESC to exit editable state | function | - | |
| onChange | Called when input at textarea | function(event) | - | | | onChange | Called when input at textarea | function(event) | - | |
| onSave | Called when exit editable stateContains text fields that are converted back to text | function(event) | - | |
| onEnd | Called when type ENTER to exit editable state | function | - | | | onEnd | Called when type ENTER to exit editable state | function | - | |
| onStart | Called when enter editable state | function | - | | | onStart | Called when enter editable state | function | - | |

View File

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