Skip to content

[JSライブラリ][WYSIWYG][テーマ管理] TinyMCEを6→7へアップデート OW-2523 #2190

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 1 commit into from
May 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions app/Plugins/Manage/ThemeManage/ThemeManage.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function declareRole()
$role_ckeck_table["create"] = array('admin_site');
$role_ckeck_table["editCss"] = array('admin_site');
$role_ckeck_table["saveCss"] = array('admin_site');
$role_ckeck_table["editTemplate"] = array('admin_site');
// $role_ckeck_table["editTemplate"] = array('admin_site');
$role_ckeck_table["saveTemplate"] = array('admin_site');
$role_ckeck_table["editJs"] = array('admin_site');
$role_ckeck_table["saveJs"] = array('admin_site');
Expand Down Expand Up @@ -386,13 +386,15 @@ public function saveCss($request, $id)
]);
}

// delete: tinymce7対応. template はTinyMCE 7.xのオープンソース版から削除されてPremium版に移りました
/**
* テンプレート編集画面
*
* @method_title テンプレート編集
* @method_desc ユーザ・テーマ毎のテンプレートを画面で編集できます。
* @method_detail 保存したテンプレートは選択したテーマで反映されます。
* method_title テンプレート編集
* method_desc ユーザ・テーマ毎のテンプレートを画面で編集できます。
* method_detail 保存したテンプレートは選択したテーマで反映されます。
*/
/*
public function editTemplate($request, $id)
{
// httpメソッド確認
Expand Down Expand Up @@ -426,6 +428,7 @@ public function editTemplate($request, $id)
"template" => $template,
]);
}
*/

/**
* テンプレート保存画面
Expand Down
40 changes: 20 additions & 20 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"sass": "^1.62.1",
"sass-loader": "^12.6.0",
"sortablejs": "^1.15.2",
"tinymce": "^6.8.5",
"tinymce": "^7.8.0",
"vue": "^3.5.13",
"vue-loader": "^17.3.0"
}
Expand Down
2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/js/app.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

/*! #__NO_SIDE_EFFECTS__ */

/*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */

/*! Axios v1.9.0 Copyright (c) 2025 Matt Zabriskie and contributors */

/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
Expand Down
2 changes: 1 addition & 1 deletion public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/js/app.js": "/js/app.js?id=4b33b4976170adce391d1d910fc9d34f",
"/js/app.js": "/js/app.js?id=39c1043952d314598bdcb00c1817d397",
"/css/app.css": "/css/app.css?id=94110667e125790f9646ca8f0c9d2382"
}
6 changes: 3 additions & 3 deletions resources/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ dayjs.extend(timezone);
window.dayjs = dayjs;

// --- TinyMCE
// 「Example src/editor.js」よりコピーして編集: https://www.tiny.cloud/docs/tinymce/6/vite-es6-npm/#procedures
// 「Example src/editor.js」よりコピーして編集: https://www.tiny.cloud/docs/tinymce/latest/vite-es6-npm/#procedures
/* Import TinyMCE */
import tinymce from 'tinymce';
window.tinymce = tinymce;
Expand All @@ -109,7 +109,8 @@ import 'tinymce/models/dom';
import 'tinymce/skins/ui/oxide/skin.js';

/* Import plugins */
// delete: imagetools はTinyMCE 6.0のオープンソース版で削除されました
// delete: imagetools はTinyMCE 6.xのオープンソース版から削除されてPremium版に移りました
// delete: template はTinyMCE 7.xのオープンソース版から削除されてPremium版に移りました
import 'tinymce/plugins/advlist';
import 'tinymce/plugins/code';
import 'tinymce/plugins/link';
Expand All @@ -118,7 +119,6 @@ import 'tinymce/plugins/table';
import 'tinymce/plugins/media';
import 'tinymce/plugins/autolink';
import 'tinymce/plugins/preview';
import 'tinymce/plugins/template';

