對於自訂元件,您可以自訂「網站產生器」工具列中顯示的內建工具列群組複本。
您可以對具有限制集且可使用自訂標記的內建元件,建立自己的元件版本。任何自訂內容都不會影響內建元件。
您可以對具有限制集且可使用自訂標記的內建元件,建立自己的元件版本,這樣做並不會影響任何內建元件。
工具列群組定義當您按一下「標題」或「段落」元件來進行編輯時,您在工具列中看到的內容。您可以移除或重新排列「標題」或「段落」元件支援的內容,但不允許您新增 Plug-in。
若要自訂「網站產生器」中的工具列群組,您必須使用與 CKEditor 用於 toolbarGroups 組態的相同語法。請參閱 https://ckeditor.com/latest/samples/toolbarconfigurator/index.html#basic。
"basicstyles" - 限制為粗體/斜體/底線 https://ckeditor.com/cke4/addon/basicstyles
"styles" - 字型樣式 https://docs.ckeditor.com/ckeditor4/latest/guide/dev_styles.html
"colors" - 文字和背景色彩 https://docs.ckeditor.com/ckeditor4/latest/guide/dev_colorbutton.html
"undo" - 還原/重做 CKEditor 中目前的執行處理
"links" - 連結自訂 Plugin 對話方塊
"paragraph" - 項目符號/編號清單與縮排支援
"list"
"indent"
"align" - 靠左/靠右/置中
"cleanup" - 移除所選文字的全部樣式
「段落」元件也支援影像和表格插入 Plug-in:
"insert"
"image"
"table"
此外,還可以使用資料列區隔符號項目:
"/"
註:
若您在工具列群組組態中設定任何其他值,該值會在「網站產生器」工具列建立之前先被移除。您不能提供 "extraPlugins"。僅支援 "name"/"groups" 組態。所有 "items" 項目都會被忽略。例如,如果您想要防止使用者定義字型、色彩、樣式或大小,可以依下列方式更新工具列組態。對於 "id" 值,您必須指定與內建值不同的自訂值。
[{ "name": "<category name>", "list": [{ "type": "scs-title", "id": "<custom-value>", "config": { "toolbarGroups": [{ "name": "basicstyles", "groups": ["basicstyles"] }, { "name": "undo", "groups": ["undo"] }, "/", { "name": "links", "groups": ["links"] }, { "name": "paragraph", "groups": ["list", "indent"] }, "/", { "name": "align", "groups": ["align"] }, { "name": "insert", "groups": ["image", "table"] }, { "name": "cleanup", "groups": ["cleanup"] } ] } }, { "type": "scs-paragraph", "id": "<custom-value>", "config": { "fontSize_sizes": "16/16px;24/24px;48/48px;" } }] }]
驗證
以上述程式碼取代您的 components.json
檔案,然後編輯您的網站 (如果正在編輯,請重新整理瀏覽器)。此時,當您編輯「標題」元件時,它將不再顯示可供選取的字型樣式或色彩。「段落」元件則會繼續顯示這些項目,而可用的字型大小清單將會限制為 16、24 及 48。
預設工具列群組
「標題」與「段落」的預設工具列群組如下:
標題
[{ "name": "basicstyles", "groups": ["basicstyles"] }, { "name": "styles", "groups": ["styles"] }, { "name": "colors", "groups": ["colors"] }, { "name": "undo", "groups": ["undo"] }, "/", { "name": "links", "groups": ["links"] }, { "name": "paragraph", "groups": ["list", "indent"] }, { "name": "align", "groups": ["align"] }, { "name": "cleanup", "groups": ["cleanup"] } ]
段落
[{ "name": "basicstyles", "groups": ["basicstyles"] }, { "name": "styles", "groups": ["styles"] }, { "name": "colors", "groups": ["colors"] }, { "name": "undo", "groups": ["undo"] }, "/", { "name": "links", "groups": ["links"] }, { "name": "paragraph", "groups": ["list", "indent"] }, { "name": "align", "groups": ["align"] }, { "name": "insert", "groups": ["image", "table"] }, { "name": "cleanup", "groups": ["cleanup"] } ]