Skip to content

Commit

Permalink
Migrate everything to TinyMCE
Browse files Browse the repository at this point in the history
Refs #156
  • Loading branch information
The4thLaw committed Aug 23, 2024
1 parent 97c3729 commit 0bac9fd
Show file tree
Hide file tree
Showing 25 changed files with 206 additions and 210 deletions.
1 change: 1 addition & 0 deletions source/demyo-vue-frontend/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ declare module 'vue' {
PublisherCard: typeof import('./src/components/PublisherCard.vue')['default']
QuickSearchResults: typeof import('./src/components/QuickSearchResults.vue')['default']
ReaderSelection: typeof import('./src/components/ReaderSelection.vue')['default']
RichTextEditor: typeof import('./src/components/RichTextEditor.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
SectionCard: typeof import('./src/components/SectionCard.vue')['default']
Expand Down
2 changes: 2 additions & 0 deletions source/demyo-vue-frontend/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */

// TODO: Vue 3: probably not relevant anymore

// This file follows the guide from
// https://vue-test-utils.vuejs.org/installation/#using-vue-test-utils-with-jest-recommended
module.exports = {
Expand Down
89 changes: 89 additions & 0 deletions source/demyo-vue-frontend/package-lock.json

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

3 changes: 2 additions & 1 deletion source/demyo-vue-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@mdi/font": "^5.9.55",
"@tinymce/tinymce-vue": "^5.1.1",
"@unhead/vue": "^1.9.1",
"@vueuse/core": "^11.0.1",
"autoprefixer": "^10.4.18",
"axios": "^1.3.1",
"currency-symbol-map": "^5.0.1",
Expand All @@ -31,7 +32,7 @@
"roboto-fontface": "^0.10.0",
"tiny-async-pool": "^2.1.0",
"tinymce": "^7.0.0",
"tinymce-i18n": "^24.0.0",
"tinymce-i18n": "^24.0.0",
"vue": "^3.4.21",
"vue-3-fullscreen-image-directive-plugin": "^1.0.4",
"vue-filepond": "^7.0.4",
Expand Down
34 changes: 19 additions & 15 deletions source/demyo-vue-frontend/src/assets/deeper-skin.css
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ button::-moz-focus-inner {
.tox .tox-collection--toolbar .tox-collection__item--active:focus::after {
border-radius: 3px;
bottom: 0;
box-shadow: 0 0 0 2px var(--dpr-color-tint) ;
box-shadow: 0 0 0 2px var(--dpr-keyboard-focus-outline-color) ;
content: '';
left: 0;
position: absolute;
Expand All @@ -748,7 +748,7 @@ button::-moz-focus-inner {
.tox .tox-collection--grid .tox-collection__item--active:not(.tox-collection__item--state-disabled):focus::after {
border-radius: 3px;
bottom: 0;
box-shadow: 0 0 0 2px var(--dpr-color-tint) 'inset';
box-shadow: 0 0 0 2px var(--dpr-keyboard-focus-outline-color) 'inset';
content: '';
left: 0;
position: absolute;
Expand Down Expand Up @@ -1771,7 +1771,7 @@ body.tox-dialog__disable-scroll {
position: relative;
}
.tox .tox-edit-area::before {
border: 2px solid var(--dpr-color-tint);
border: 2px solid var(--dpr-keyboard-focus-outline-color);
border-radius: 4px;
content: '';
inset: 0;
Expand Down Expand Up @@ -2504,7 +2504,7 @@ body.tox-dialog__disable-scroll {
.tox .tox-mbtn:focus:not(:disabled)::after {
border-radius: 3px;
bottom: 0;
box-shadow: 0 0 0 2px var(--dpr-color-tint) ;
box-shadow: 0 0 0 2px var(--dpr-keyboard-focus-outline-color) ;
content: '';
left: 0;
position: absolute;
Expand Down Expand Up @@ -2998,7 +2998,7 @@ body.tox-dialog__disable-scroll {
.tox .tox-statusbar__wordcount:focus-visible::after {
border-radius: 3px;
bottom: 0;
box-shadow: 0 0 0 2px var(--dpr-color-tint) ;
box-shadow: 0 0 0 2px var(--dpr-keyboard-focus-outline-color) ;
content: '';
left: 0;
position: absolute;
Expand Down Expand Up @@ -3047,7 +3047,7 @@ body.tox-dialog__disable-scroll {
.tox .tox-statusbar__resize-handle:focus-visible::after {
border-radius: 3px;
bottom: 0;
box-shadow: 0 0 0 2px var(--dpr-color-tint) ;
box-shadow: 0 0 0 2px var(--dpr-keyboard-focus-outline-color) ;
content: '';
left: 0;
position: absolute;
Expand Down Expand Up @@ -3119,7 +3119,7 @@ body.tox-dialog__disable-scroll {
.tox .tox-tbtn:focus::after {
border-radius: 3px;
bottom: 0;
box-shadow: 0 0 0 2px var(--dpr-color-tint) ;
box-shadow: 0 0 0 2px var(--dpr-keyboard-focus-outline-color) ;
content: '';
left: 0;
position: absolute;
Expand Down Expand Up @@ -3196,7 +3196,7 @@ body.tox-dialog__disable-scroll {
.tox .tox-tbtn--enabled:focus::after {
border-radius: 3px;
bottom: 0;
box-shadow: 0 0 0 2px var(--dpr-color-tint) ;
box-shadow: 0 0 0 2px var(--dpr-keyboard-focus-outline-color) ;
content: '';
left: 0;
position: absolute;
Expand Down Expand Up @@ -3252,7 +3252,7 @@ body.tox-dialog__disable-scroll {
.tox .tox-number-input:focus::after {
border-radius: 3px;
bottom: 0;
box-shadow: 0 0 0 2px var(--dpr-color-tint) ;
box-shadow: 0 0 0 2px var(--dpr-keyboard-focus-outline-color) ;
content: '';
left: 0;
position: absolute;
Expand All @@ -3272,7 +3272,7 @@ body.tox-dialog__disable-scroll {
.tox .tox-number-input .tox-input-wrapper:focus::after {
border-radius: 3px;
bottom: 0;
box-shadow: 0 0 0 2px var(--dpr-color-tint) ;
box-shadow: 0 0 0 2px var(--dpr-keyboard-focus-outline-color) ;
content: '';
left: 0;
position: absolute;
Expand All @@ -3282,7 +3282,7 @@ body.tox-dialog__disable-scroll {
.tox .tox-number-input .tox-input-wrapper:has(input:focus)::after {
border-radius: 3px;
bottom: 0;
box-shadow: 0 0 0 2px var(--dpr-color-tint) ;
box-shadow: 0 0 0 2px var(--dpr-keyboard-focus-outline-color) ;
content: '';
left: 0;
position: absolute;
Expand Down Expand Up @@ -3332,7 +3332,7 @@ body.tox-dialog__disable-scroll {
.tox .tox-number-input button:focus::after {
border-radius: 3px;
bottom: 0;
box-shadow: 0 0 0 2px var(--dpr-color-tint) ;
box-shadow: 0 0 0 2px var(--dpr-keyboard-focus-outline-color) ;
content: '';
left: 0;
position: absolute;
Expand Down Expand Up @@ -3440,7 +3440,7 @@ body.tox-dialog__disable-scroll {
pointer-events: none;
border-radius: 3px;
bottom: 0;
box-shadow: 0 0 0 2px var(--dpr-color-tint) ;
box-shadow: 0 0 0 2px var(--dpr-keyboard-focus-outline-color) ;
content: '';
left: 0;
position: absolute;
Expand Down Expand Up @@ -3911,7 +3911,7 @@ body.tox-dialog__disable-scroll {
.tox .tox-revisionhistory__sidebar .tox-revisionhistory__revisions:focus::after {
border-radius: 3px;
bottom: 0;
box-shadow: 0 0 0 2px var(--dpr-color-tint) ;
box-shadow: 0 0 0 2px var(--dpr-keyboard-focus-outline-color) ;
content: '';
left: 0;
position: absolute;
Expand Down Expand Up @@ -3948,7 +3948,7 @@ body.tox-dialog__disable-scroll {
border-radius: 6px !important;
border-radius: 3px;
bottom: 0;
box-shadow: 0 0 0 2px var(--dpr-color-tint) ;
box-shadow: 0 0 0 2px var(--dpr-keyboard-focus-outline-color) ;
content: '';
left: 0;
position: absolute;
Expand Down Expand Up @@ -4099,6 +4099,7 @@ body.tox-dialog__disable-scroll {
--dpr-border-color: rgba(var(--v-border-color), var(--v-border-opacity));
--dpr-text-color: rgba(var(--v-theme-on-surface), var(--v-high-emphasis-opacity));
--dpr-text-color-muted: rgba(var(--v-theme-on-surface), var(--v-medium-emphasis-opacity));
--dpr-keyboard-focus-outline-color: rgba(var(--v-border-color), var(--v-high-emphasis-opacity));
--dpr-separator-color: gray;
--dpr-accessibility-issue-info-heading-text-color: rgb(var(--v-theme-info));
--dpr-accessibility-issue-info-body-text-color: rgb(var(--v-theme-info));
Expand Down Expand Up @@ -4252,3 +4253,6 @@ body.tox-dialog__disable-scroll {
.tox.tox-tinymce .tox-color-input span::before {
background-repeat: repeat;
}
.tox.tox-tinymce {
border-radius: 4px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
--dpr-border-color: rgba(var(--v-border-color), var(--v-border-opacity));
--dpr-text-color: rgba(var(--v-theme-on-surface), var(--v-high-emphasis-opacity));
--dpr-text-color-muted: rgba(var(--v-theme-on-surface), var(--v-medium-emphasis-opacity));
--dpr-keyboard-focus-outline-color: var(--dpr-color-tint);
--dpr-separator-color: gray;
--dpr-accessibility-issue-info-heading-text-color: rgb(var(--v-theme-info));
--dpr-accessibility-issue-info-body-text-color: rgb(var(--v-theme-info));
Expand Down Expand Up @@ -162,3 +163,6 @@
.tox.tox-tinymce .tox-color-input span::before {
background-repeat: repeat;
}
.tox.tox-tinymce {
border-radius: 4px;
}
2 changes: 0 additions & 2 deletions source/demyo-vue-frontend/src/assets/skin.js

This file was deleted.

70 changes: 70 additions & 0 deletions source/demyo-vue-frontend/src/components/RichTextEditor.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<template>
<!--
TODO: eventually, import the skin from a package published on npm rather than copy-pasting it to the assets
-->
<Editor
v-model="model"
api-key="sample-api"
:init="{
plugins: 'autoresize lists link image help',
license_key: 'gpl',
// We sideload our skin, no need for TinyMCE to manage it
skin: false,
content_css: 'default',
// No branding or promotion, we'll have that in our About page
promotion: false,
branding: false,
// Customize the toolbar
menubar: false,
toolbar: 'undo redo | styles | bold italic underline | link unlink image'
+ ' | alignleft aligncenter alignright alignjustify alignnone '
+ ' blockquote bullist numlist indent outdent'
+ ' | nonbreaking hr | removeformat | help',
language: $t('tinymce.language'),
// We don't need the status bar
statusbar: false
}"
/>
</template>

<script setup lang="ts">
import Editor from '@tinymce/tinymce-vue'
import { useVModel } from '@vueuse/core'
/* We need the global tinymce */
import 'tinymce/tinymce'
/* Default icons are required. After that, import custom icons if applicable */
import 'tinymce/icons/default/icons.min.js'
/* Required TinyMCE components */
import 'tinymce/models/dom/model.min.js'
import 'tinymce/themes/silver/theme.min.js'
/* Import a skin (can be a custom skin instead of the default) */
// import 'tinymce/skins/ui/oxide/skin.js'
import '@/assets/deeper-skin.css'
import '@/assets/deeper-vuetify-bindings.css'
/* Import plugins */
import 'tinymce/plugins/autoresize'
import 'tinymce/plugins/help'
import 'tinymce/plugins/help/js/i18n/keynav/en'
import 'tinymce/plugins/help/js/i18n/keynav/fr_FR'
import 'tinymce/plugins/image'
import 'tinymce/plugins/link'
import 'tinymce/plugins/lists'
// import 'tinymce/plugins/table'
/* Import languages. Eventually, lazy-load them? */
import 'tinymce-i18n/langs7/fr_FR'
/* The default content CSS can be changed or replaced with appropriate CSS for the editor content. */
import 'tinymce/skins/content/default/content.js'
const props = defineProps<{
modelValue: string | undefined
}>()
const emit = defineEmits(['update:modelValue'])
const model = useVModel(props, 'modelValue', emit)
</script>
Loading

0 comments on commit 0bac9fd

Please sign in to comment.