当前位置: 首页 > news >正文

angular:quill align的坑

上一行设置了align为center,换行后下一个会继承上一行的格式,我想使用Quill.formatLine(newLineIndex, 0, ‘align’, 'left')来左对齐,发现始终不能生效。

参看quill.js源码,发现align没有left的配置

var config = {scope: _parchment2.default.Scope.BLOCK,whitelist: ['right', 'center', 'justify']
};var AlignAttribute = new _parchment2.default.Attributor.Attribute('align', 'align', config);
var AlignClass = new _parchment2.default.Attributor.Class('align', 'ql-align', config);
var AlignStyle = new _parchment2.default.Attributor.Style('align', 'text-align', config);

因此只能获取换行后的格式,将align设置为undefined,再调用Quill.formatLine

  function insertImage(editor: Quill | undefined, url: string) {if (!editor) return;const {index} = editor.getSelection(true);editor.insertEmbed(index, 'image', url);editor.formatLine(index, 0, 'align', 'center')editor.insertText(index+1, '\n');const newLineIndex = index + 2;const newLineFormat = editor.getFormat(newLineIndex, length);newLineFormat['align'] = undefined;editor.formatLine(newLineIndex, 0, newLineFormat);editor.setSelection(newLineIndex, 0);}

http://www.lryc.cn/news/130818.html

相关文章:

  • 设计模式篇---抽象工厂(包含优化)
  • Azure创建可用性集
  • SpringBoot中优雅的实现隐私数据脱敏(提供Gitee源码)
  • Elasticsearch集群shard过多后导致的性能问题分析
  • Unity框架学习--5 事件中心管理器
  • (二)结构型模式:3、过滤器模式(Filter、Criteria Pattern)(C++示例)
  • 谷歌在Chrome浏览器中推进抗量子加密技术
  • Kotlin的数组
  • centos 安装docker
  • Oracle-如何判断字符串包含中文字符串(汉字),删除中文内容及保留中文内容
  • File 类的用法, InputStream和Reader, OutputStream和Writer 的用法
  • AtCoder Beginner Contest 315 Task:A/B/C/E
  • 【项目实践】基于LSTM的一维数据扩展与预测
  • webshell实践,在nginx上实现负载均衡
  • LVS+Keepalived集群
  • Java的网络编程
  • kafka配置远程连接
  • css实现渐变色border
  • 管理 IBM Spectrum LSF
  • 117页数字化转型与产业互联网发展趋势及机会分析报告PPT
  • 【JavaWeb】实训的长篇笔记(上)
  • 如何使用Docker安装AWVS?
  • vue命名规范
  • 第05天 SpringBoot自动配置原理
  • AlphaZero能否从围棋和国际象棋飞跃到量子计算?
  • 进程切换
  • ES踩坑记录之UNASSIGNED分片无法恢复
  • ubuntu更换国内apt源
  • OpenCV-Python中的图像处理-视频分析
  • STM32 CubeMX (第四步Freertos内存管理和CPU使用率)