-
Notifications
You must be signed in to change notification settings - Fork 80
Improve typings for events and update project demo #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3216b8b
Internal: Add Vue linter and apply suggestions
filipsobol 1a8cc69
Feature: Improve typings for events emitted by the Vue component
filipsobol b1de678
Internal: Update demo project to better reflect real-world usage
filipsobol 56b455d
Internal: Remove outdated comment
filipsobol beaa75d
Internal: Update tests for checking CKEditor version
filipsobol e346f9c
Use Yarn instead of npm
filipsobol 0c06b9f
Fix build command in demo
filipsobol 8f38adc
Update README.md
filipsobol 9b2379c
Update README.md explaining how to run the demo project
filipsobol 3c7cffa
Build demo project on CI
filipsobol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
node_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>CKEditor Vue example</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "demo", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vue-tsc && vite build", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-build-classic": "^37.0.0-alpha.3", | ||
"@ckeditor/ckeditor5-vue": "file:..", | ||
"vue": "^3.2.47" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-vue": "^4.1.0", | ||
"typescript": "^4.9.3", | ||
"vite": "^4.2.0", | ||
"vue-tsc": "^1.2.0" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<template> | ||
<h1>Example of using CKEditor 5 in Vue.js 3.x</h1> | ||
|
||
<ckeditor | ||
v-model="data" | ||
tag-name="textarea" | ||
:editor="ClassicEditor" | ||
:config="config" | ||
:disabled="disabled" | ||
@ready="onReady" | ||
@focus="onFocus" | ||
@blur="onBlur" | ||
@input="onInput" | ||
@destroy="onDestroy" | ||
/> | ||
|
||
<button @click="toggleEditorDisabled"> | ||
{{ disabled ? 'Enable' : 'Disable' }} editor | ||
</button> | ||
|
||
<h2>Live editor data</h2> | ||
|
||
<textarea v-model="data" /> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, reactive } from 'vue'; | ||
import ClassicEditor from '@ckeditor/ckeditor5-build-classic'; | ||
import type { EventInfo } from '@ckeditor/ckeditor5-utils'; | ||
|
||
// State | ||
const data = ref( '<p>Hello world!</p>' ); | ||
|
||
const disabled = ref( false ); | ||
|
||
const config = reactive( { | ||
toolbar: [ 'heading', '|', 'bold', 'italic' ] | ||
} ); | ||
|
||
// Methods | ||
function toggleEditorDisabled() { | ||
disabled.value = !disabled.value; | ||
} | ||
|
||
function onReady( editor: ClassicEditor ) { | ||
window.editor = editor; | ||
|
||
console.log( 'Editor is ready.', { editor } ); | ||
} | ||
|
||
function onFocus( event: EventInfo, editor: ClassicEditor ) { | ||
console.log( 'Editor focused.', { event, editor } ); | ||
} | ||
|
||
function onBlur( event: EventInfo, editor: ClassicEditor ) { | ||
console.log( 'Editor blurred.', { event, editor } ); | ||
} | ||
|
||
function onInput( data: string, event: EventInfo, editor: ClassicEditor ) { | ||
console.log( 'Editor data input.', { event, editor, data } ); | ||
} | ||
|
||
function onDestroy( editor: ClassicEditor ) { | ||
console.log( 'Editor destroyed.', { editor } ); | ||
} | ||
</script> | ||
|
||
<style> | ||
body { | ||
max-width: 800px; | ||
margin: 20px auto; | ||
} | ||
|
||
textarea { | ||
width: 100%; | ||
height: 100px; | ||
font-family: monospace; | ||
} | ||
|
||
button { | ||
margin-top: 10px; | ||
} | ||
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { createApp } from 'vue'; | ||
import CKEditorPlugin from '@ckeditor/ckeditor5-vue'; | ||
import App from './App.vue'; | ||
|
||
createApp( App ) | ||
.use( CKEditorPlugin ) | ||
.mount( '#app' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type ClassicEditor from '@ckeditor/ckeditor5-build-classic'; | ||
|
||
declare global { | ||
interface Window { | ||
editor: ClassicEditor; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"useDefineForClassFields": true, | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"strict": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"esModuleInterop": true, | ||
"lib": ["ESNext", "DOM"], | ||
"skipLibCheck": true, | ||
"noEmit": true, | ||
"allowSyntheticDefaultImports": true, | ||
"types": [ | ||
"vite/client" | ||
] | ||
}, | ||
"include": [ | ||
"src/**/*.ts", | ||
"src/**/*.vue", | ||
"vite.config.ts" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineConfig } from 'vite'; | ||
import vue from '@vitejs/plugin-vue'; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig( { | ||
plugins: [ vue() ], | ||
optimizeDeps: { | ||
/** | ||
* This is required only because we use "npm link" for | ||
* testing purposes. See `dependencies` in `package.json`. | ||
*/ | ||
include: [ '@ckeditor/ckeditor5-vue' ] | ||
} | ||
} ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I am not in the process, I do not understand why we have two samples:
sample/
demo/
I can guess that the first is just a sample using the component and some CKEditor 5 build, while the second is a demo application (more realistic scenario). It would be good to describe both in README and explain which should be checked before releasing a new version. Maybe we do not need the
sample/
directory anymore. Instead, we should develop example applications that could be checked using E2E tests on CI.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR removes the demo in the
sample
folder, so we only have the one in thedemo
folder.I updated the README to include information on how to run the new demo before releasing a new version.
I also added a new CI script that will build the demo project.
Any more sophisticated tests will require more work and are probably beyond the scope of this PR. Any thoughts?