Skip to content

Commit

Permalink
feat: build v-editor component
Browse files Browse the repository at this point in the history
  • Loading branch information
gravitano committed Apr 4, 2022
1 parent 158cf73 commit 6815a02
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/editor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
44 changes: 44 additions & 0 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# GITS Editor Component

> Based on Vue 3 CKEditor
## Installation

via npm

```
npm i @gits-id/editor
```

via yarn

```
yarn add @gits-id/editor
```

via pnpm

```
pnpm i @gits-id/editor
```

## Usage

```vue
<script setup lang="ts">
import {ref} from 'vue';
import VEditor from '@gits-id/editor';
const content = ref('');
</script>
<v-editor v-model="content"></v-editor>
```

## Documentation

View `VEditor` documentation [here](https://gits-ui.web.app/?path=/story/components-editor--default).

## Licence

ISC
3 changes: 3 additions & 0 deletions packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"description": "GITS Rich Text Editor Component",
"main": "src/index.ts",
"scripts": {
"build": "vite build && tsc --emitDeclarationOnly && mv dist/src dist/types",
"prepublishOnly": "npm run build",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
Expand All @@ -20,6 +22,7 @@
"vue": "^3.2.31"
},
"devDependencies": {
"@gits-id/tailwind-config": "^0.1.17-next.0",
"@gits-id/utils": "^0.1.17-next.0",
"@headlessui/vue": "^1.5.0",
"@heroicons/vue": "^1.0.6",
Expand Down
6 changes: 6 additions & 0 deletions packages/editor/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
5 changes: 5 additions & 0 deletions packages/editor/src/vue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.vue' {
import type {DefineComponent} from 'vue';
const component: DefineComponent<{}, {}, any>;
export default component;
}
6 changes: 6 additions & 0 deletions packages/editor/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
content: [
'./src/**/*.{vue,js,ts,jsx,tsx}',
],
presets: [require('@gits-id/tailwind-config/preset')],
};
21 changes: 21 additions & 0 deletions packages/editor/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "dist",
"declaration": true,
"sourceMap": false,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"allowJs": true,
"strict": true,
"noUnusedLocals": true,
"rootDir": ".",
"skipLibCheck": true,
"types": ["vite/client"],
"emitDeclarationOnly": true,
"allowSyntheticDefaultImports": true
},
"include": ["vue.d.ts", "*.vue", "src"],
"exclude": ["**/*.stories.ts", "**/*.spec.ts", "**/*.test.ts"]
}
51 changes: 51 additions & 0 deletions packages/editor/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {defineConfig} from 'vite';
import vue from '@vitejs/plugin-vue';
import {resolve} from 'path';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
],
esbuild: {
exclude: ['./src/**/**.stories.ts'],
},
build: {
target: 'esnext',
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'VEditor',
formats: ['es', 'cjs', 'iife', 'umd'],
},
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: ['vue', '@ckeditor/ckeditor5-build-classic', '@ckeditor/ckeditor5-vue', 'vee-validate'],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
vue: 'Vue'
}
},
resolve: {
dedupe: "vue"
},
plugins: [
{
name: 'remove-collection-handlers',
transform(code, id) {
if (
id.endsWith('reactivity.esm-bundler.js') ||
id.endsWith('runtime-core.esm-bundler.js')
) {
return code
.replace(`mutableCollectionHandlers,`, `null,`)
.replace(`readonlyCollectionHandlers,`, `null,`);
}
},
},
],
},
},
});
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6815a02

Please sign in to comment.