/* Import plugins(Connect-CMS Custom)
コピー元Path: node_modules/tinymce/plugins/image/plugin.js */
Expand Down
2 changes: 1 addition & 1 deletion resources/js/tinymce/langs/ja.js

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions resources/js/tinymce/plugins/image/plugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* TinyMCE version 6.8.5 (TBD)
* TinyMCE version 7.8.0 (TBD)
*/

(function () {
Expand Down Expand Up @@ -322,24 +322,23 @@
const getImageSize = url => new Promise(callback => {
const img = document.createElement('img');
const done = dimensions => {
img.onload = img.onerror = null;
if (img.parentNode) {
img.parentNode.removeChild(img);
}
callback(dimensions);
};
img.onload = () => {
img.addEventListener('load', () => {
const width = parseIntAndGetMax(img.width, img.clientWidth);
const height = parseIntAndGetMax(img.height, img.clientHeight);
const dimensions = {
width,
height
};
done(Promise.resolve(dimensions));
};
img.onerror = () => {
});
img.addEventListener('error', () => {
done(Promise.reject(`Failed to get image dimensions for: ${ url }`));
};
});
const style = img.style;
style.visibility = 'hidden';
style.position = 'fixed';
Expand Down Expand Up @@ -742,6 +741,7 @@
write(css => normalizeCss$1(editor, css), data, image);
syncSrcAttr(editor, image);
if (isFigure(image.parentNode)) {
editor.dom.setStyle(image, 'float', '');
const figure = image.parentNode;
splitTextBlock(editor, figure);
editor.selection.select(image.parentNode);
Expand Down Expand Up @@ -1321,6 +1321,7 @@
});
api.showTab('general');
changeSrc(helpers, info, state, api);
api.focus('src');
};
blobToDataUri(file).then(dataUrl => {
const blobInfo = helpers.createBlobCache(file, blobUri, dataUrl);
Expand All @@ -1330,7 +1331,9 @@
finalize();
}).catch(err => {
finalize();
helpers.alertErr(err);
helpers.alertErr(err, () => {
api.focus('fileinput');
});
});
} else {
helpers.addToBlobCache(blobInfo);
Expand Down Expand Up @@ -1413,8 +1416,8 @@
const addToBlobCache = editor => blobInfo => {
editor.editorUpload.blobCache.add(blobInfo);
};
const alertErr = editor => message => {
editor.windowManager.alert(message);
const alertErr = editor => (message, callback) => {
editor.windowManager.alert(message, callback);
};
const normalizeCss = editor => cssText => normalizeCss$1(editor, cssText);
const parseStyle = editor => cssText => editor.dom.parseStyle(cssText);
Expand Down
35 changes: 9 additions & 26 deletions resources/views/plugins/common/wysiwyg.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,6 @@
$advlist_number_lists_file = File::get($advlist_number_lists_default_path);
}

// テーマ固有 簡易テンプレート
$templates_file = '';
$templates_path = public_path() . '/themes/' . $theme . '/wysiwyg/templates.txt';
$templates_group_default_path = public_path() . '/themes/' . $theme_group_default . '/wysiwyg/templates.txt';
$templates_default_path = public_path() . '/themes/Defaults/Default/wysiwyg/templates.txt';
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);
}

