简体   繁体   English

使用Node.js将HTML存储在browserDB中

[英]Store HTML in browserDB using Node.js

I'm trying to store HTML files in the browser for an app built on NW.js or Electron. 我正在尝试将HTML文件存储在浏览器中,以便在NW.js或Electron上构建应用程序。

Long story short: I want to make something like Sublime Text using a WYSIWYG editor (I don't know exactly how it works, so I will make a guess) 长话短说:我想使用WYSIWYG编辑器制作类似Sublime Text的东西(我不确切知道它是如何工作的,所以我会猜一猜)

  1. Creating a new TAB, all content inside the #editor is store in localStorage/IndexedDB/NeDB/PounchDB/LimvoDB/... as the user is writing. 创建一个新的TAB,#editor中的所有内容都存储在localStorage / IndexedDB / NeDB / PounchDB / LimvoDB / ...中,正如用户正在编写的那样。
  2. When the user needs to save the file, it stores the content in the browser window, and then it creates the file. 当用户需要保存文件时,它会将内容存储在浏览器窗口中,然后创建该文件。
  3. If the file already exists, the localStorage content overwrites it. 如果该文件已存在,则localStorage内容将覆盖该文件。

    All the magic must happen around the browser DB. 所有的魔力必须围绕浏览器DB发生。

    You might be wondering why I'm not using files directly, and it's because the first request: We don't know if the user will save the file, but we don't want to lose all the content if the app is closed . 您可能想知道我为什么不直接使用文件,这是因为第一个请求:我们不知道用户是否会保存文件,但如果应用程序关闭我们不希望丢失所有内容

    Searching the web, I find that is bad practice to pass HTML content through JSON , but I can't think of any other solution.. I'd have to use encodeURI and decode when retrieve the data to the #editor or the file saved. 在网上搜索,我发现通过JSON传递HTML内容不好的做法 ,但我想不出任何其他解决方案..当检索数据到#editor或保存的文件时,我必须使用encodeURI和解码。

I'm using: 我正在使用:

  • Electron 电子
  • Angular
  • I don't know yet what DB should I choose 我不知道我应该选择什么数据库

    Digging around, I also saw the sync function in PounchDB -> CouchDB and it blew my mind away ─it's a function to synchronize offline and online data using the named DB's. 四处搜索, 我也看到了 PounchDB中的同步功能 - > CouchDB,这让我大吃一惊 - 这是一个使用命名数据库同步离线和在线数据的功能。

    Is it possible to store .HTML files in PounchDB and then synchronize it with CouchDB? 是否可以在PounchDB中存储.HTML文件,然后将其与CouchDB同步? Is all this bad practice? 这都是不好的做法吗? How would you do a Notepad - Sublime Text or a «MS Word» editor using PounchDB, or NeDB, or LimvoDB using Electron/NW.js engine? 你会如何使用电子/ NW.js引擎使用PounchDB,NeDB或LimvoDB做记事本 - Sublime Text或«MS Word»编辑器?

使用PouchDB结束,这也恰好处理了很好的html字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM