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.

44 lines
1.2 KiB

1 month ago
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var i18n = require('../../utils/i18n.js');
  5. function useComposition({
  6. afterComposition,
  7. emit
  8. }) {
  9. const isComposing = vue.ref(false);
  10. const handleCompositionStart = (event) => {
  11. emit == null ? void 0 : emit("compositionstart", event);
  12. isComposing.value = true;
  13. };
  14. const handleCompositionUpdate = (event) => {
  15. var _a;
  16. emit == null ? void 0 : emit("compositionupdate", event);
  17. const text = (_a = event.target) == null ? void 0 : _a.value;
  18. const lastCharacter = text[text.length - 1] || "";
  19. isComposing.value = !i18n.isKorean(lastCharacter);
  20. };
  21. const handleCompositionEnd = (event) => {
  22. emit == null ? void 0 : emit("compositionend", event);
  23. if (isComposing.value) {
  24. isComposing.value = false;
  25. vue.nextTick(() => afterComposition(event));
  26. }
  27. };
  28. const handleComposition = (event) => {
  29. event.type === "compositionend" ? handleCompositionEnd(event) : handleCompositionUpdate(event);
  30. };
  31. return {
  32. isComposing,
  33. handleComposition,
  34. handleCompositionStart,
  35. handleCompositionUpdate,
  36. handleCompositionEnd
  37. };
  38. }
  39. exports.useComposition = useComposition;
  40. //# sourceMappingURL=index.js.map