Skip to content

Commit

Permalink
fix: prefix for components, lowlight import
Browse files Browse the repository at this point in the history
  • Loading branch information
modbender committed Dec 8, 2023
1 parent 80afa71 commit a4f735e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Instantly add [TipTap Editor](https://tiptap.dev/editor) with basic functionalit
## Features

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

## Quick Setup

Expand Down Expand Up @@ -176,7 +176,7 @@ Instantly add [TipTap Editor](https://tiptap.dev/editor) with basic functionalit
redo
</button>
</div>
<EditorContent :editor="editor" />
<TiptapEditorContent :editor="editor" />
</div>
</template>

Expand Down
7 changes: 2 additions & 5 deletions src/imports/optional.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
export const lowlightImports = [
{ name: "lowlight ", path: "lowlight" },
{ name: "CodeBlock", path: "@tiptap/extension-code-block" },
];

export const optionalImports: {[key: string]: any}[] = [];
export const optionalComponents: {[key: string]: any}[] = [];
{ name: "CodeBlockLowlight", path: "@tiptap/extension-code-block-lowlight" },
];
21 changes: 9 additions & 12 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,11 @@ export interface ModuleOptions {
lowlight?:
| boolean
| {
/**
* Determine if lowlight should be enabled
*
* @default false
*/
enabled: boolean;
/**
* Languages to be loaded for highlighting
*
*/
languages: string[];
// languages: string[];
};
}

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

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

var optionalImports: { [key: string]: any }[] = [];
var optionalComponents: { [key: string]: any }[] = [];

// Do not add the extension since the `.ts` will be transpiled to `.mjs` after `npm run prepack`
for (const obj of allImports.defaultComposables) {
addImports({
Expand All @@ -78,21 +75,21 @@ export default defineNuxtModule<ModuleOptions>({
for (const obj of allImports.defaultComponents) {
addComponent({
mode: "client",
name: obj.name,
name: `${options.prefix}${obj.name}`,
export: obj.name,
filePath: obj.path,
// _internal_install: obj.path,
});
transpileModules.add(obj.path);
}

if (options.lowlight === false) {
allImports.optionalImports.push(...allImports.lowlightImports);
if (!!options.lowlight && options.lowlight !== false) {
optionalImports = [...optionalImports, ...allImports.lowlightImports];
}

for (const obj of allImports.optionalImports) {
for (const obj of optionalImports) {
addImports({
as: obj.name,
as: `${options.prefix}${obj.name}`,
name: obj.name,
from: obj.path,
// _internal_install: obj.path,
Expand Down

0 comments on commit a4f735e

Please sign in to comment.