You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

import { ref, nextTick } from 'vue';
import '../../utils/index.mjs';
import { isKorean } from '../../utils/i18n.mjs';
function useComposition({
afterComposition,
emit
}) {
const isComposing = ref(false);
const handleCompositionStart = (event) => {
emit == null ? void 0 : emit("compositionstart", event);
isComposing.value = true;
};
const handleCompositionUpdate = (event) => {
var _a;
emit == null ? void 0 : emit("compositionupdate", event);
const text = (_a = event.target) == null ? void 0 : _a.value;
const lastCharacter = text[text.length - 1] || "";
isComposing.value = !isKorean(lastCharacter);
};
const handleCompositionEnd = (event) => {
emit == null ? void 0 : emit("compositionend", event);
if (isComposing.value) {
isComposing.value = false;
nextTick(() => afterComposition(event));
}
};
const handleComposition = (event) => {
event.type === "compositionend" ? handleCompositionEnd(event) : handleCompositionUpdate(event);
};
return {
isComposing,
handleComposition,
handleCompositionStart,
handleCompositionUpdate,
handleCompositionEnd
};
}
export { useComposition };
//# sourceMappingURL=index.mjs.map