Revert "Update Editor.js to 2.30+ (#23837)" (#24851)

* Revert "Update Editor.js to 2.30+ (#23837)"

This reverts commit f718059d6c.

* Create nasty-trainers-compare.md
This commit is contained in:
Connor Winston
2025-03-18 09:01:42 -05:00
committed by GitHub
parent fc469b2125
commit 392bd381f7
7 changed files with 177 additions and 151 deletions

View File

@@ -0,0 +1,5 @@
---
"@directus/app": patch
---
Downgraded Editor.JS to circumvent conflicting inline elements bug until it's fixed

View File

@@ -48,19 +48,19 @@
"@directus/validation": "workspace:*",
"@editorjs/attaches": "1.3.0",
"@editorjs/checklist": "1.6.0",
"@editorjs/code": "2.9.3",
"@editorjs/code": "2.9.0",
"@editorjs/delimiter": "1.4.2",
"@editorjs/editorjs": "2.30.8",
"@editorjs/embed": "2.7.6",
"@editorjs/header": "2.8.8",
"@editorjs/image": "2.10.2",
"@editorjs/editorjs": "2.29.1",
"@editorjs/embed": "2.7.4",
"@editorjs/header": "2.8.1",
"@editorjs/image": "2.9.3",
"@editorjs/inline-code": "1.5.1",
"@editorjs/nested-list": "1.4.3",
"@editorjs/paragraph": "2.11.7",
"@editorjs/quote": "2.7.6",
"@editorjs/raw": "2.5.1",
"@editorjs/table": "2.4.3",
"@editorjs/underline": "1.2.1",
"@editorjs/paragraph": "2.11.5",
"@editorjs/quote": "2.7.2",
"@editorjs/raw": "2.5.0",
"@editorjs/table": "2.3.0",
"@editorjs/underline": "1.1.0",
"@fortawesome/fontawesome-svg-core": "6.7.2",
"@fortawesome/free-brands-svg-icons": "6.7.2",
"@fullcalendar/core": "6.1.15",

View File

@@ -7,32 +7,10 @@
z-index: 3;
}
/* Remove once merged: https://github.com/codex-team/editor.js/pull/2679 */
.codex-editor .ce-block__content [contenteditable] {
word-break: break-word;
}
/* Background color for selected text */
.codex-editor ::selection {
background-color: var(--theme--background-accent);
}
/* Color of block selection rectangle while dragging cursor */
.codex-editor .codex-editor-overlay__rectangle {
background-color: color-mix(in srgb, var(--theme--primary), transparent 75%);
}
/* Background for selected blocks */
.codex-editor .ce-block--selected .ce-block__content {
border-radius: var(--theme--border-radius);
background: var(--theme--primary-background);
}
/* Fix pseudo selection background when editing link */
.codex-editor .ce-block .ce-block__content [style='background-color: rgb(168, 214, 255);'] {
background-color: var(--theme--primary-background) !important;
}
.codex-editor .ce-toolbar__plus,
.codex-editor .ce-toolbar__settings-btn {
color: var(--theme--form--field--input--foreground);
@@ -76,19 +54,13 @@
}
.codex-editor .ce-popover {
--color-border: var(--theme--form--field--input--border-color);
--color-background: var(--theme--form--field--input--background-subdued);
--border-radius: var(--theme--border-radius);
/* Background color when focusing menu item */
--color-background-item-focus: var(--theme--background-accent);
}
.codex-editor .ce-popover__container {
background: var(--theme--form--field--input--background-subdued);
border-color: var(--theme--form--field--input--border-color);
border-width: var(--theme--border-width);
border-radius: var(--theme--border-radius);
}
.codex-editor .ce-popover-item,
.codex-editor .ce-popover__items button,
.codex-editor .ce-popover-item--confirmation .ce-popover-item__title {
color: var(--theme--form--field--input--foreground);
}
@@ -114,33 +86,25 @@
color: var(--theme--form--field--input--foreground);
}
.codex-editor .ce-popover-item.ce-popover-item--active,
.codex-editor .ce-popover-item.ce-popover-item--active:hover,
.codex-editor .ce-inline-tool.ce-inline-tool--active,
.codex-editor .ce-inline-tool.ce-inline-tool--active:hover {
.codex-editor .ce-popover-item--active {
background: var(--theme--background-accent);
}
.codex-editor .ce-popover:not(.ce-popover--inline) .ce-popover-item__icon:not(.ce-popover-item__icon--chevron-right) {
margin-right: 4px;
.codex-editor .ce-popover-item.ce-popover-item--active:hover {
background: var(--theme--background-accent);
}
.codex-editor .ce-popover-item__icon {
background: transparent;
box-shadow: unset;
border: 1px solid var(--theme--foreground-subdued);
border-radius: var(--theme--border-radius);
}
.codex-editor .ce-popover-item--active .ce-popover-item__icon {
color: var(--theme--primary);
}
/* Add small gap between buttons in inline toolbar */
.codex-editor
.ce-popover__items
> [class^='ce-popover-item']:not(.ce-popover-item-separator)
+ [class^='ce-popover-item']:not(.ce-popover-item-separator) {
margin-left: 1px;
}
.codex-editor .ce-popover-item__icon i {
display: inline-flex;
font-family: 'Material Symbols', sans-serif;
font-style: normal;
font-variant: normal;
@@ -157,6 +121,10 @@
border-color: var(--theme--background-subdued);
}
.codex-editor .ce-inline-tool {
padding: 0 10px !important;
}
.codex-editor .ce-settings__button--confirm.ce-settings__button--confirm {
background-color: var(--danger-110) !important;
}
@@ -205,7 +173,7 @@
.codex-editor .cdx-settings-button:hover,
.codex-editor .ce-conversion-tool:hover,
.codex-editor .ce-inline-toolbar__dropdown:hover,
.codex-editor .ce-inline-tool:hover,
.codex-editor .ce-inline-toolbar .ce-inline-tool:hover,
.codex-editor .ce-settings .ce-settings__button:hover {
background: var(--theme--background-normal);
}
@@ -309,21 +277,12 @@
--border-color: var(--theme--form--field--input--border-color);
}
.codex-editor .image-tool .image-tool__image {
border-radius: var(--theme--border-radius);
}
.codex-editor .image-tool--uploading .image-tool__image {
.codex-editor .image-tool--loading .image-tool__image {
background: var(--theme--background-normal);
}
.codex-editor .image-tool .image-tool__image-preloader {
background-color: var(--theme--foreground-subdued);
}
.codex-editor .image-tool .image-tool__image-preloader::after {
border-color: var(--theme--foreground-subdued);
border-top-color: var(--front-color);
.codex-editor .image-tool--loading .image-tool__image {
border-color: var(--theme--form--field--input--border-color);
}
/* Checklist */
@@ -433,9 +392,7 @@
border-radius: 4px;
}
/* Contrast for highlighted content inside inline code elements */
.codex-editor .ce-block .inline-code::selection,
.codex-editor .ce-block .inline-code > *::selection {
.codex-editor .ce-block .inline-code::selection {
background-color: var(--theme--warning);
}
@@ -521,14 +478,6 @@
text-align: right;
}
.codex-editor .ce-align-buttons {
padding: var(--item-padding);
}
.codex-editor .ce-align-buttons .cdx-settings-button {
margin-right: 2px;
}
.codex-editor .ce-align-buttons .cdx-settings-button svg {
fill: var(--theme--foreground);
}
@@ -591,6 +540,16 @@
color: var(--theme--primary);
}
.codex-editor .ce-block--selected .ce-block__content {
border-radius: var(--theme--border-radius);
background: var(--theme--primary-background);
}
/* Fix link pseudo selection background when editing link */
.codex-editor .ce-block.ce-block--focused .ce-block__content span[style='background-color: rgb(168, 214, 255);'] {
background-color: var(--theme--background-accent) !important;
}
.codex-editor .ce-block ul,
.codex-editor .ce-block ol {
margin: 24px 0;
@@ -668,6 +627,11 @@
text-align: center;
}
.codex-editor .ce-inline-tool--active {
color: var(--theme--primary);
background-color: var(--theme--background-normal);
}
/* Toggle Block */
.codex-editor .ce-block span.toggle-block__icon[style='color: black;'] {

View File

@@ -224,8 +224,7 @@ function sanitizeValue(value: any): EditorJS.OutputData | null {
border-color: var(--theme--form--field--input--border-color-hover);
}
&:focus-within,
&:has(.ce-popover--opened) {
&:focus-within {
border-color: var(--theme--form--field--input--border-color-focus);
}
}

View File

@@ -1,15 +1,22 @@
import { unexpectedError } from '@/utils/unexpected-error';
import BaseAttachesTool from '@editorjs/attaches';
import { MenuConfig } from '@editorjs/editorjs/types/tools';
import BaseImageTool from '@editorjs/image';
import { unexpectedError } from '@/utils/unexpected-error';
import { useBus } from './bus';
/*
/**
* This file is a modified version of the attaches and image tool from editorjs to work with the Directus file manager.
*
* We include an uploader to directly use Directus file manager, along with a modified version of the attaches and image tools.
*/
type Tune = {
name?: string;
title: string;
icon: string;
onActivate?: () => void;
toggle: boolean;
};
class Uploader {
getCurrentFile: any;
config: any;
@@ -139,7 +146,7 @@ export class AttachesTool extends BaseAttachesTool {
}
}
export class ImageTool extends (BaseImageTool as any) {
export class ImageTool extends BaseImageTool {
constructor(params: any) {
super(params);
@@ -153,20 +160,61 @@ export class ImageTool extends (BaseImageTool as any) {
set image(file: { url?: any }) {
this._data.file = file || {};
if (file?.url) this.ui.fillImage(file.url);
if (file && file.url) {
const separator = file.url.includes('?') ? '&' : '?';
const imageUrl = `${file.url}${separator}key=system-large-contain`;
this.ui.fillImage(imageUrl);
}
}
renderSettings() {
const openImageItem: MenuConfig = {
icon: '<i>open_in_new</i>',
title: 'Open Image',
toggle: false,
onActivate: () => {
const bus = useBus();
bus.emit({ type: 'open-url', payload: this.data.file.fileURL });
const tunes: Tune[] = [
{
icon: 'open_in_new',
title: 'Open Image',
toggle: false,
onActivate: () => {
const bus = useBus();
bus.emit({ type: 'open-url', payload: this.data.file.fileURL });
},
},
};
...BaseImageTool.tunes,
];
return [openImageItem, ...super.renderSettings()];
const wrapperElement = document.createElement('div');
wrapperElement.classList.add('ce-popover__items');
for (const tune of tunes) {
const tuneElement = document.createElement('div');
tuneElement.classList.add('ce-popover-item');
const iconElement = document.createElement('div');
iconElement.classList.add('ce-popover-item__icon');
const iElement = document.createElement('i');
iElement.innerHTML = tune.icon;
iconElement.appendChild(iElement);
tuneElement.appendChild(iconElement);
const titleElement = document.createElement('div');
titleElement.classList.add('ce-popover-item__title');
titleElement.innerHTML = tune.title;
tuneElement.appendChild(titleElement);
if (tune.toggle && tune.name && this._data[tune.name]) {
tuneElement.classList.add('ce-popover-item--active');
}
if (tune.onActivate) tuneElement.addEventListener('click', tune.onActivate);
else if (tune.toggle)
tuneElement.addEventListener('click', () => {
this.tuneToggled(tune.name);
tuneElement.classList.toggle('ce-popover-item--active');
});
wrapperElement.appendChild(tuneElement);
}
return wrapperElement;
}
}

11
app/src/shims.d.ts vendored
View File

@@ -28,10 +28,21 @@ declare module 'frappe-charts/src/js/charts/AxisChart' {
declare module '@directus-extensions' {}
declare module '@editorjs/image';
declare module '@editorjs/attaches';
declare module '@editorjs/paragraph';
declare module '@editorjs/quote';
declare module '@editorjs/checklist';
declare module '@editorjs/delimiter';
declare module '@editorjs/table';
declare module '@editorjs/code';
declare module '@editorjs/header';
declare module '@editorjs/underline';
declare module '@editorjs/embed';
declare module '@editorjs/raw';
declare module '@editorjs/inline-code';
declare module '@editorjs/nested-list';
declare module 'editorjs-text-alignment-blocktune';
declare module 'editorjs-toggle-block';
declare module 'vue-virtual-scroller' {

107
pnpm-lock.yaml generated
View File

@@ -593,23 +593,23 @@ importers:
specifier: 1.6.0
version: 1.6.0
'@editorjs/code':
specifier: 2.9.3
version: 2.9.3
specifier: 2.9.0
version: 2.9.0
'@editorjs/delimiter':
specifier: 1.4.2
version: 1.4.2
'@editorjs/editorjs':
specifier: 2.30.8
version: 2.30.8
specifier: 2.29.1
version: 2.29.1
'@editorjs/embed':
specifier: 2.7.6
version: 2.7.6
specifier: 2.7.4
version: 2.7.4
'@editorjs/header':
specifier: 2.8.8
version: 2.8.8
specifier: 2.8.1
version: 2.8.1
'@editorjs/image':
specifier: 2.10.2
version: 2.10.2
specifier: 2.9.3
version: 2.9.3
'@editorjs/inline-code':
specifier: 1.5.1
version: 1.5.1
@@ -617,20 +617,20 @@ importers:
specifier: 1.4.3
version: 1.4.3
'@editorjs/paragraph':
specifier: 2.11.7
version: 2.11.7
specifier: 2.11.5
version: 2.11.5
'@editorjs/quote':
specifier: 2.7.6
version: 2.7.6
specifier: 2.7.2
version: 2.7.2
'@editorjs/raw':
specifier: 2.5.1
version: 2.5.1
specifier: 2.5.0
version: 2.5.0
'@editorjs/table':
specifier: 2.4.3
version: 2.4.3
specifier: 2.3.0
version: 2.3.0
'@editorjs/underline':
specifier: 1.2.1
version: 1.2.1
specifier: 1.1.0
version: 1.1.0
'@fortawesome/fontawesome-svg-core':
specifier: 6.7.2
version: 6.7.2
@@ -2782,8 +2782,8 @@ packages:
'@editorjs/checklist@1.6.0':
resolution: {integrity: sha512-hRNP36DInr73mSK3noHBQeoQb7DA12ANfqTXufEkTgQzx+k4mRJ0HdeGukTIR4JbwjHJ9ecUBnnQqIEGnxCFEg==}
'@editorjs/code@2.9.3':
resolution: {integrity: sha512-nXUrK3CjhpubvShYtcbkpZ9SU15IYwmJOsWZrlWYSzy9unZBRQthii6eABndsCtODzzV0yiSKmTp00RQkFow3Q==}
'@editorjs/code@2.9.0':
resolution: {integrity: sha512-QNOWxF29j6mYl/gM5HJzeGOt3s4laoZCUbuRqj6RkIvLBWMU+ASwjckEiouA61hcYUOMfpw4vQjzhsfC7xm/vA==}
'@editorjs/delimiter@1.4.2':
resolution: {integrity: sha512-S8q2LpeYdYkVShLp7K8c4HLthDHBevLw+sT+iO0+SH0oMvFmld9SUon3DFzMQ2gG07EOdZGRZ958+sVxyvFjZw==}
@@ -2791,20 +2791,20 @@ packages:
'@editorjs/dom@0.0.5':
resolution: {integrity: sha512-SZ78Gwpkp3EUhjBIp0lSojeQ35V9acF8SubJsMeOH/vlOUE40GOnvvwWZnF05lO7bIB0dOHhhJy4N7IIAWxP2w==}
'@editorjs/editorjs@2.30.8':
resolution: {integrity: sha512-ClFuxI1qZTfXPJTacQfsJtOUP6bKoIe6BQNdAvGsDTDVwMnZEzoaSOwvUpdZEE56xppVfQueNK/1MElV9SJKHg==}
'@editorjs/editorjs@2.29.1':
resolution: {integrity: sha512-WRT2pCfikMsvySQJqpCU21LfTZaPuxUWsDO8aFGrPx4MKzOR9D+Ur4mNb3jq0FXx2EMqvIWfTyFixJxtjGHTyQ==}
'@editorjs/embed@2.7.6':
resolution: {integrity: sha512-L3agW/23mOI0L+oksUE9UOR5VSNCqapxLH5lma+5j+idjKCC31nxbx07x53MSJ4rlOTO1L7cFVhkqptEdOliJA==}
'@editorjs/embed@2.7.4':
resolution: {integrity: sha512-ByvSZnVuh9FhjLGmvjNlxhk3hnqN0g5K+E/tJY6Whdspgh9mst0iBARoVJQDGeJC+NNL2sSgYGt1ZjvEK5Z+lQ==}
'@editorjs/header@2.8.8':
resolution: {integrity: sha512-bsMSs34u2hoi0UBuRoc5EGWXIFzJiwYgkFUYQGVm63y5FU+s8zPBmVx5Ip2sw1xgs0fqfDROqmteMvvmbCy62w==}
'@editorjs/header@2.8.1':
resolution: {integrity: sha512-y0HVXRP7m2W617CWo3fsb5HhXmSLaRpb9GzFx0Vkp/HEm9Dz5YO1s8tC7R8JD3MskwoYh7V0hRFQt39io/r6hA==}
'@editorjs/helpers@0.0.4':
resolution: {integrity: sha512-ieg3dzo2m1/ELze/RMNADiAiC5amXxIlVXoJ5vvXITOu/p/dPsrF+Oi3h5gBYvtGk9vg5LJUSG5YWU0tBUO1tw==}
'@editorjs/image@2.10.2':
resolution: {integrity: sha512-SU0nP9NhqwA7+Jlco/E7zjYjtRUrVGSOW8bsrrEnH8my588UW7mPGa1zwAHFs/UMB0x8LXKOb1iq40db+2iC6A==}
'@editorjs/image@2.9.3':
resolution: {integrity: sha512-hBOHuqvL/ovjrns+xLuBh/b3kqABDlLxlByWnSuKnE31O351NDrg9AXrB1yYo0yZerw5V591rP0US3PEzp7CzQ==}
'@editorjs/inline-code@1.5.1':
resolution: {integrity: sha512-XvKpqw9y1bOYgyuVUHGDuu7KlNWCYIXD5uU1Lpc4s4LJ8VN4TjWFGKJ3sS+LR7zzasWe8hu2ffR1JC6MHIS0EQ==}
@@ -2812,20 +2812,20 @@ packages:
'@editorjs/nested-list@1.4.3':
resolution: {integrity: sha512-3jTJd6H2Zwe8SeiI9li9AolkCxFVitEnCpJjDI6+la/HslSJC827fHivc9hue6JmC8esA4yri0KCMyp8N4ykww==}
'@editorjs/paragraph@2.11.7':
resolution: {integrity: sha512-qD6bbWvRc4VvP0mXDOm+hOhzzhUYR9ZjcAvgCuKWcCbUMpCvhVF1s8NX40zdjekPi6JEnuHTamCncTrSzVsVhw==}
'@editorjs/paragraph@2.11.5':
resolution: {integrity: sha512-ZcUKnVOoFPuMdVJJXMo2odmsjxeZQOUxmOwOiZktRuFkRDMq9qCqkmzqE1BH5VR6YyyMLKV4ZBEwedwggDH8iA==}
'@editorjs/quote@2.7.6':
resolution: {integrity: sha512-D01KUMSDj2r+6Z+xjDkQqI+y6URpeHCvj0+P4pah+GtkG040lWjFb2H4pgHFXuol2cbfyAoraYSw85fuPheCvw==}
'@editorjs/quote@2.7.2':
resolution: {integrity: sha512-C2yB6TdBJsmfcwe2rirSjPMCQ3jTz8oOwOPbOFeLDcvUgxECEIws8kZOkuxXePdWua68QwIpUFH7yWf338lwUQ==}
'@editorjs/raw@2.5.1':
resolution: {integrity: sha512-h7CjXtfSTe4Bj1CL84ch5NW0q0CdrlWsLzQ/kbaFTgx914CzKz4Ug+xgdvytVO1dd1QzB5/HCW0ic1VxtgkhMQ==}
'@editorjs/raw@2.5.0':
resolution: {integrity: sha512-ZOYKgR/sutOXHQ4uaWg8KzZ6yFJZCMTndezlN257GGsQ3Sa3ERcK9wZHKgAMNXaDhdKx9fDuojxRRcYvz6l9aQ==}
'@editorjs/table@2.4.3':
resolution: {integrity: sha512-TBLVFA1T6PIZRSWz0gXZUtNrFu4a59FeABM/wS0/Coc/bhOfWBRrf5/Ic5tVHaTazXEo1dYWWrVgg/jRaRnYbw==}
'@editorjs/table@2.3.0':
resolution: {integrity: sha512-/dKE6A5FkukX/FpvIyQGsewwXglZk8YbXpEp9vkB6Ec4ETLeGJMxObCcYqbXqVod+IU/a1tFH+j3lsD8ASD41g==}
'@editorjs/underline@1.2.1':
resolution: {integrity: sha512-LjJ01ia6Pj0Z/elifycp9+T1bQs0eXNnIcEYKOlk0sGHLy88DPcBOh9oz1i+uWarZ4AjGsvSMaptpWe+yQNsjQ==}
'@editorjs/underline@1.1.0':
resolution: {integrity: sha512-vQj2ROW1KreD31QHlhaPikmDJGWYzRBusN4Zyfwl9nIIQCByt4S8fZQpsrRvH4sct5mkirsHllNT00rJlqHK7Q==}
'@emnapi/runtime@1.3.1':
resolution: {integrity: sha512-kEBmG8KyqtxJZv+ygbEim+KCGtIq1fC22Ms3S4ziXmYKm8uyoLX0MHONVKwp+9opg390VaKRNt4a7A9NwmpNhw==}
@@ -13492,9 +13492,9 @@ snapshots:
dependencies:
'@codexteam/icons': 0.3.3
'@editorjs/code@2.9.3':
'@editorjs/code@2.9.0':
dependencies:
'@codexteam/icons': 0.3.3
'@codexteam/icons': 0.0.5
'@editorjs/delimiter@1.4.2':
dependencies:
@@ -13504,20 +13504,19 @@ snapshots:
dependencies:
'@editorjs/helpers': 0.0.4
'@editorjs/editorjs@2.30.8': {}
'@editorjs/editorjs@2.29.1': {}
'@editorjs/embed@2.7.6':
'@editorjs/embed@2.7.4':
dependencies:
'@editorjs/editorjs': 2.30.8
'@editorjs/editorjs': 2.29.1
'@editorjs/header@2.8.8':
'@editorjs/header@2.8.1':
dependencies:
'@codexteam/icons': 0.0.5
'@editorjs/editorjs': 2.30.8
'@editorjs/helpers@0.0.4': {}
'@editorjs/image@2.10.2':
'@editorjs/image@2.9.3':
dependencies:
'@codexteam/icons': 0.3.3
@@ -13529,26 +13528,26 @@ snapshots:
dependencies:
'@codexteam/icons': 0.0.2
'@editorjs/paragraph@2.11.7':
'@editorjs/paragraph@2.11.5':
dependencies:
'@codexteam/icons': 0.0.4
'@editorjs/quote@2.7.6':
'@editorjs/quote@2.7.2':
dependencies:
'@codexteam/icons': 0.3.3
'@editorjs/dom': 0.0.5
'@editorjs/raw@2.5.1':
'@editorjs/raw@2.5.0':
dependencies:
'@codexteam/icons': 0.0.4
'@editorjs/table@2.4.3':
'@editorjs/table@2.3.0':
dependencies:
'@codexteam/icons': 0.0.6
'@editorjs/underline@1.2.1':
'@editorjs/underline@1.1.0':
dependencies:
'@codexteam/icons': 0.3.3
'@codexteam/icons': 0.0.6
'@emnapi/runtime@1.3.1':
dependencies: