部落格之富文字編輯器

2022-05-09 23:49:40 字數 1502 閱讀 3704

文件說明:

# 因為article_content 不是文字字串,而是包含標籤的html字串

# 但是文章描述 desc 只需要拿文字字串,不拿標籤字串

desc=bs.text[0:150]+"..."

# 過濾非法標籤, decompose() 會刪除script和link標籤

# 為什麼要刪除這些標籤,因為kineditor儲存的不是單純的文字

# kineditor儲存的是html字串,要想前端顯示用了safe

# 因為有了safe ,所以script標籤也會正常顯示,所以我們需要把script標籤刪除掉

for tag in bs.find_all():

print(tag.name)

if tag.name in ["script", "link"]:

tag.decompose()

article_obj=models.article.objects.create(user=user,title=title,desc=desc)

models.articledetail.objects.create(content=str(bs),article=article_obj)

return httpresponse("新增成功")

return render(request,"add_article.html")

富文字編輯器

關於使用富文字編輯器的一些小坑 官網 1.專案 片 editor fail function xhr,editor,result custominsert function insertimg,result,editor this.editor.create this.editor.txt.html...

富文字編輯器

富文字編輯器,rich text editor,簡稱 rte,它提供類似於 microsoft word 的編輯功能。常用的富文字編輯器 kindeditor ueditor ckeditor 在頁面中新增js 用於初始化kindeditorallowfilemanager 是否允許瀏覽伺服器已上傳...

富文字編輯器

富文字編輯器,rich text editor,簡稱 rte,它提供類似於 microsoft word 的編輯功能。常用的富文字編輯器 kindeditor ueditor ckeditor 在頁面中新增js 用於初始化kindeditor allowfilemanager 是否允許瀏覽伺服器已上...