tiptapify 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ import '@tiptap/extension-invisible-characters'
|
|
|
62
62
|
|
|
63
63
|
import Tiptapify from './src/components/Tiptapify.vue'
|
|
64
64
|
import TiptapifyDialog from './src/components/UI/TiptapifyDialog.vue'
|
|
65
|
+
import { TIPTAPIFY_CONFIG_KEY, useTiptapifyConfig, TiptapifyConfig } from './src/composables/useTiptapifyConfig'
|
|
65
66
|
import * as mdi from '@mdi/js'
|
|
66
67
|
|
|
67
68
|
export type TiptapifyFooterAlignment = 'start' | 'center' | 'end'
|
|
@@ -188,6 +189,8 @@ export {
|
|
|
188
189
|
mdi,
|
|
189
190
|
Tiptapify,
|
|
190
191
|
TiptapifyDialog,
|
|
192
|
+
TIPTAPIFY_CONFIG_KEY,
|
|
193
|
+
useTiptapifyConfig,
|
|
191
194
|
TiptapEditor,
|
|
192
195
|
nodeViewProps,
|
|
193
196
|
NodeViewWrapper,
|
|
@@ -225,6 +228,8 @@ export type {
|
|
|
225
228
|
SingleCommands,
|
|
226
229
|
}
|
|
227
230
|
|
|
231
|
+
export type { TiptapifyConfig }
|
|
232
|
+
|
|
228
233
|
declare module '@vue/runtime-core' {
|
|
229
234
|
interface GlobalComponents {
|
|
230
235
|
Tiptapify: typeof Tiptapify
|
package/package.json
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { createSSRApp, h, provide, ref } from 'vue'
|
|
3
|
+
import { renderToString } from 'vue/server-renderer'
|
|
4
|
+
import { createVuetify } from 'vuetify'
|
|
5
|
+
import Items from '@tiptapify/components/Toolbar/Items.vue'
|
|
6
|
+
import HeadingButton from '@tiptapify/extensions/components/style/heading/Button.vue'
|
|
7
|
+
|
|
8
|
+
const editor = {
|
|
9
|
+
instanceId: 1,
|
|
10
|
+
isActive: () => false,
|
|
11
|
+
can: () => ({ chain: () => ({ focus: () => ({ toggleHeading: () => ({ run: () => false }) }) }) }),
|
|
12
|
+
chain: () => ({ focus: () => ({ redo: () => ({ run: () => false }) }) }),
|
|
13
|
+
commands: {},
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const items = [
|
|
17
|
+
{
|
|
18
|
+
section: 'style',
|
|
19
|
+
group: true,
|
|
20
|
+
components: [{ name: 'heading', component: HeadingButton }],
|
|
21
|
+
},
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
async function renderToolbar () {
|
|
25
|
+
const warnings: string[] = []
|
|
26
|
+
const warn = vi.spyOn(console, 'warn').mockImplementation((...args: unknown[]) => {
|
|
27
|
+
warnings.push(args.map(String).join(' '))
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const app = createSSRApp({
|
|
31
|
+
setup () {
|
|
32
|
+
provide('tiptapifyEditor', ref(editor))
|
|
33
|
+
provide('tiptapifyI18n', { t: (key: string) => key })
|
|
34
|
+
|
|
35
|
+
return () => h(Items, { items })
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
app.use(createVuetify())
|
|
39
|
+
|
|
40
|
+
const html = await renderToString(app)
|
|
41
|
+
warn.mockRestore()
|
|
42
|
+
|
|
43
|
+
return { html, warnings }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('Toolbar Items', () => {
|
|
47
|
+
it('does not pass undeclared attributes to toolbar buttons', async () => {
|
|
48
|
+
const { html, warnings } = await renderToolbar()
|
|
49
|
+
|
|
50
|
+
expect(html).toContain('tiptapify-heading-button-1')
|
|
51
|
+
expect(warnings.join('\n')).not.toContain('Extraneous non-props attributes')
|
|
52
|
+
})
|
|
53
|
+
})
|
|
@@ -22,7 +22,7 @@ const { variantBtn } = useTiptapifyConfig()
|
|
|
22
22
|
<template v-else>
|
|
23
23
|
<VBtnGroup v-if="item.group" elevation="4" :class="{ 'tiptapify-btn-group--elevated': variantBtn === 'elevated' }">
|
|
24
24
|
<template v-for="sectionItem in item.components" :key="sectionItem.name">
|
|
25
|
-
<component :is="sectionItem.component" v-bind="
|
|
25
|
+
<component :is="sectionItem.component" v-bind="sectionItem.props ?? {}" />
|
|
26
26
|
</template>
|
|
27
27
|
</VBtnGroup>
|
|
28
28
|
<template v-else>
|
|
@@ -30,7 +30,7 @@ const { variantBtn } = useTiptapifyConfig()
|
|
|
30
30
|
:is="sectionItem.component"
|
|
31
31
|
v-for="sectionItem in item.components"
|
|
32
32
|
:key="sectionItem.name"
|
|
33
|
-
v-bind="
|
|
33
|
+
v-bind="sectionItem.props ?? {}"
|
|
34
34
|
/>
|
|
35
35
|
</template>
|
|
36
36
|
<div class="menu-divider" />
|