Skip to content

[TinyMCE] [テーマ管理:テンプレート編集] カスタムプラグイン「テンプレートの挿入」追加&テーマ管理のテンプレート登録機能を復活 #2199

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
May 23, 2025

Conversation

masaton0216
Copy link
Contributor

@masaton0216 masaton0216 commented May 22, 2025

概要

  • 本PRでは、#2190 で一度削除された「テンプレートの挿入」機能を、TinyMCEのカスタムプラグインとして再開発・追加しました。
  • また、テーマ管理画面のテンプレート登録機能も復活させています。

主な変更点

  • (TinyMCE)カスタムプラグイン「テンプレートの挿入」を新規開発
  • (テーマ管理)テンプレートの登録機能を復活&注釈の追記

補足

  • テンプレートの登録内容はテキストファイル(templates.txt)で管理されます。

レビュー完了希望日

5/29(木)

関連Pull requests/Issues

#2190

参考

イメージ1(ウィジウィグのツールバー)

image

イメージ2(ダイアログ画面)

image

DB変更の有無

なし

チェックリスト

@masaton0216 masaton0216 requested a review from gakigaki May 22, 2025 05:54
@masaton0216 masaton0216 self-assigned this May 22, 2025
@masaton0216 masaton0216 marked this pull request as ready for review May 22, 2025 06:05
@masaton0216
Copy link
Contributor Author

@gakigaki レビューお願いします。

Copy link
Contributor

@gakigaki gakigaki left a comment

Choose a reason for hiding this comment

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

ご対応ありがとうございます!
ご確認お願いします。

tinymce.PluginManager.add('cc_template', function(editor, url) {
// アイコン定義 see) https://fontawesome.com/search?q=stamp&o=r ※svgコードそのままコピペでは表示されない為、widthとheightを指定
editor.ui.registry.addIcon(
'clone',
Copy link
Contributor

Choose a reason for hiding this comment

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

editor.ui.registry.addIcon()は使わないで、editor.ui.registry.addButton()のiconに 'template' を指定する方がいいかもしれません。

editor.ui.registry.addButton('cc_template', {
      icon: 'template',
      tooltip: 'テンプレートの挿入',
     .......
}

addIcon()はTinyMCEのicon群に使いたいものがないときのカスタム用の関数のようです。
template用のiconは用意されているので、そちらを使っていいのではないかと思いました。
https://www.tiny.cloud/docs/tinymce/latest/editor-icon-identifiers/

TinyMCEのアイコンに変更すると、以下画像のようになります。
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

なるほど、ありがとうございます。
このドキュメントは見落としてました。

const template = templates[selected_idx] || {};
preview.innerHTML = `
<div>
<div>${template.description || ''}</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

説明とコンテンツの区切りがあると見やすように感じました。
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

賛成です。下記のようにしてみました。
image

Comment on lines +152 to +160
if (File::exists($templates_path)) {
$templates_file = File::get($templates_path);
}
else if (File::exists($templates_group_default_path)) {
$templates_file = File::get($templates_group_default_path);
}
else if (File::exists($templates_default_path)) {
$templates_file = File::get($templates_default_path);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

改行の仕方がコード規約違反ですが、他の個所もこうなっていましたね。
ここだけ直すかはお任せします!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bladeは上手く動作しないのかな?
ツールでポンなら直したかったけど、全部で22カ所あったので今回は見送ります。
指摘ありがとうございます。

> ./vendor/bin/phpcbf --standard=phpcs.xml C:\sites\connect_cms_php_8030\htdocs\resources\views\plugins\common\wysiwyg.blade.php
PHP Warning:  Module "openssl" is already loaded in Unknown on line 0

Warning: Module "openssl" is already loaded in Unknown on line 0



No violations were found

Time: 103ms; Memory: 10MB

@masaton0216
Copy link
Contributor Author

@gakigaki 確認ありがとうございます!再レビューおねしゃす!

@gakigaki gakigaki merged commit af4d495 into master May 23, 2025
1 check passed
@gakigaki
Copy link
Contributor

修正ありがとうございました!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants