Python/Javascript:WYSIWYG html编辑器-快速处理大型文档和/或设计理论 [英] Python/Javascript: WYSIWYG html editor - Handle large documents fast and/or design theory

查看:76
本文介绍了Python/Javascript:WYSIWYG html编辑器-快速处理大型文档和/或设计理论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:

我正在用python编写一个电子书编辑程序.目前,它使用源代码视图进行编辑,我想将其移植到所见即所得(Wysiwyg)视图进行编辑.我可以为python找到的最好的(唯一?)html渲染器是webkit(我使用的是PyQt版本).

I am writing an ebook editing program in python. Currently it utilizes a source-code view for editing, and I would like to port it over to a wysiwyg view for editing. The best (only?) html renderer I could find for python was webkit (I am using the PyQt version).

问题:

如何完成所见即所得的编辑?要求/问题如下:

How do I accomplish wysiwyg editing? The requirements/issues are as follows:

  1. 一本电子书最多可包含10,000个段落/1,000,000人物.
    • PyQt Webkit(ContentEditable):没问题.
    • PyQt Webkit(TinyMce等):永远需要 来打开它们!
  1. An ebook may be up to 10,000 paragraphs / 1,000,000 characters.
    • PyQt Webkit (ContentEditable): No problem.
    • PyQt Webkit (TinyMce, etc): Takes forever to open them!
  • PyQt Webkit(ContentEditable):如果您尝试删除多个段落中的文本,那将永远耗费时间!!我的理解是,这是因为它会重置要更改的元素的公共父元素(即整个body元素),因为两个不同的段落都将被删除/合并.但是,不需要这样做-它只需要删除/合并/更改这些单独的段落!
  • PyQt Webkit (ContentEditable): If you try deleting text across multiple paragraphs, it takes forever!! My understanding is that this is because it resets the common-parent of the elements being changed - i.e. the entire body element, since two different paragraphs are being deleted/merged. But, there should be no need for this - it should need only delete/merge/change those individual paragraphs!

我愿意实现自己的所见即所得编辑,但是对于我一生来说,我不知道如何正确删除/剪切/粘贴/合并/更改html代码.我在网上搜索了有关html所见即所得设计理论的文章,​​然后干了起来.

I am open to implementing my own wysiwyg editing, but for the life of me I can't figure out how to delete/cut/paste/merge/change the html code correctly. I searched online for articles about html wysiwyg design theory, and came up dry.

谢谢!

推荐答案

我可以提出一种完整的方法吗?由于您的电子书只有< p></p> :

Can i suggest a complete another approach ? Since your ebook is only <p></p>:

  • < p></p> 上分割文本以获取所有段落的索引数组
  • 创建自己的分页系统,并在屏幕上填充N个段落,这些段落会自动获得足够的文本以从索引数组中显示
  • 进行选择时,可以使用[段落索引+段落中的字符索引]进行选择的开始/结束
  • 然后根据这些假设进行剪切/复制/粘贴/删除/撤消/重做.
  • Split the text on <p></p> to get an indexed array of all your paragraphs
  • Make your own pagination system, and fill the screen with N paragraphs, that automatically get enough text to show from the indexed array
  • When you are doing selection, you can use [paragraph index + character index in the paragraph] for selection start / end
  • Then implement cut/copy/paste/delete/undo/redo based on thoses assumptions.

(注意:当您进行选择时,由于保存了起点,因此可以安全地更改屏幕/分页上的文本,直到选择结束.)

(Note: when you'll do a selection, since the start point is saved, you can safely change the text on the screen / pagination, until the selection end.)

这篇关于Python/Javascript:WYSIWYG html编辑器-快速处理大型文档和/或设计理论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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