Skip to content

Commit a4f735e

Browse files
committed
fix: prefix for components, lowlight import
1 parent 80afa71 commit a4f735e

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Instantly add [TipTap Editor](https://tiptap.dev/editor) with basic functionalit
2323
## Features
2424

2525
- 🔆Easy to integrate
26-
- ⚡️Instantly usable components
26+
- ⚡️Instantly usable components provided by `@tiptap`.
2727

2828
## Quick Setup
2929

@@ -176,7 +176,7 @@ Instantly add [TipTap Editor](https://tiptap.dev/editor) with basic functionalit
176176
redo
177177
</button>
178178
</div>
179-
<EditorContent :editor="editor" />
179+
<TiptapEditorContent :editor="editor" />
180180
</div>
181181
</template>
182182

src/imports/optional.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
export const lowlightImports = [
22
{ name: "lowlight ", path: "lowlight" },
3-
{ name: "CodeBlock", path: "@tiptap/extension-code-block" },
4-
];
5-
6-
export const optionalImports: {[key: string]: any}[] = [];
7-
export const optionalComponents: {[key: string]: any}[] = [];
3+
{ name: "CodeBlockLowlight", path: "@tiptap/extension-code-block-lowlight" },
4+
];

src/module.ts

+9-12
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,11 @@ export interface ModuleOptions {
2121
lowlight?:
2222
| boolean
2323
| {
24-
/**
25-
* Determine if lowlight should be enabled
26-
*
27-
* @default false
28-
*/
29-
enabled: boolean;
3024
/**
3125
* Languages to be loaded for highlighting
3226
*
3327
*/
34-
languages: string[];
28+
// languages: string[];
3529
};
3630
}
3731

@@ -54,6 +48,9 @@ export default defineNuxtModule<ModuleOptions>({
5448

5549
const transpileModules = new Set<string>([]);
5650

51+
var optionalImports: { [key: string]: any }[] = [];
52+
var optionalComponents: { [key: string]: any }[] = [];
53+
5754
// Do not add the extension since the `.ts` will be transpiled to `.mjs` after `npm run prepack`
5855
for (const obj of allImports.defaultComposables) {
5956
addImports({
@@ -78,21 +75,21 @@ export default defineNuxtModule<ModuleOptions>({
7875
for (const obj of allImports.defaultComponents) {
7976
addComponent({
8077
mode: "client",
81-
name: obj.name,
78+
name: `${options.prefix}${obj.name}`,
8279
export: obj.name,
8380
filePath: obj.path,
8481
// _internal_install: obj.path,
8582
});
8683
transpileModules.add(obj.path);
8784
}
8885

89-
if (options.lowlight === false) {
90-
allImports.optionalImports.push(...allImports.lowlightImports);
86+
if (!!options.lowlight && options.lowlight !== false) {
87+
optionalImports = [...optionalImports, ...allImports.lowlightImports];
9188
}
9289

93-
for (const obj of allImports.optionalImports) {
90+
for (const obj of optionalImports) {
9491
addImports({
95-
as: obj.name,
92+
as: `${options.prefix}${obj.name}`,
9693
name: obj.name,
9794
from: obj.path,
9895
// _internal_install: obj.path,

0 commit comments

Comments
 (0)