- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为我的编辑器使用 quilljs
。我所有的数据都由 mysql 数据库处理。我正在使用 Angularjs 1.x
,而后端 Cakephp
是我的框架。我目前正在尝试构建一个论坛类型的页面,我想在其中保存多个图像以及将使用 quilljs 格式化的文本
<p>sd<img src="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgA....SUVORK5CYII=" alt="i am image"><b>it is image of earth</b></p>
这是当前存储在我的数据库中的内容。现在,如果有多个大图像进来,那么字段的大小会太大,因为我想在服务器端文件夹中上传图像,并想在图像标签中打印图像地址,如:
<p>sd<img src="../img/709f2d0be9d13c645037f1b9bb066b00a6d7/image1.jpg" alt="i am image"><b>it is image of earth</b></p>
所以我可以直接从给定的文件夹中获取图像。
最佳答案
我用 quilljs 做了一些小技巧。我在 quilljs 中放置了一些代码,这些代码在 if (typeof value === 'string')
之后的第 8663 行向我的 php 脚本发送图像这条语句我已经添加了将图像值发送到我的 php 脚本的脚本
var img = {
'img' : value
}
$.ajax({
url: "../Writers/writerCertificateupload",
data: img,
contentType: undefined,
type: 'post'
}).success(function(path){
node.setAttribute('src', path);
})
哪里node.setAttribute('src', path);
设置我从 php 脚本返回的路径,它将它设置在图像标签上,即 <img src="../img/709f2d0be9d13c645037f1b9bb066b00a6d7/image1.jpg">
然后它在编辑器中设置它,然后我们可以在编辑器中保存该数据。这就是我解决这个问题的方法。
我的 php 代码是
public function writerCertificateupload()//pending
{
$id = $this->Auth->user('id');
$this->autoRender=false;
define('UPLOAD_DIR', 'files/post/');
$img = $_POST['img'];
$img = str_replace('data:image/jpeg;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.jpg';
$success = file_put_contents($file, $data);
$file = "../".$file;
print $success ? $file : 'Unable to save the file.';
}
关于php - 使用 quilljs 在服务器上上传图像并在图像标签内添加文件路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41742475/
我在我的网站上使用 QuillJs 作为文本编辑器。在长篇文章中,当粘贴文本或更改标题类型或对齐方式或颜色或插入链接或视频时,屏幕 View 会跳到顶部。找不到原因。 QuillJs 版本:1.2.6
我有: useEffect(() => { if (quill) { quill.clipboard.dangerouslyPasteHTML(docu
我尝试在 Django 1.10 模板中的特定表单字段上使用 QuillJS,如下所示: var quill = new Quill('#id_text', { theme: 's
我在 Quill 还很新。 我想制作一个处理拖放事件的自定义模块或扩展函数。我想检测删除的文本,如果它是图像网址,我想插入“img”标签而不是“a”标签。 目前,Quill 正在为删除的网址添加“a”
所以我知道您可以向颜色字段添加颜色选项,例如 [{'color': "#000000"}] 但我想知道是否有一种方法可以让用户可以像在 最佳答案 您可以使用自定义工具栏handler只需一点 jav
我环顾了 Quill documentation 、GitHub 主题以及 Stack Overflow 中的此处,我一直无法找到使用 format 的简单示例属性。我想限制我的用户,使他们只能使用粗
置顶 this page ,据称提供了有关如何创建工具栏以控制字体、大小、粗体、斜体、下划线、删除线、文本颜色、背景颜色、列表、项目符号和文本对齐方式的说明。 但是,当我使用示例 HTML 代码时,我
我尝试上传 exif 数据中方向参数错误的图片。这会导致图像旋转不正确。 我需要在上传到 quillJS 编辑器之前旋转图像。 我该怎么做?有什么想法吗? 编辑: .js app.config(['n
我想创建一个自定义的嵌入格式,可以设置样式但它的文本不能更改。我的用例与主题标签的情况非常相似。我想要一个外部按钮,它将向编辑器上的当前选定范围添加一个主题标签。但是在这样做之后,我希望主题标签表现为
我们目前正在为一个项目使用 quilljs。当我们尝试通过 Clipboard 模块中的 dangerouslyPasteHTML API 添加 html 时,段落中的自定义属性被剥离。 例如: 在应
我正在使用 Quilljs 创建一个在线文档创建器作为我网站的一项功能。我已经设置好了,想知道是否有办法在输入文档后下载该文档?也许使用 php 或 javascript,最好在; .doc、.doc
嗨,我正在使用 quilljs 进行简单的富文本编辑器。我有一个不错的工作解决方案,但我面临的一个问题是当我保存编辑器空间的内容时会丢失。这是下面的代码,输入一些图像并在其前面留出空格,然后单击“保存
描述:我在 Quill Editor 工具栏中创建下拉列表时遇到问题。任何帮助,将不胜感激。理想情况下,我希望下拉列表显示在工具栏中,并将选择选项文本添加为编辑器中的文本。 测试用例:https:
我正在尝试在 QuillJS 中创建自定义类属性。 我已经走了这么远: let config = { scope: Parchment.Scope.BLOCK, }; let MClass = n
我正在使用Quill JS作为富文本编辑器。如果用户单击按钮,我希望能够突出显示文本中的特定单词。但 Quill JS 似乎没有授予通过另一个插件编辑其内容的权限(?) 我试过Mark.js和 Hig
感谢您对我的问题感兴趣。 使用的技术: PHP/JS 愿望结果:我想允许将属性“alt”添加到图像中。 添加图片时,发送到服务器,然后将带有 url (src) 的 img 标签插入到编辑器中。 它完
(我将以我是一名新的 javascript 开发人员这一事实作为序言,并且我确信我对 javascript/angular/quill 如何在页面上协同工作的知识存在差距。) 我想知道这是否可行。我不
当您在 quilljs 编辑器中插入代码块时,在渲染时代码块会被 包裹起来 有没有办法添加额外的类,以便我可以在渲染时自定义代码块的格式?例如,我想以某种方式指定一个类,比如 lang-javasc
我希望能够通过 JavaScript 使用工具栏选项将自定义字体系列添加到我的 Quill JS 编辑器,而不是通过 HTML 定义它们。 我的代码如下,与文档中的代码相同: var toolbarO
如何在textarea下方显示工具栏。 我的代码: var quill = new Quill('#txtMessage', { theme: 'snow', modules: { t
我是一名优秀的程序员,十分优秀!