Skip to content

Commit

Permalink
feat: add hook to html parser
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdmlln committed Apr 18, 2024
1 parent b15ad39 commit 877a867
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ export default defineNuxtModule<ModuleOptions>({
)

nuxt.hook('prepare:types', (options) => {
options.references.push({
path: resolver.resolve('runtime/types/nuxt.d.ts'),
})
options.references.push(
{
path: resolver.resolve('runtime/types/hooks.d.ts'),
},
{
path: resolver.resolve('runtime/types/schema.d.ts'),
},
)
})

options = nuxt.options.runtimeConfig.public[CONFIG_KEY]
Expand Down
4 changes: 3 additions & 1 deletion src/runtime/components/ui/T3HtmlParser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<script setup lang="ts">
import { computed, ref } from 'vue'
import { useT3LinkReplacer, useT3TableEnhancer } from '#imports'
import { useNuxtApp, useT3LinkReplacer, useT3TableEnhancer } from '#imports'

const props = defineProps<{
content: string
Expand All @@ -22,6 +22,8 @@ const content = computed(() => props.content)

useT3TableEnhancer(el, content)
useT3LinkReplacer(el, content)

useNuxtApp().callHook('typo3:parseHtml', el, content)
</script>

<style lang="scss">
Expand Down
13 changes: 13 additions & 0 deletions src/runtime/types/hooks.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { HookResult } from '@nuxt/schema'
import { type Ref } from 'vue'

declare module '#app' {
interface RuntimeNuxtHooks {
'typo3:parseHtml': (
el: Ref<HTMLDivElement | undefined>,
content: Ref<string>,
) => HookResult
}
}

export {}
File renamed without changes.

0 comments on commit 877a867

Please sign in to comment.