Skip to content

Commit

Permalink
edittheme
Browse files Browse the repository at this point in the history
  • Loading branch information
Nattuki committed Dec 4, 2023
2 parents 09f3ab9 + 4c3688d commit e585c73
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
9 changes: 6 additions & 3 deletions build/gen-mplus.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,14 @@ const getUrlFromSrc = src => {
}

const generateFilename = font => {
const i = getUrlFromSrc(font.src).match(/\/v\d+\/[^.]+\.(\d+)\.woff2/)
if (!i) throw new Error(`Unexpected: ${getUrlFromSrc(font.src)}`)
const family = font['font-family'].replace(/[' ]/g, '')
const weight = font['font-weight'].replace(/[' ]/g, '')
return `${family}.${weight}.${i[1]}.woff2`

const fontSrcWithId = getUrlFromSrc(font.src).match(/\/v\d+\/([^/]+)\.woff2/)
if (!fontSrcWithId) {
throw new Error(`Unexpected URL: ${getUrlFromSrc(font.src)}`)
}
return `${family}.${weight}.${fontSrcWithId[1]}.woff2`
}

const downloadAndtransform = async (url, filename) => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/ShareTarget/ShareTargetMessageInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<textarea
:id="id"
ref="textareaRef"
v-model="state.text"
:class="$style.input"
:value="state.text"
@input="event => state.text = (event.target as HTMLTextAreaElement).value"
/>
</div>
<div :class="$style.controls">
Expand Down
32 changes: 27 additions & 5 deletions src/components/UI/ClickOutside.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
cloneVNode,
shallowRef,
onMounted,
onBeforeUnmount
onBeforeUnmount,
ref
} from 'vue'
import { isIOS } from '/@/lib/dom/browser'
import { useModalStore } from '/@/store/ui/modal'
Expand All @@ -23,7 +24,8 @@ const filterChildren = <T extends VNode>(vnodes: T[]) =>
return true
})

const eventName = isIOS() ? 'touchend' : 'click'
const startEventName = isIOS() ? 'touchstart' : 'mousedown'
const endEventName = isIOS() ? 'touchend' : 'mouseup'

/**
* そのデフォルトスロットに指定した要素の外でクリックされたときにclickOutsideイベントを発火する
Expand Down Expand Up @@ -51,8 +53,9 @@ export default defineComponent({
const element = shallowRef<Element | ComponentPublicInstance>()

const { shouldShowModal } = useModalStore()
const isMouseDown = ref(false)

const onClick = (e: MouseEvent | TouchEvent) => {
const onMouseDown = (e: MouseEvent | TouchEvent) => {
if (!element.value) return

if (props.unableWhileModalOpen && shouldShowModal.value) return
Expand All @@ -64,17 +67,36 @@ export default defineComponent({
return
}

isMouseDown.value = true
if (props.stop) {
e.stopPropagation()
}
}
const onMouseUp = (e: MouseEvent | TouchEvent) => {
if (!isMouseDown.value) return
isMouseDown.value = false

if (!element.value) return
const ele =
element.value instanceof Element ? element.value : element.value.$el

if (ele === e.target || e.composedPath().includes(ele)) {
return
}

emit('clickOutside', e)
if (props.stop) {
e.stopPropagation()
}
}

onMounted(() => {
window.addEventListener(eventName, onClick, { capture: true })
window.addEventListener(startEventName, onMouseDown, { capture: true })
window.addEventListener(endEventName, onMouseUp, { capture: true })
})
onBeforeUnmount(() => {
window.removeEventListener(eventName, onClick, { capture: true })
window.removeEventListener(startEventName, onMouseDown, { capture: true })
window.removeEventListener(endEventName, onMouseUp, { capture: true })
})

return () => {
Expand Down

0 comments on commit e585c73

Please sign in to comment.