创建Rich Text编辑器AngularJS [英] Creating Rich Text editor AngularJS

查看:86
本文介绍了创建Rich Text编辑器AngularJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道那里有很多很棒的富文本编辑器,可以轻松地将它们移植到有角度的地方,并就如何执行此问题进行了大量讨论,但是我想创建自己的编辑器.

I know there are lots of great rich text editors out there that can easily be ported to angular and plenty of discussion on how to do this, but I'd like to create my own.

我的基本想法是:

  • 创建一个文本区域,观察输入并随着输入的变化执行功能.我对ngBindhtml指令非常熟悉,仅在可以将其应用于元素的范围内.

有什么想法可以创建一个将纯文本呈现为html的函数吗?

Any idea how I might be able to create a function that would render plain text into html?

推荐答案

我以前尝试过,但最终使用 textAngular .

I've tried it before but ended up using textAngular.

基本上,我用iframe替换了textarea,类似于tinyMCE所做的方式.

Basically i replaced the textarea with a iframe, similar to the way tinyMCE does.

元素上的 contenteditable 允许您替换文本区域并直接在div上书写.您将以这种方式插入所有HTML元素(例如标题和文本).您必须处理文本上的光标位置,根据按钮和文本选择应用样式,等等.

The contenteditable on a element allow you to replace the textarea and write directly on the div. You would insert all html elements like headers and text this way. You'll have to handle the cursor position on text, apply styles based on buttons and text selection, etc.

这篇关于创建Rich Text编辑器AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