[英]Add suneditor css file with symfony webpack-encore
I'm trying to ad suneditor
to a symfony
project using webpak-encore
, I have created a js file我正在尝试使用
webpak-encore
将suneditor
到symfony
项目,我创建了一个 js 文件
htmlEditor.js
with this code使用此代码
import SUNEDITOR from 'suneditor'
import 'suneditor/dist/css/suneditor.min.css'
import plugins from 'suneditor/src/plugins'
const editor = SUNEDITOR.create((document.getElementById('appbundle_popup_description') || 'appbundle_popup_description'),{
// All of the plugins are loaded in the "window.SUNEDITOR" object in dist/suneditor.min.js file
// Insert options
// Language global object (default: en)
//lang: SUNEDITOR_LANG['en'],
height: 400,
plugins: plugins,
buttonList: [
['undo', 'redo'],
['font', 'fontSize', 'formatBlock'],
['paragraphStyle', 'blockquote'],
['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
['fontColor', 'hiliteColor', 'textStyle'],
['removeFormat'],
'/', // Line break
['outdent', 'indent'],
['align', 'horizontalRule', 'list', 'lineHeight'],
['table', 'link', 'image', 'video', 'audio' /** ,'math' */], // You must add the 'katex' library at options to use the 'math' plugin.
/** ['imageGallery'] */ // You must add the "imageGalleryUrl".
['fullScreen', 'showBlocks', 'codeView'],
['preview', 'print'],
['save', 'template']
]
});
then I've included an entry in webpack.config.js
然后我在
webpack.config.js
中包含了一个条目
.addEntry('htmlEditor', './assets/js/htmlEditor.js')
and I've included the files at the view file我已经将文件包含在视图文件中
{% block stylesheets %}
{{ parent() }}
{{ encore_entry_link_tags('htmlEditor') }}
{% endblock %}
{% block javascripts %}
{{ parent() }}
{{ encore_entry_script_tags('htmlEditor') }}
{% endblock %}
and then the js file ins included but not the css file, how can I include the css file?然后包含js文件但不包含css文件,如何包含css文件?
I have the same problem.我也有同样的问题。 I have a solution for waiting a better solution.
我有一个解决方案等待更好的解决方案。 Invcude the CDN in your html after the block javascript in your html head
<link href="https://cdn.jsdelivr.net/npm/suneditor@latest/dist/css/suneditor.min.css" rel="stylesheet">
在您的 html 中的块 javascript 之后在您的
<link href="https://cdn.jsdelivr.net/npm/suneditor@latest/dist/css/suneditor.min.css" rel="stylesheet">
中引入 CDN <link href="https://cdn.jsdelivr.net/npm/suneditor@latest/dist/css/suneditor.min.css" rel="stylesheet">
Better solution copy the files suneditor/src/assets/css/suneditor-contents.css
for the editing part and suneditor/src/assets/css/suneditor.css
for your view After import in your app.js import '../assets/suneditor-contents.css'
and for your back import '../assets/suneditor.css'更好的解决方案复制文件
suneditor/src/assets/css/suneditor-contents.css
用于编辑部分和suneditor/src/assets/css/suneditor.css
用于您import '../assets/suneditor-contents.css'
视图import '../assets/suneditor-contents.css'
并在后面导入 '../assets/suneditor.css'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.