diff options
| author | git-pc-greta <ordipolo@gmx.fr> | 2025-01-22 01:23:58 +0100 |
|---|---|---|
| committer | git-pc-greta <ordipolo@gmx.fr> | 2025-01-22 01:23:58 +0100 |
| commit | f1dd96bc67e497f6c07291d6e5f6f23ec243b091 (patch) | |
| tree | 428dfe2ad601815c99a8e447fee05e2ec411a3e2 /src | |
| parent | 718107e8efbcb42d6b263999a3d9f6c4f02f26e5 (diff) | |
| download | ckeditor5-f1dd96bc67e497f6c07291d6e5f6f23ec243b091.tar.gz ckeditor5-f1dd96bc67e497f6c07291d6e5f6f23ec243b091.tar.bz2 ckeditor5-f1dd96bc67e497f6c07291d6e5f6f23ec243b091.zip | |
classe CKEditor
Diffstat (limited to 'src')
| -rw-r--r-- | src/integration/ckeditor5/CKEditor.php | 153 | ||||
| -rw-r--r-- | src/integration/ckeditor5/clean_html.php | 40 | ||||
| -rw-r--r-- | src/integration/ckeditor5/config.php | 22 | ||||
| -rw-r--r-- | src/integration/ckeditor5/create.php | 18 | ||||
| -rw-r--r-- | src/integration/ckeditor5/image_upload.php | 25 | ||||
| -rw-r--r-- | src/integration/ckeditor5/init.php | 23 | ||||
| -rw-r--r-- | src/integration/ckeditor5/view.php | 17 | ||||
| -rw-r--r-- | src/view/templates/page.php | 6 |
8 files changed, 172 insertions, 132 deletions
diff --git a/src/integration/ckeditor5/CKEditor.php b/src/integration/ckeditor5/CKEditor.php new file mode 100644 index 0000000..f3a60e0 --- /dev/null +++ b/src/integration/ckeditor5/CKEditor.php | |||
| @@ -0,0 +1,153 @@ | |||
| 1 | <?php | ||
| 2 | class CKEditor | ||
| 3 | { | ||
| 4 | public const string INTEGRATION_PATH = 'src/integration/ckeditor5/'; | ||
| 5 | private string $from = 'index.php'; | ||
| 6 | public string $open_editor_link = 'index.php?action=editor'; | ||
| 7 | private string $form_action_file = 'index.php?action=submit'; | ||
| 8 | private string $upload_ajax_url = 'index.php?action=upload_image'; | ||
| 9 | private string $php_ini_max_size; | ||
| 10 | public string $css_editor_tag = ''; | ||
| 11 | public string $css_outside_editor_tag; | ||
| 12 | private string $toolbar_language = 'fr'; | ||
| 13 | public string $storage = 'files'; | ||
| 14 | public string $data_path = 'data/page'; | ||
| 15 | public string $nom_article = "article"; | ||
| 16 | |||
| 17 | private string $server_root; | ||
| 18 | // pour l'importmap: j'ai modifié la version "installation avec CDN de la doc pour utiliser les fichiers locaux | ||
| 19 | // l'"importmap" permet d'utiliser "import" (ça ressemble pas mal au python) dans le navigateur comme n'importe quel langage de programmation normal | ||
| 20 | |||
| 21 | |||
| 22 | public function __construct() | ||
| 23 | { | ||
| 24 | $this->makeTranslationSymLink(); | ||
| 25 | $this->from .= isset($_GET['from']) ? '?page=' . $_GET['from'] : ''; | ||
| 26 | $this->php_ini_max_size = $this->returnBytes(ini_get('upload_max_filesize')); // = 2M par défaut dans le php.ini | ||
| 27 | $this->css_outside_editor_tag = '<link rel="stylesheet" href="' . self::INTEGRATION_PATH . 'article_hors_editeur.css" />'; | ||
| 28 | $this->server_root = $_SERVER['SERVER_NAME'] . '/ckeditor5/'; | ||
| 29 | } | ||
| 30 | |||
| 31 | public function checkAjaxReqest() | ||
| 32 | { | ||
| 33 | // dans un fichier à part parce que trop de lignes | ||
| 34 | require self::INTEGRATION_PATH . 'image_upload.php'; | ||
| 35 | die; | ||
| 36 | } | ||
| 37 | |||
| 38 | public function checkSubmitPOST() | ||
| 39 | { | ||
| 40 | $html_from_editor = $this->getAndCleanEditorOutput($_POST["contenu"]); // manipule $_POST['contenu']; | ||
| 41 | |||
| 42 | // enregistrement des données | ||
| 43 | //var_dump($html_from_editor); | ||
| 44 | echo "ce programme n'enregistre rien, faîtes-le dans votre application et supprimer cette ligne dans index.php"; die; | ||
| 45 | |||
| 46 | header('Location: ' . $this->from); | ||
| 47 | die; | ||
| 48 | } | ||
| 49 | |||
| 50 | public function openEditor() | ||
| 51 | { | ||
| 52 | // version "minifiée" | ||
| 53 | $this->css_editor_tag = '<link rel="stylesheet" href="node_modules/ckeditor5/dist/browser/ckeditor5.css" />'; | ||
| 54 | // version normale aérée et commentée" | ||
| 55 | $this->css_editor_tag = '<link rel="stylesheet" href="node_modules/ckeditor5/dist/ckeditor5.css" />'; | ||
| 56 | |||
| 57 | if($this->storage === 'database') | ||
| 58 | {} | ||
| 59 | elseif($this->storage === 'files') | ||
| 60 | { | ||
| 61 | $texte = file_get_contents($this->data_path . '/html/' . $this->nom_article . '.html'); | ||
| 62 | |||
| 63 | $texte = trim(addcslashes($texte, "'")); // échapper les simples quotes pour javascript | ||
| 64 | //$texte = trim(addslashes($texte)); // échappe ', ", \ et NULL, je sais pas si c'est bien | ||
| 65 | } | ||
| 66 | |||
| 67 | require self::INTEGRATION_PATH . 'view.php'; // html + JS | ||
| 68 | return $editeurHTML; | ||
| 69 | } | ||
| 70 | |||
| 71 | /* lien symbolique des traductions | ||
| 72 | l'éditeur recherche un dans module/ckeditor5/dist/browser/translations | ||
| 73 | un fichier se trouvant dans module/ckeditor5/dist/translations | ||
| 74 | c'est le meilleur moyen que j'ai trouvé de gérer ça (il y a surement mieux) */ | ||
| 75 | private function makeTranslationSymLink(): void | ||
| 76 | { | ||
| 77 | $target = '../translations'; | ||
| 78 | $link = 'node_modules/ckeditor5/dist/browser/translations'; | ||
| 79 | |||
| 80 | if(!file_exists($link)) | ||
| 81 | { | ||
| 82 | if(PHP_OS_FAMILY === 'Linux') | ||
| 83 | { | ||
| 84 | symlink($target, $link); | ||
| 85 | } | ||
| 86 | elseif(PHP_OS_FAMILY === 'Windows') // note: PHP_OS = WINNT | ||
| 87 | { | ||
| 88 | // on peut créer une jointure sans droit d'admin | ||
| 89 | $target = 'node_modules\ckeditor5\dist\translations'; | ||
| 90 | exec('mklink /J ' . str_replace('/', '\\', $link) . ' ' . $target); | ||
| 91 | } | ||
| 92 | else | ||
| 93 | { | ||
| 94 | echo "erreur dans " . self::INTEGRATION_PATH . "CKEditor.php: système d'exploitation n'a pas été reconnu"; | ||
| 95 | } | ||
| 96 | // autres valeurs possibles pour PHP_OS_FAMILY: 'BSD', 'Darwin', 'Solaris', 'Unknown' | ||
| 97 | } | ||
| 98 | } | ||
| 99 | |||
| 100 | // conversion des 2M du php.ini en 2000000 | ||
| 101 | // note: les kibi, mébi et gibi sont inutiles ici | ||
| 102 | private function returnBytes($size_str) // chaine du style '2M' | ||
| 103 | { | ||
| 104 | switch (substr ($size_str, -1)) | ||
| 105 | { | ||
| 106 | case 'Ki': case 'ki': return (int)$size_str * 1024; | ||
| 107 | case 'Mi': case 'mi': return (int)$size_str * 1048576; | ||
| 108 | case 'Gi': case 'gi': return (int)$size_str * 1073741824; | ||
| 109 | case 'K': case 'k': return (int)$size_str * 1000; | ||
| 110 | case 'M': case 'm': return (int)$size_str * 1000000; | ||
| 111 | case 'G': case 'g': return (int)$size_str * 1000000000; | ||
| 112 | default: return $size_str; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | private function getAndCleanEditorOutput(string $html): string | ||
| 117 | { | ||
| 118 | // bugs possibles sans trim() lorsqu'on insère le HTML dans l'éditeur | ||
| 119 | $html = trim($html); | ||
| 120 | |||
| 121 | //checkContentInFile($html, 'avant'); | ||
| 122 | |||
| 123 | // sécurisation du HTML (faille XSS) | ||
| 124 | require 'vendor/htmlawed/htmlawed/htmLawed.php'; | ||
| 125 | $configHtmLawed = array( | ||
| 126 | 'safe'=>1, // protection contre les élements et attributs dangereux | ||
| 127 | |||
| 128 | // balises autorisées | ||
| 129 | 'elements'=>'h2, h3, h4, p, span, i, strong, u, s, mark, blockquote, li, ol, ul, a, figure, hr, img, figcaption, table, tbody, tr, td', | ||
| 130 | // note: change <s></s> en <span style="text-decoration: line-through;"></span> | ||
| 131 | |||
| 132 | // attributs interdits | ||
| 133 | 'deny_attribute'=>'id', // 'class' et 'style' sont conservés pour le ckeditor | ||
| 134 | ); | ||
| 135 | $specHtmLawed = ''; // optionnel: faire qu'un certain élément puisse n'avoir que certains attributs | ||
| 136 | $html = htmLawed($html, $configHtmLawed, $specHtmLawed); | ||
| 137 | |||
| 138 | //checkContentInFile($html, 'après'); | ||
| 139 | |||
| 140 | return $html; | ||
| 141 | } | ||
| 142 | |||
| 143 | |||
| 144 | private function checkContentInFile($html, $file_name): void | ||
| 145 | { | ||
| 146 | $page = 'page'; | ||
| 147 | $nom_fichier = $file_name . ".html"; | ||
| 148 | $fichier = fopen('data/' . $page . '/' . $nom_fichier, 'w'); // w peut créer un fichier, si il existe déjà, il est effacé par le nouveau contenu | ||
| 149 | fputs($fichier, $html); | ||
| 150 | fclose($fichier); | ||
| 151 | chmod('data/' . $page . '/' . $nom_fichier, 0666); | ||
| 152 | } | ||
| 153 | } \ No newline at end of file | ||
diff --git a/src/integration/ckeditor5/clean_html.php b/src/integration/ckeditor5/clean_html.php deleted file mode 100644 index e56f49c..0000000 --- a/src/integration/ckeditor5/clean_html.php +++ /dev/null | |||
| @@ -1,40 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | // src/integration/ckeditor5/clean_html.php | ||
| 3 | |||
| 4 | function getAndCleanEditorOutput(): string | ||
| 5 | { | ||
| 6 | // bugs possibles sans trim() lorsqu'on insère le HTML dans l'éditeur | ||
| 7 | $html = trim($_POST["contenu"]); | ||
| 8 | |||
| 9 | //checkContentInFile($html, 'avant'); | ||
| 10 | |||
| 11 | // sécurisation du HTML (faille XSS) | ||
| 12 | require 'vendor/htmlawed/htmlawed/htmLawed.php'; | ||
| 13 | $configHtmLawed = array( | ||
| 14 | 'safe'=>1, // protection contre les élements et attributs dangereux | ||
| 15 | |||
| 16 | // balises autorisées | ||
| 17 | 'elements'=>'h2, h3, h4, p, span, i, strong, u, s, mark, blockquote, li, ol, ul, a, figure, hr, img, figcaption, table, tbody, tr, td', | ||
| 18 | // note: change <s></s> en <span style="text-decoration: line-through;"></span> | ||
| 19 | |||
| 20 | // attributs interdits | ||
| 21 | 'deny_attribute'=>'id', // 'class' et 'style' sont conservés pour le ckeditor | ||
| 22 | ); | ||
| 23 | $specHtmLawed = ''; // optionnel: faire qu'un certain élément puisse n'avoir que certains attributs | ||
| 24 | $html = htmLawed($html, $configHtmLawed, $specHtmLawed); | ||
| 25 | |||
| 26 | //checkContentInFile($html, 'après'); | ||
| 27 | |||
| 28 | return $html; | ||
| 29 | } | ||
| 30 | |||
| 31 | |||
| 32 | function checkContentInFile($html, $file_name) | ||
| 33 | { | ||
| 34 | $page = 'page'; | ||
| 35 | $nom_fichier = $file_name . ".html"; | ||
| 36 | $fichier = fopen('data/' . $page . '/' . $nom_fichier, 'w'); // w peut créer un fichier, si il existe déjà, il est effacé par le nouveau contenu | ||
| 37 | fputs($fichier, $html); | ||
| 38 | fclose($fichier); | ||
| 39 | chmod('data/' . $page . '/' . $nom_fichier, 0666); | ||
| 40 | } \ No newline at end of file | ||
diff --git a/src/integration/ckeditor5/config.php b/src/integration/ckeditor5/config.php deleted file mode 100644 index e185e8e..0000000 --- a/src/integration/ckeditor5/config.php +++ /dev/null | |||
| @@ -1,22 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | // src/integration/ckeditor5/config.php | ||
| 3 | |||
| 4 | $ckeditor_integration = 'src/integration/ckeditor5/'; | ||
| 5 | $css_hors_editeur = '<link rel="stylesheet" href="' . $ckeditor_integration . 'article_hors_editeur.css" />'; | ||
| 6 | |||
| 7 | $server_root = $_SERVER['SERVER_NAME'] . '/ckeditor5/'; | ||
| 8 | // pour l'importmap: j'ai modifié la version "installation avec CDN de la doc pour utiliser les fichiers locaux | ||
| 9 | // l'"importmap" permet d'utiliser "import" (ça ressemble pas mal au python) dans le navigateur comme n'importe quel langage de programmation normal | ||
| 10 | |||
| 11 | $previous_page = 'index.php'; | ||
| 12 | $open_editor_link = 'index.php?page=editor'; | ||
| 13 | $form_action_file = 'index.php?action=submit'; | ||
| 14 | $upload_ajax_url = 'index.php?action=upload_image'; | ||
| 15 | |||
| 16 | $toolbar_language = 'fr'; | ||
| 17 | |||
| 18 | $storage = 'files'; // choisir 'files' ou 'database' | ||
| 19 | $page = 'page'; | ||
| 20 | $nom_article = "article"; | ||
| 21 | |||
| 22 | $php_ini_max_size = ini_get('upload_max_filesize'); // = 2M par défaut dans le php.ini | ||
diff --git a/src/integration/ckeditor5/create.php b/src/integration/ckeditor5/create.php deleted file mode 100644 index cf7242c..0000000 --- a/src/integration/ckeditor5/create.php +++ /dev/null | |||
| @@ -1,18 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | // src/integration/ckeditor5/create.php | ||
| 3 | |||
| 4 | // modèle | ||
| 5 | if($storage === 'database') | ||
| 6 | {} | ||
| 7 | elseif($storage === 'files') | ||
| 8 | { | ||
| 9 | // modèle | ||
| 10 | $texte = file_get_contents('data/' . $page . '/html/' . $nom_article . '.html'); | ||
| 11 | |||
| 12 | $texte = trim(addcslashes($texte, "'")); // échapper les simples quotes pour javascript | ||
| 13 | //$texte = trim(addslashes($texte)); // échappe ', ", \ et NULL, je sais pas si c'est bien | ||
| 14 | } | ||
| 15 | |||
| 16 | // vue | ||
| 17 | require $ckeditor_integration . 'view.php'; // html + JS | ||
| 18 | $contenu = $editeurHTML; | ||
diff --git a/src/integration/ckeditor5/image_upload.php b/src/integration/ckeditor5/image_upload.php index 6cbc911..5764569 100644 --- a/src/integration/ckeditor5/image_upload.php +++ b/src/integration/ckeditor5/image_upload.php | |||
| @@ -1,27 +1,17 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/integration/ckeditor5/image_upload.php | 2 | // src/integration/ckeditor5/image_upload.php |
| 3 | 3 | ||
| 4 | // script récupérant les images téléchargée en AJAX par l'éditeur et c'est tout | ||
| 5 | // on récupère les données, on renvoie au navigateur la réponse qu'il attend et stop! | ||
| 6 | |||
| 7 | // le "simple upload adapter" envoie un POST appelé: $_FILES['upload'] | 4 | // le "simple upload adapter" envoie un POST appelé: $_FILES['upload'] |
| 8 | // en retour il attend impérativement des données au format JSON du genre: {"url": "data/page/images/monfichier.jpg"} | 5 | // en retour il attend impérativement des données au format JSON du genre: {"url": "data/page/images/monfichier.jpg"} |
| 9 | // cette adresse doit permettre à l'éditeur de télécharger l'image afficher de manière normale: <img scr="data/page/images/monfichier.jpg"> | 6 | // cette adresse doit permettre à l'éditeur de télécharger l'image afficher de manière normale: <img scr="data/page/images/monfichier.jpg"> |
| 10 | 7 | ||
| 11 | // pour voir cette réponse, les messages d'erreur ou tout affichage avec echo ou var_dump: | ||
| 12 | // outils de développement (F12) => réseau => trouver la requête (xhr) => cliquer dessus puis sur réponse | ||
| 13 | |||
| 14 | // rappel: le téléchargement de fichier avec PHP nécessite un dossier temporaire et que le serveur y soit autorisé en écriture | ||
| 15 | |||
| 16 | |||
| 17 | $erreur = ''; | 8 | $erreur = ''; |
| 18 | if($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['upload']) | 9 | if($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['upload']) |
| 19 | && strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== false // simple upload adapter envoie "des form-data" | 10 | && strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== false) // le "simple upload adapter" envoie des "form-data" |
| 20 | && isset($_GET['action']) && $_GET['action'] === 'upload_image') // image insérée dans l'éditeur => requête AJAX | ||
| 21 | { | 11 | { |
| 22 | if($_FILES['upload']['error'] == 0) // 0 signifie ok | 12 | if($_FILES['upload']['error'] == 0) // 0 signifie ok |
| 23 | { | 13 | { |
| 24 | if($_FILES['upload']['size'] <= $php_ini_max_size ) | 14 | if($_FILES['upload']['size'] <= $this->php_ini_max_size) |
| 25 | { | 15 | { |
| 26 | $infos = pathinfo ($_FILES['upload']['name']); | 16 | $infos = pathinfo ($_FILES['upload']['name']); |
| 27 | $extension = $infos['extension']; | 17 | $extension = $infos['extension']; |
| @@ -29,8 +19,8 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['upload']) | |||
| 29 | // on prend la même liste que celle côté javascript, le SVG est bloqué pour raison de sécurité (javascript à l'intérieur) | 19 | // on prend la même liste que celle côté javascript, le SVG est bloqué pour raison de sécurité (javascript à l'intérieur) |
| 30 | if(in_array($extension, $extautorisées)) | 20 | if(in_array($extension, $extautorisées)) |
| 31 | { | 21 | { |
| 32 | move_uploaded_file ($_FILES['upload']['tmp_name'], 'data/' . $page . '/images/' . $_FILES['upload']['name']); | 22 | move_uploaded_file ($_FILES['upload']['tmp_name'], $this->data_path . '/images/' . $_FILES['upload']['name']); |
| 33 | chmod('data/' . $page . '/images/' . $_FILES['upload']['name'], 0666); | 23 | chmod($this->data_path . '/images/' . $_FILES['upload']['name'], 0666); |
| 34 | } | 24 | } |
| 35 | else | 25 | else |
| 36 | { | 26 | { |
| @@ -49,14 +39,17 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['upload']) | |||
| 49 | 39 | ||
| 50 | if(empty($erreur)) | 40 | if(empty($erreur)) |
| 51 | { | 41 | { |
| 52 | $chemin = '{"url": "data/' . $page . '/images/' . $_FILES['upload']['name'] . '"}'; | 42 | $chemin = '{"url": "' . $this->data_path . '/images/' . $_FILES['upload']['name'] . '"}'; |
| 53 | echo $chemin; | 43 | echo $chemin; |
| 54 | } | 44 | } |
| 55 | else | 45 | else |
| 56 | { | 46 | { |
| 57 | echo $erreur; | 47 | echo $erreur; |
| 58 | } | 48 | } |
| 59 | die; | 49 | } |
| 50 | else | ||
| 51 | { | ||
| 52 | echo "erreur: téléchargement non identifié"; | ||
| 60 | } | 53 | } |
| 61 | 54 | ||
| 62 | /* les erreurs retournées avec $_FILES['upload']['error']: | 55 | /* les erreurs retournées avec $_FILES['upload']['error']: |
diff --git a/src/integration/ckeditor5/init.php b/src/integration/ckeditor5/init.php deleted file mode 100644 index 30e5fb9..0000000 --- a/src/integration/ckeditor5/init.php +++ /dev/null | |||
| @@ -1,23 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | // src/integration/ckeditor5/init.php | ||
| 3 | |||
| 4 | // lien symbolique des traductions | ||
| 5 | function makeTranslationSymLink(): void | ||
| 6 | { | ||
| 7 | $target = '../translations'; | ||
| 8 | $link = 'node_modules/ckeditor5/dist/browser/translations'; | ||
| 9 | |||
| 10 | if(!file_exists($link)) | ||
| 11 | { | ||
| 12 | if(PHP_OS === 'Linux') | ||
| 13 | { | ||
| 14 | symlink($target, $link); | ||
| 15 | } | ||
| 16 | elseif(PHP_OS === 'WINNT') | ||
| 17 | { | ||
| 18 | // on peut créer une jointure sans droit d'admin | ||
| 19 | $target = 'node_modules\ckeditor5\dist\translations'; | ||
| 20 | exec('mklink /J ' . str_replace('/', '\\', $link) . ' ' . $target); | ||
| 21 | } | ||
| 22 | } | ||
| 23 | } | ||
diff --git a/src/integration/ckeditor5/view.php b/src/integration/ckeditor5/view.php index b5cf5cc..ed1d0f7 100644 --- a/src/integration/ckeditor5/view.php +++ b/src/integration/ckeditor5/view.php | |||
| @@ -1,22 +1,19 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/integration/ckeditor5/view.php | 2 | // src/integration/ckeditor5/view.php |
| 3 | 3 | ||
| 4 | //$css_editeur = '<link rel="stylesheet" href="node_modules/ckeditor5/dist/ckeditor5.css" />'; // version normale aérée et commentée | ||
| 5 | $css_editeur = '<link rel="stylesheet" href="node_modules/ckeditor5/dist/browser/ckeditor5.css" />'; // version "minifiée" | ||
| 6 | |||
| 7 | ob_start(); | 4 | ob_start(); |
| 8 | ?> | 5 | ?> |
| 9 | <div class="conteneur_article" > | 6 | <div class="conteneur_article" > |
| 10 | <form action="<?= $form_action_file ?>" method="POST" enctype="multipart/form-data" > | 7 | <form action="<?= $this->form_action_file ?>" method="POST" enctype="multipart/form-data" > |
| 11 | <textarea id="editor" name="contenu" ></textarea> | 8 | <textarea id="editor" name="contenu" ></textarea> |
| 12 | <input class="boutonSubmitEditeur" type="submit" value="Valider"> | 9 | <input class="boutonSubmitEditeur" type="submit" value="Valider"> |
| 13 | <a class="boutonAnnuler" href="<?= $previous_page ?>" > | 10 | <a class="boutonAnnuler" href="<?= $this->from ?>" > |
| 14 | <input type="button" value="Annuler"></a> | 11 | <input type="button" value="Annuler"></a> |
| 15 | <script type="importmap"> | 12 | <script type="importmap"> |
| 16 | { | 13 | { |
| 17 | "imports": { | 14 | "imports": { |
| 18 | "ckeditor5": "http://<?= $server_root ?>node_modules/ckeditor5/dist/browser/ckeditor5.js", | 15 | "ckeditor5": "http://<?= $this->server_root ?>node_modules/ckeditor5/dist/browser/ckeditor5.js", |
| 19 | "ckeditor5/": "http://<?= $server_root ?>node_modules/ckeditor5/dist/browser/" | 16 | "ckeditor5/": "http://<?= $this->server_root ?>node_modules/ckeditor5/dist/browser/" |
| 20 | } | 17 | } |
| 21 | } | 18 | } |
| 22 | </script> | 19 | </script> |
| @@ -29,7 +26,7 @@ ob_start(); | |||
| 29 | Link, Table, TableColumnResize, TableToolbar, TableProperties, TableCellProperties, TextPartLanguage | 26 | Link, Table, TableColumnResize, TableToolbar, TableProperties, TableCellProperties, TextPartLanguage |
| 30 | } from "ckeditor5"; | 27 | } from "ckeditor5"; |
| 31 | 28 | ||
| 32 | import coreTranslations from 'ckeditor5/translations/<?= $toolbar_language ?>.js'; | 29 | import coreTranslations from 'ckeditor5/translations/<?= $this->toolbar_language ?>.js'; |
| 33 | // n'utilise pas le bon chemin à cause d'un bug? solution = créer un lien symbolique à l'endroit attendu: | 30 | // n'utilise pas le bon chemin à cause d'un bug? solution = créer un lien symbolique à l'endroit attendu: |
| 34 | // ln -s /srv/http/ckeditor5/node_modules/ckeditor5/dist/translations /srv/http/ckeditor5/node_modules/ckeditor5/dist/browser/ | 31 | // ln -s /srv/http/ckeditor5/node_modules/ckeditor5/dist/translations /srv/http/ckeditor5/node_modules/ckeditor5/dist/browser/ |
| 35 | 32 | ||
| @@ -37,7 +34,7 @@ ob_start(); | |||
| 37 | 34 | ||
| 38 | let editor; | 35 | let editor; |
| 39 | let html_existant = '<?= $texte ?>'; // $texte doit avoir été sécurisé: simple quotes échappées au minimum | 36 | let html_existant = '<?= $texte ?>'; // $texte doit avoir été sécurisé: simple quotes échappées au minimum |
| 40 | let upload_url = '<?= $upload_ajax_url ?>'; | 37 | let upload_url = '<?= $this->upload_ajax_url ?>'; |
| 41 | 38 | ||
| 42 | // ATTENTION: si l'éditeur ne fonctionne pas, empêcher qu'on puisse cliquer sur Valider! | 39 | // ATTENTION: si l'éditeur ne fonctionne pas, empêcher qu'on puisse cliquer sur Valider! |
| 43 | // Il y a aussi des paramètres dans le fichier de config: ckeditor/webpack.config.js | 40 | // Il y a aussi des paramètres dans le fichier de config: ckeditor/webpack.config.js |
| @@ -70,7 +67,7 @@ ob_start(); | |||
| 70 | shouldNotGroupWhenFull: true | 67 | shouldNotGroupWhenFull: true |
| 71 | }, | 68 | }, |
| 72 | 69 | ||
| 73 | language: '<?= $toolbar_language ?>', | 70 | language: '<?= $this->toolbar_language ?>', |
| 74 | translations: [coreTranslations], | 71 | translations: [coreTranslations], |
| 75 | 72 | ||
| 76 | // barre d'outils dans une image | 73 | // barre d'outils dans une image |
diff --git a/src/view/templates/page.php b/src/view/templates/page.php index 3153ced..5051a5f 100644 --- a/src/view/templates/page.php +++ b/src/view/templates/page.php | |||
| @@ -4,12 +4,12 @@ | |||
| 4 | <meta charset="utf-8"> | 4 | <meta charset="utf-8"> |
| 5 | <title></title> | 5 | <title></title> |
| 6 | <link rel="icon" type="image/png" href=""> | 6 | <link rel="icon" type="image/png" href=""> |
| 7 | <?= $css_hors_editeur ?> | 7 | <?= $ckeditor->css_outside_editor_tag ?> |
| 8 | <?= $css_editeur ?> | 8 | <?= $ckeditor->css_editor_tag ?> |
| 9 | </head> | 9 | </head> |
| 10 | <body> | 10 | <body> |
| 11 | <div> | 11 | <div> |
| 12 | <?= $contenu ?> | 12 | <?= $editeurHTML ?> |
| 13 | </div> | 13 | </div> |
| 14 | </body> | 14 | </body> |
| 15 | </html> | 15 | </html> |
