Skip to content

Commit

Permalink
Merge pull request #16 from motea927/dev
Browse files Browse the repository at this point in the history
fix: fix plugins dts error
  • Loading branch information
motea927 authored Jun 17, 2023
2 parents 930c39f + 2ec13c8 commit 32a2cfa
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 23 deletions.
7 changes: 7 additions & 0 deletions packages/core/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { BindingObj, BindingI18nObj } from './shared'
declare module '@vue/runtime-core' {
export interface ComponentCustomProperties {
$i18nHtml: (binding: string | BindingI18nObj) => string
$safeHtml: (binding: string | BindingObj) => string
}
}
8 changes: 0 additions & 8 deletions packages/core/plugins.d.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/core/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { App } from 'vue'
import { useI18n } from 'vue-i18n'
import type { Options, BindingObj } from './shared'
import type { Options, BindingObj, BindingI18nObj } from './shared'
import {
setGlobalOptions,
getBindingValue,
Expand All @@ -10,7 +10,7 @@ import {
} from './shared'

const generateHtml =
(getContentText: (binding: string | BindingObj) => string) =>
(getContentText: (binding: string | BindingObj | BindingI18nObj) => string) =>
(binding: string | BindingObj): string => {
if (!binding) return ''

Expand Down
4 changes: 4 additions & 0 deletions packages/core/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export type BindingObj = {
htmlString: string | (() => string)
} & Options

export type BindingI18nObj = Omit<BindingObj, 'htmlString'> & {
htmlString: string
}

const globalOptions = ref<Options | undefined>()

export function getDefaultString(
Expand Down
1 change: 1 addition & 0 deletions playgrounds/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<div>
<h2>i18n</h2>
<p v-html="$safeHtml(`<p style='color: red;'>123</p>`)"></p>
<p v-html="$t('message')"></p>
<button @click="handleClickChangeMessage">change message</button>
</div>
</div>
Expand Down
11 changes: 0 additions & 11 deletions plugins/i18n-html.ts

This file was deleted.

4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export default defineConfig({
plugins: [
vue(),
dts({
include: ['packages/**/*.ts'],
include: ['packages/core/*.ts'],
insertTypesEntry: true,
copyDtsFiles: false,
copyDtsFiles: true,
tsConfigFilePath: './tsconfig.app.json'
})
],
Expand Down

0 comments on commit 32a2cfa

Please sign in to comment.