当前位置:   article > 正文

vue3使用富文本编辑器 Editor.js_vue canvas-editor

vue canvas-editor

一、安装 Editor.js

npm i  @editorjs/editorjs --save 

 二、在页面中引入并使用

样式就不发了,自己按自己的来

三、转换语言,默认是英文

  1. editor = new EditorJS({
  2. holder: this.$refs.editor,
  3. // 自动聚焦
  4. autofocus: true,
  5. // 其他配置...
  6. tools: {
  7. },
  8. i18n: {
  9. messages: {
  10. ui: {
  11. blockTunes: {
  12. toggler: {
  13. 'Click to tune': '点击转换'
  14. }
  15. },
  16. inlineToolbar: {
  17. converter: {
  18. 'Convert to': '转换'
  19. }
  20. },
  21. toolbar: {
  22. toolbox: {
  23. Add: '工具栏添加'
  24. }
  25. },
  26. popover: {
  27. 'Filter': '过滤',
  28. 'Nothing found': '找不到',
  29. "Enter a code": "输入代码"
  30. }
  31. },
  32. toolNames: {
  33. "Text": "文本",
  34. "Heading": "标题",
  35. "List": "列表",
  36. "Warning": "警告",
  37. "Checklist": "清单",
  38. "Quote": "引用",
  39. "Code": "代码",
  40. "Delimiter": "分隔符",
  41. "Raw HTML": "原始 HTML",
  42. "Table": "表格",
  43. "Link": "链接",
  44. "Marker": "标记",
  45. "Bold": "粗体",
  46. "Italic": "斜体",
  47. "InlineCode": "内联代码",
  48. "Image": "图片"
  49. },
  50. tools: {
  51. "paragraph": {
  52. 'Press Tab': '输入内容',
  53. },
  54. "warning": { // <-- 'Warning' tool will accept this dictionary section
  55. "Title": "标题",
  56. "Message": "消息",
  57. },
  58. "link": {
  59. "Add a link": "添加连接"
  60. },
  61. "code": {
  62. "Enter a code": "输入代码"
  63. },
  64. "image": {
  65. "Add border": "添加边框",
  66. "With border": "有边框",
  67. "Stretch image": "拉伸图像",
  68. "With background": "有背景",
  69. "Add background": "添加背景"
  70. },
  71. "list": {
  72. "Ordered": "有序",
  73. "Unordered": "无序"
  74. }
  75. },
  76. blockTunes: {
  77. // Section allows to translate Block Tunes
  78. "delete": {
  79. "Delete": "删除",
  80. "Click to delete": "点击删除"
  81. },
  82. "moveUp": {
  83. "Move up": "上移"
  84. },
  85. "moveDown": {
  86. "Move down": "下移"
  87. }
  88. },
  89. }
  90. },
  91. });

四、标题

其余功能需自行安装,引入

npm install  @editorjs/header
import Header from '@editorjs/header';
  1. // 其他配置
  2. tools: {
  3. header: {
  4. class: Header,
  5. config: {
  6. placeholder: '输入标题',
  7. levels: [1, 2, 3, 4], // 可转换的标题
  8. defaultLevel: 1 // 默认标题
  9. }
  10. },
  11. }

 五、图片有两种,可拖拽上传处理

  1. 简单的图像(无后端要求)
  2. 图像

 

配置官网有具体文档,若不清楚请留言

Editor.jsFree block-style editor with a universal JSON outputicon-default.png?t=N7T8https://editorjs.io/

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/634953
推荐阅读
相关标签
  

闽ICP备14008679号