有個項目用ckeditor富文本插件了,客戶要有首行縮進按鈕,
最開始用的官網上的document模式,這個模式從work直接拷貝過來的格式很友好,但我們的項目居然用了
*{ margin: 0; padding: 0; box-sizing: border-box; }
這個東西去除樣式,這會導致ol,li等縮進都沒有,改這個東西太麻煩了,用回了article模式
這個模式縮進是給<p>標簽加‘margin-left: 40px;’
這樣會導致整段文字都縮進,用戶體驗很不友好
查了網上的資料,把模板改成 'text-indent: 2em;' 就可以了。
下邊貼下那位仁兄的博客,我這邊也轉載記錄下
https://blog.csdn.net/qq_36303853/article/details/114670864
1.打開ckeditor.js文件,使用ctrl+f進行搜索。
d.config.indentOffset||40 將40修改為2 d.config.indentUnit||"px" 將px修改為em b.getComputedStyle("direction"))?"margin-left":"margin-right"} 將"margin-left":"margin-right"修改為"text-indent":"text-indent"
2.他說還要關閉過濾器,這個沒試驗,我反正是加上了
ckeditor/config.js 配置文件中修改
config.allowedContent = true;
清除緩存,完美解決