New editor #458
无评审员
标签
未选择标签
A: API
A: Backend
A: Federation
A: Front-End
A: I18N
A: Meta
A: Security
Build
C: Bug
C: Discussion
C: Enhancement
C: Feature
Compatibility
Dependency
Design
Documentation
Good first issue
Help welcome
Mobile
Rendering
S: Blocked
S: Duplicate
S: Incomplete
S: Instance specific
S: Invalid
S: Needs Voting/Discussion
S: Ready for review
Suggestion
S: Voted on Loomio
S: Wontfix
暂无项目
未指派成员
2 位参与者
通知
到期时间
未设置到期时间。
依赖工单
没有设置依赖项。
引用:Plume/Plume#458
正在加载…
添加表格
在新工单中引用
没有提供说明。
删除分支 "editor"
删除分支是永久的。虽然已删除的分支在实际被删除前有可能会短时间存在,但这在大多数情况下无法撤销。是否继续?
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:There is still a lot to do, but it is a good first step.
Fixes #255
Codecov Report
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?
Was the build script correctly run by cargo? Like, did you saw
plume(build)
beforeplume(bin)
next to the compilation progress bar? Otherwise, you can try to add aprintln!("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 haveBy 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 richershould this file (and fr.po~) exists?
my suggestion to @BaptisteGelez is to either add this our
.gitignore
or to her global.git/ignore
No, I though
*.po~
was in the gitignore, but it looks like it is not. 🤷♀️ I will add it.I think it would be easy to avoid escaping here, I will try.
They are only ignored in some directories, not everywhere
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.
mostly code-style comment again
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
@ -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
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
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).
@ -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
I tried to make the code a bit more readable, but I'm not sure it is enough…
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
so how big is the dynamic front-end right now? and how much of that is cachable?
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
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?
@ -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👍
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