Skip to content

[WYSIWYG]TinyMCEの画像編集機能(imagetools)代替としてToast UI Image Editorを導入しました #2204

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 5 commits into from
Jun 3, 2025

Conversation

gakigaki
Copy link
Contributor

@gakigaki gakigaki commented May 29, 2025

概要

WYSIWYGエディタに、オープンソースの画像編集ライブラリであるToast UI Image Editorを導入し、高機能な画像編集機能を追加しました。

変更の目的

TinyMCE6において、従来提供されていた画像編集機能(imagetools)がオープンソースとして公開されなくなりました。
この変更は、Connect-CMSにおいて同等の画像編集機能を提供することを目的としています。

変更内容

オープンソースの「Toast UI Image Editor」をWYSIWYGエディタに組み込みました。
これにより、以下の主要な画像編集機能が利用可能になります。

  • リサイズ、回転、反転、切り抜き
  • 描画(線、図形、テキスト)
  • フィルター(グレースケール、セピア、ぼかし等)
  • アイコンやマスク画像の追加
  • 明るさ、コントラスト、彩度の調整

テスト

以下の項目について、動作確認を実施しました。

  • Toast UI Image Editorの各編集機能(リサイズ、回転、描画、フィルターなど、上記「変更内容」に記載の利用可能な機能)が正常に動作すること。
  • 編集後の画像が、Connect-CMSの既存の仕組みを通じて正しく保存され、エディタおよびコンテンツに反映されること。

レビュー完了希望日

6/7

関連Pull requests/Issues

参考

DB変更の有無

無し

チェックリスト

OW-2572

@gakigaki gakigaki requested a review from masaton0216 May 29, 2025 08:50
@gakigaki gakigaki marked this pull request as ready for review May 29, 2025 08:52
Copy link
Contributor

@masaton0216 masaton0216 left a comment

Choose a reason for hiding this comment

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

対応お疲れ様でした。
4点ありますので確認お願いします。

}

const imageUrl = selectedNode.getAttribute('src');
const imageFileName = selectedNode.getAttribute('alt') || 'edited_image.png'; // ファイル名に拡張子を含めると良いでしょう
Copy link
Contributor

Choose a reason for hiding this comment

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

処理解説に資さないAIのサジェストコメントは除去しといてください。

@@ -0,0 +1,233 @@
import { locale_ja_JP } from './locale_ja_JP.js';
Copy link
Contributor

Choose a reason for hiding this comment

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

※指摘行数とは関係ないです。

困り事

そちらで再現しますか?
原因一緒かわからないけど、下記2環境で同操作でエラーになり、いずれもメッセージ違いです。

  • https://pre.osws.jp/tmp で適用ボタン押下でエラーになった。
  • ローカルでも適用ボタン押下でエラーになった。

再現手順

  1. 固定記事の編集ボタン押下
  2. 画像の挿入ボタン押下
  3. ファイルをブラウズボタン押下&画像を選択
  4. 保存ボタン押下
  5. (差し込まれた画像を選択)画像を編集ボタン押下
  6. そのまま適用ボタン押下

参考1(https://pre.osws.jp/tmp)

image

参考2(ローカル)

image

参考3(ローカルのlaravel-log)キャビネット等ではアップロードできるので書き込み権限ナシは考えづらい気がしている。「8.」って拡張子がちょん切れてるのは正常?

[2025-05-30 10:42:23] production.ERROR: fopen(C:\sites\connect_cms_php_8030_tcrp\htdocs\storage\app\uploads/1/8.): Failed to open stream: Permission denied {"userId":1,"exception":"[object] (ErrorException(code: 0): fopen(C:\\sites\\connect_cms_php_8030_tcrp\\htdocs\\storage\\app\\uploads/1/8.): Failed to open stream: Permission denied at C:\\sites\\connect_cms_php_8030_tcrp\\htdocs\\vendor\\league\\flysystem\\src\\Adapter\\Local.php:157)

参考4(UP対象の画像)

PXL_20250516_094526650

Copy link
Contributor Author

@gakigaki gakigaki May 30, 2025

Choose a reason for hiding this comment

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

報告ありがとうございます。それぞれ不具合の原因が違いました。

  • https://pre.osws.jp/tmp
    • 原因: ディレクトリインストールで画像アップロードのPOST先URLが正しく設定されない
    • 対応: アプリのルートからURLを指定する
  • masaton0216さんのローカル環境
    • 原因: (おそらく)拡張子なしでファイルが保存されるので、.(ドット)で終わるファイル名をWindowsが扱えない
    • 対応: 拡張子を含めたファイル名で保存する

Copy link
Contributor Author

Choose a reason for hiding this comment

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

どちらの環境でも問題ないように修正したと思います。
ご確認いただけますか?

return;
}

const imageUrl = selectedNode.getAttribute('src');
Copy link
Contributor

Choose a reason for hiding this comment

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

対象がない状態で画像編集エディタを開く必要はないと思うので、imageUrlが空や無効の場合のアーリーリターンを入れといてください。
再現例)下記タグで9のファイルをアップロード管理で削除

<p><img src="/file/9"></p>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

画像が取得できない場合にメッセージを表示して画像編集のダイアログを表示しないようにしました。


// FormDataを作成して画像データを追加
const formData = new FormData();
const fileName = selectedNode.getAttribute('alt') || `edited_image_${Date.now()}.png`;
Copy link
Contributor

Choose a reason for hiding this comment

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

altが設定されてないと拡張子pngで統一されちゃう?
オリジナルのファイル名や拡張子を継承した処理にできないかしら?

Copy link
Contributor Author

@gakigaki gakigaki May 30, 2025

Choose a reason for hiding this comment

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

mimeタイプから拡張子を取得するように修正しました。
おそらく透過画像が作られることから、元画像がJPGであってもPNG形式になるようです。

@gakigaki
Copy link
Contributor Author

@masaton0216
修正しました!ご確認お願い致します。

Copy link
Contributor

@masaton0216 masaton0216 left a comment

Choose a reason for hiding this comment

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

修正ありがとうございます。確認しました。
マージします。

@masaton0216 masaton0216 merged commit c1212cc into master Jun 3, 2025
1 check passed
@masaton0216 masaton0216 deleted the wysiwyg-image-editor branch June 3, 2025 01:20
@gakigaki gakigaki added developer update 開発者向けの更新 new feature labels Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer update 開発者向けの更新 new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants