New editor #458

已合并
elegaanz 5 年前 将 13 次代码提交从 editor 合并至 master
elegaanz 评论于 5 年前 (从 github.com 迁移)

With this PR, when JS is activated and WASM supported, the article editor will be dynamically replaced with contenteditables elements. This makes the editing interface simpler and less like a regular form. It will also allow us to easily add visual formatting with native browser APIs (and to insert images or videos directly). Here is a little demo:

peek 05-03-2019 16-12

There is still a lot to do, but it is a good first step.

Fixes #255

With this PR, when JS is activated and WASM supported, the article editor will be dynamically replaced with `contenteditable`s elements. This makes the editing interface simpler and less like a regular form. It will also allow us to easily add visual formatting with native browser APIs (and to insert images or videos directly). Here is a little demo: ![peek 05-03-2019 16-12](https://user-images.githubusercontent.com/16254623/53815536-1dc05680-3f62-11e9-94d3-b363ed84eb97.gif) There is still a lot to do, but it is a good first step. Fixes #255
codecov[bot] 评论于 5 年前 (从 github.com 迁移)

Codecov Report

Merging #458 into master will increase coverage by 1.64%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #458      +/-   ##
==========================================
+ Coverage   26.49%   28.13%   +1.64%     
==========================================
  Files          64       64              
  Lines        7111     7496     +385     
==========================================
+ Hits         1884     2109     +225     
- Misses       5227     5387     +160
# [Codecov](https://codecov.io/gh/Plume-org/Plume/pull/458?src=pr&el=h1) Report > Merging [#458](https://codecov.io/gh/Plume-org/Plume/pull/458?src=pr&el=desc) into [master](https://codecov.io/gh/Plume-org/Plume/commit/2a188abfa152efe7a2794174279e3b9da4a809d1?src=pr&el=desc) will **increase** coverage by `1.64%`. > The diff coverage is `n/a`. ```diff @@ Coverage Diff @@ ## master #458 +/- ## ========================================== + Coverage 26.49% 28.13% +1.64% ========================================== Files 64 64 Lines 7111 7496 +385 ========================================== + Hits 1884 2109 +225 - Misses 5227 5387 +160 ```
elegaanz 评论于 5 年前 (从 github.com 迁移)

Something I just noticed: published articles are always drafts (unless you are editing an already published article)

Something I just noticed: published articles are always drafts (unless you are editing an already published article)
所有者

I'm having trouble making it work. I had to tinker plume-front.js. Any idea why, or how to prevent that?

I'm having trouble making it work. I had to tinker plume-front.js. Any idea why, or how to prevent that?
elegaanz 评论于 5 年前 (从 github.com 迁移)

Was the build script correctly run by cargo? Like, did you saw plume(build) before plume(bin) next to the compilation progress bar? Otherwise, you can try to add a println!("cargo:rerun-if-changed=target/deploy/plume-front.js") (IIRC) to it, so that we are sure it is re-run when the JS changes (it does when the WASM changes normally, but maybe that's not enough).

Was the build script correctly run by cargo? Like, did you saw `plume(build)` before `plume(bin)` next to the compilation progress bar? Otherwise, you can try to add a `println!("cargo:rerun-if-changed=target/deploy/plume-front.js")` (IIRC) to it, so that we are sure it is re-run when the JS changes (it does when the WASM changes normally, but maybe that's not enough).
所有者

ok my bad, I ran cargo web deploy -o ../static so the buildscript did not update the js file as it should have

ok my bad, I ran `cargo web deploy -o ../static` so the buildscript did not update the js file as it should have
trinity-1686a 评审于 5 年前
所有者

By doing the following change, I was able to copy past a picture in a post and have it rendered as expected. However when re-editing the article, < and > where escaped, leading to a messy html tag in the middle of the content. I don't know if this is considered in scope for this pr, but this might be something to look at, as it will get important once the editor get richer

                            set_value("editor-content", js!{return @{&widgets.2}.innerHTML}.as_str().unwrap_or_default());
By doing the following change, I was able to copy past a picture in a post and have it rendered as expected. However when re-editing the article, `<` and `>` where escaped, leading to a messy html tag in the middle of the content. I don't know if this is considered in scope for this pr, but this might be something to look at, as it will get important once the editor get richer ```suggestion set_value("editor-content", js!{return @{&widgets.2}.innerHTML}.as_str().unwrap_or_default()); ```
trinity-1686a 评审于 5 年前
所有者

should this file (and fr.po~) exists?

should this file (and fr.po~) exists?
igalic (从 github.com 迁移) 评审于 5 年前
igalic (从 github.com 迁移) 评论于 5 年前

my suggestion to @BaptisteGelez is to either add this our .gitignore or to her global .git/ignore

my suggestion to @BaptisteGelez is to either add this our `.gitignore` or to her global `.git/ignore`
elegaanz (从 github.com 迁移) 评审于 5 年前
elegaanz (从 github.com 迁移) 评论于 5 年前

No, I though *.po~ was in the gitignore, but it looks like it is not. 🤷‍♀️ I will add it.

No, I though `*.po~` was in the gitignore, but it looks like it is not. :woman_shrugging: I will add it.
elegaanz (从 github.com 迁移) 评审于 5 年前
elegaanz (从 github.com 迁移) 评论于 5 年前

I think it would be easy to avoid escaping here, I will try.

I think it would be easy to avoid escaping here, I will try.
trinity-1686a 评审于 5 年前
所有者

They are only ignored in some directories, not everywhere

They are only ignored in some directories, not everywhere
elegaanz 评论于 5 年前 (从 github.com 迁移)

I added back the character counter, but it is not as precise as the previous one, since I only took the article content in account (otherwise I would have had to rebuild all the original form every time, which would be quite long both in code and when running). I don't think that's a big issue, since the previous one was not perfectly precise neither, and that people will rarely reach this limit anyway.

I added back the character counter, but it is not as precise as the previous one, since I only took the article content in account (otherwise I would have had to rebuild all the original form every time, which would be quite long both in code and when running). I don't think that's a big issue, since the previous one was not perfectly precise neither, and that people will rarely reach this limit anyway.
trinity-1686a 评审于 5 年前
trinity-1686a 留下了一条评论
所有者

mostly code-style comment again

mostly code-style comment again
所有者

this line is duplicated

this line is duplicated
所有者

this closure is really long. It would gain in readability to be divided in multiple smaller functions called one after an other (like "hide non-js form", "add js editor", "show popup", "copy editor to form"...). I understand what it's doing, but if there is something wrong, it's too complex to see it right away

this closure is really long. It would gain in readability to be divided in multiple smaller functions called one after an other (like "hide non-js form", "add js editor", "show popup", "copy editor to form"...). I understand what it's doing, but if there is something wrong, it's too complex to see it right away
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
所有者

I love that it just works like in the back-end, with nothing more to

I love that it just works like in the back-end, with nothing more to
elegaanz (从 github.com 迁移) 评审于 5 年前
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
elegaanz (从 github.com 迁移) 评论于 5 年前

Yeah, that's really great! The only downside is that we include all the translations in the .wasm so it is a bit bigger, but there is like 3 or 4 messages for the moment so I guess it's fine (and I don't expect it to become much bigger, I think we will never have more than 30 messages for the front end).

Yeah, that's really great! The only downside is that we include all the translations in the .wasm so it is a bit bigger, but there is like 3 or 4 messages for the moment so I guess it's fine (and I don't expect it to become much bigger, I think we will never have more than 30 messages for the front end).
trinity-1686a 评审于 5 年前
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
所有者

considering all Plume translations (not plume-front) are 208k on my computer, any picture loaded on the front page must cost much more than having all translations available

considering all Plume translations (not plume-front) are 208k on my computer, any picture loaded on the front page must cost much more than having all translations available
elegaanz 评论于 5 年前 (从 github.com 迁移)

I tried to make the code a bit more readable, but I'm not sure it is enough…

I tried to make the code a bit more readable, but I'm not sure it is enough…
igalic (从 github.com 迁移) 评审于 5 年前
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
igalic (从 github.com 迁移) 评论于 5 年前

so how big is the dynamic front-end right now? and how much of that is cachable?

so how big is the dynamic front-end right now? and how much of that is cachable?
elegaanz (从 github.com 迁移) 评审于 5 年前
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
elegaanz (从 github.com 迁移) 评论于 5 年前

It is 2.2M on my computer, but there are various ways to optimize WASM size that we didn't explored yet. And I don't know how much of it is cachable? Nothing?

It is 2.2M on my computer, but there are various ways to optimize WASM size that we didn't explored yet. And I don't know how much of it is cachable? Nothing?
trinity-1686a 评审于 5 年前
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
所有者

I'd say everything, it's a static file after all. I tried compiling with cargo web deploy --release, it seems to work, and is "only" 832k. We could also try to compact plume-front.js as it's 35k with indentation and things, however I'm not sure it's that important

I'd say everything, it's a static file after all. I tried compiling with `cargo web deploy --release`, it seems to work, and is "only" 832k. We could also try to compact plume-front.js as it's 35k with indentation and things, however I'm not sure it's that important
trinity-1686a5 年前 批准此合并请求
trinity-1686a 留下了一条评论
所有者

👍

:+1:
所有者

Oups, 2 little things : It doesn't seems to be possible to add carriage return in the content (prevent default I guess), and it may be nice to have a button to switch back to the plain markdown editor

Oups, 2 little things : It doesn't seems to be possible to add carriage return in the content (prevent default I guess), and it may be nice to have a button to switch back to the plain markdown editor

评审人

trinity-1686a5 年前 批准此合并请求
该合并请求已作为 9076dbaadc 被合并。
你也可以查看 命令行指令

第一步:

从你的仓库中签出一个新的分支并测试变更。
git checkout -b editor master
git pull origin editor

第二步:

合并变更并更新到 Forgejo 上
git checkout master
git merge --no-ff editor
git push origin master
登录 并参与到对话中。
无审核者
未选择里程碑
未指派成员
2 名参与者
通知
到期时间
到期日期无效或超出范围。请使用 'yyyy-mm-dd' 格式。

未设置到期时间。

依赖工单

没有设置依赖项。

参考:Plume/Plume#458
正在加载...
这个人很懒,什么都没留下。