Skip to content
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

YSHOP2-1137-v2 : Rich text editor with froala #236

Merged
merged 32 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
eb0c92e
Created rich text editor with froala
Jan 14, 2024
7c8ba24
Removed tiptap based rich text editor
Jan 14, 2024
364d3de
Added custom types for component props
Jan 14, 2024
56e3cbf
Added configuration for custom icons
Jan 18, 2024
f326c5b
Merge branch 'main' into YSHOP2-1137-v2
Jan 18, 2024
7f5ddf9
minor improvements
eihabkhan1 Jan 19, 2024
dde565f
Renamed custom class
Jan 19, 2024
f01f807
Setting default font
Jan 19, 2024
2d903e4
Remove duplicated code
Jan 19, 2024
ece2cdb
Changed font size
Jan 19, 2024
59c239c
Changed fullscreen exit icon
Jan 19, 2024
6a9781d
Merge branch 'main' into YSHOP2-1137-v2
Jan 24, 2024
7688793
Updated toolbar icons
Jan 24, 2024
3d4b06b
Merge branch 'main' into YSHOP2-1137-v2
Jan 24, 2024
e28eb23
Added error prop and editable toolbar
Jan 25, 2024
4aeb5aa
Merge branch 'main' into YSHOP2-1137-v2
Jan 25, 2024
d4f2fe8
Removed tiptap
Jan 25, 2024
2991df7
Updated pnpm-lock file
Jan 25, 2024
e058108
Resolving pnpm conflict
Jan 25, 2024
cc434c5
Updated pnpm-lock file
Jan 25, 2024
b156708
Merge branch 'main' into YSHOP2-1137-v2
Jan 25, 2024
61d4745
updated pnpm file
Jan 29, 2024
51d5414
Merge branch 'main' into YSHOP2-1137-v2
Jan 29, 2024
39e80db
minor improvments
Jan 29, 2024
cf4e3a5
Merge branch 'main' into YSHOP2-1137-v2
Jan 29, 2024
ccff987
Fixed app.vue
Jan 29, 2024
3509fdc
Added quick insert feature
Jan 29, 2024
2aa745f
removed tiptap
Jan 29, 2024
ce93f6c
fixed editor width
Jan 29, 2024
f97ffaa
Merge branch 'main' into YSHOP2-1137-v2
Jan 29, 2024
d13c01a
Editor improvments
Jan 30, 2024
4a4ced4
Merge branch 'main' into YSHOP2-1137-v2
Feb 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"stylelint.validate": ["vue"],
"cSpell.words": [
"youcan"
]
"froala",
"youcan"
]
}
18 changes: 2 additions & 16 deletions packages/vue3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,8 @@
},
"dependencies": {
"@popperjs/core": "^2.11.7",
"@tiptap/core": "2.0.0-beta.215",
"@tiptap/extension-color": "2.0.0-beta.210",
"@tiptap/extension-highlight": "2.0.0-beta.210",
"@tiptap/extension-horizontal-rule": "2.0.0-beta.210",
"@tiptap/extension-image": "2.0.0-beta.210",
"@tiptap/extension-link": "2.0.0-beta.210",
"@tiptap/extension-table": "2.0.0-beta.210",
"@tiptap/extension-table-cell": "2.0.0-beta.210",
"@tiptap/extension-table-header": "2.0.0-beta.210",
"@tiptap/extension-table-row": "2.0.0-beta.210",
"@tiptap/extension-text-align": "^2.0.0-beta.210",
"@tiptap/extension-text-style": "2.0.0-beta.210",
"@tiptap/extension-underline": "2.0.0-beta.210",
"@tiptap/pm": "2.0.0-beta.210",
"@tiptap/starter-kit": "2.0.0-beta.210",
"@tiptap/vue-3": "2.0.0-beta.210",
"froala-editor": "^4.1.4",
"vue-froala-wysiwyg": "^4.1.4",
"vue-slicksort": "^2.0.5"
},
"devDependencies": {
Expand Down
60 changes: 15 additions & 45 deletions packages/vue3/src/_dev/App.vue
Original file line number Diff line number Diff line change
@@ -1,63 +1,33 @@
<script setup lang="ts">
import 'uno.css';
import '../assets/main.css';
import { ref, watch } from 'vue';
import { MediaInput, UploadedMedia } from '~/components';
import { ref } from 'vue';
import { RichText } from '~/components';
import type { ToolbarButtonsType } from '~/components/RichText/types';

const attachments = ref<File[]>([]);
const disabled = ref(false);
const limit = 4;

const checkLimit = () => {
disabled.value = attachments.value.length >= limit;
};

const deleteFile = (file: File) => {
const idx = attachments.value.indexOf(file);
if (idx > -1) {
attachments.value.splice(idx, 1);
checkLimit();
}
const content = ref('');
const error = ref(false);
const license = ref('license-key');
const toolbar: ToolbarButtonsType = {
text: ['fullscreen', 'bold', 'italic', 'underline', 'strikeThrough', 'textColor', 'backgroundColor', 'fontSize', 'paragraphFormat'],
paragraph: ['align', 'formatOL', 'formatUL', 'outdent', 'indent'],
misc: ['undo', 'redo'],
rich: ['insertTable', 'insertImage', 'insertVideo', 'emoticons', 'insertLink', 'specialCharacters', 'insertHR', 'codeView', 'clear'],
};
watch(attachments, () => {
checkLimit();
});
</script>

<template>
<div class="container">
<div class="files-grid">
<UploadedMedia
v-for="(attachment, index) in attachments"
:key="index"
:file="attachment"
@delete="deleteFile(attachment)"
/>
</div>
<MediaInput v-model="attachments" :limit="limit" :disabled="disabled" />
<div class="files-grid">
<UploadedMedia
file="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885_1280.jpg"
/>
</div>
<RichText v-model="content" :error="error" lang="ar" :license="license" :toolbar="toolbar" />
</div>
</template>

<style scoped>
<style scoped lang="css">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

css is the default lang so we can omit this

Suggested change
<style scoped lang="css">
<style scoped>

.container {
display: flex;
position: relative;
flex-direction: column;
align-items: center;
justify-content: center;
width: 300px;
min-height: 140px;
}

.file-grid {
position: absolute;
right: 0;
bottom: 0;
left: 0;
height: 100vh;
margin: 0 5%;
}
</style>
10 changes: 10 additions & 0 deletions packages/vue3/src/_dev/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
// Import Froala Editor
import 'froala-editor/js/plugins.pkgd.min.js';
// Import Froala Editor css files.
import 'froala-editor/css/froala_editor.pkgd.min.css';
import 'froala-editor/css/froala_style.min.css';
import 'froala-editor/js/languages/ar.js';
import 'froala-editor/js/languages/fr.js';
import 'froala-editor/js/languages/en_gb.js';
import VueFroala from 'vue-froala-wysiwyg';
import { createApp } from 'vue';
import App from './App.vue';
import 'uno.css';
import '@youcan/ui-core/tokens';

const app = createApp(App, {});

app.use(VueFroala);
app.mount('#app');
Loading