// TinyMCE Body クラス
$body_class = '';
if ($frame->area_id == 0) {
Expand All @@ -180,7 +165,8 @@
// change: tinymce5対応. textcolor は coreに含まれたため除外
// change: tinymce6対応. imagetools は オープンソース版から削除のため除外
// change: tinymce6対応. hr は coreに含まれたため除外
$plugins = 'file image media link autolink preview code table lists advlist template ';
// change: tinymce7対応. template は オープンソース版から削除のため除外
$plugins = 'file image media link autolink preview code table lists advlist ';
if (Configs::getConfigsValue($cc_configs, 'use_translate', UseType::not_use) == UseType::use) {
$plugins .= ' translate';
}
Expand All @@ -203,11 +189,6 @@
// toolbar
$toolbar = "undo redo | bold italic underline strikethrough subscript superscript {$toolbar_fontsizeselect} | styles | forecolor backcolor | removeformat | table hr | numlist bullist | blockquote | alignleft aligncenter alignright alignjustify | outdent indent | link | image file media | preview | code";
$mobile_toolbar = "undo redo | image file media | link | code | bold italic underline strikethrough subscript superscript {$toolbar_fontsizeselect} | styles | forecolor backcolor | removeformat | table hr | numlist bullist | blockquote | alignleft aligncenter alignright alignjustify | outdent indent | preview";
// 簡易テンプレート設定がない場合、テンプレート挿入ボタン押下でエラー出るため、設定ない場合はボタン表示しない。
if (! empty($templates_file)) {
$toolbar .= '| template ';
$mobile_toolbar .= '| template ';
}
// いずれかの外部サービスONの場合、頭に区切り文字 | を追加する
if (Configs::getConfigsValue($cc_configs, 'use_translate', UseType::not_use) == UseType::use || Configs::getConfigsValue($cc_configs, 'use_pdf_thumbnail')) {
$toolbar .= ' | ';
Expand Down Expand Up @@ -269,11 +250,16 @@
selector : 'textarea',
@endif

cache_suffix: '?v=6.1',
cache_suffix: '?v=7.1',

// add: tinymce6対応. www.tiny.cloudのPRリンク表示OFF
// see) https://www.tiny.cloud/docs/tinymce/latest/promotions/
promotion: false,

// add: tinymce7対応. ライセンスの設定
// see) https://www.tiny.cloud/docs/tinymce/latest/license-key/
license_key: 'gpl',

// change: app.blade.phpと同様にlocaleを見て切替
language : '{{ app()->getLocale() }}',

Expand Down Expand Up @@ -312,9 +298,6 @@
{{-- テーマ固有 番号箇条書きリスト(OLタグ)の表示設定 --}}
{!!$advlist_number_lists_file!!}

{{-- テーマ固有 簡易テンプレート設定 --}}
{!!$templates_file!!}

formats: {
// bugfix: bootstrap4のblockquoteはclassに'blockquote'付ける
blockquote: { block: 'blockquote', classes: 'blockquote' }
Expand All @@ -333,7 +316,7 @@
},

relative_urls : false,
height: {{ isset($height) ? $height : 300 }},
height: {{ isset($height) ? $height : 400 }},
resize: 'both',
branding: false,
valid_children : "+body[style|input],+a[div|p],",
Expand Down
3 changes: 2 additions & 1 deletion resources/views/plugins/manage/theme/theme.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ function view_list_images(dir_name)
<a href="javascript:view_css_edit('{{$dir['dir']}}');" id="css_edit_{{$loop->iteration}}">[CSS編集]</a>
<a href="javascript:view_js_edit('{{$dir['dir']}}');" id="js_edit_{{$loop->iteration}}">[JavaScript編集]</a>
<a href="javascript:view_list_images('{{$dir['dir']}}');" id="image_edit_{{$loop->iteration}}">[画像管理]</a>
<a href="javascript:view_template_edit('{{$dir['dir']}}');" id="template_edit_{{$loop->iteration}}">[テンプレート編集]</a>
{{-- delete: tinymce7対応. template はTinyMCE 7.xのオープンソース版から削除されてPremium版に移りました
<a href="javascript:view_template_edit('{{$dir['dir']}}');" id="template_edit_{{$loop->iteration}}">[テンプレート編集]</a> --}}
<a href="javascript:view_name_edit('{{$dir['dir']}}');" id="name_edit_{{$loop->iteration}}">[テーマ編集]</a>
</li>
@endforeach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@
<span class="nav-link"><span class="active">画像管理</span></span>
</li>
@endif
{{-- delete: tinymce7対応. template はTinyMCE 7.xのオープンソース版から削除されてPremium版に移りました
@if ($function == "editTemplate")
<li role="presentation" class="nav-item">
<span class="nav-link"><span class="active">テンプレート編集</span></span>
</li>
@endif
@endif --}}
@if ($function == "editName")
<li role="presentation" class="nav-item">
<span class="nav-link"><span class="active">テーマ名編集</span></span>
Expand Down