Skip to content

Editor improvements#30

Merged
nitn3lav merged 5 commits into
nitn3lav:mainfrom
eladyn:editor_improvements
Oct 19, 2024
Merged

Editor improvements#30
nitn3lav merged 5 commits into
nitn3lav:mainfrom
eladyn:editor_improvements

Conversation

@eladyn

@eladyn eladyn commented Oct 13, 2024

Copy link
Copy Markdown
Contributor

This PR contains several things:

  • The EasyMDE editor is no longer included by default (which is probably good, because we currently rely on the CDN).
  • It allows enabling drag-and-drop / copy-paste uploads and exposes relevant configuration values to the library user.

Comment thread src/easymde.rs
Comment on lines +27 to +51
impl EditorConfig {
/// Enable uploads directly in the editor.
pub fn enable_uploads(mut self, enable: bool) -> Self {
self.enable_uploads = enable;
self
}

/// Set the max size for uploads.
pub fn upload_max_size(mut self, max_size: u32) -> Self {
self.upload_max_size = max_size;
self
}

/// Add an allowed file type to the currently allowed file types.
pub fn allow_file_type(mut self, file_type: impl Into<Cow<'static, str>>) -> Self {
self.allowed_file_types.push(file_type.into());
self
}

/// Reset the allowed file types to the given list.
pub fn allowed_file_types(mut self, file_types: Vec<Cow<'static, str>>) -> Self {
self.allowed_file_types = file_types;
self
}
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good use case for e. g. getset

Comment thread src/easymde.rs
Comment on lines +94 to +100
fn into_response(self) -> axum::response::Response {
let status_code = StatusCode::from_u16(match self {
UploadError::NoFileGiven | UploadError::ImportError => 400,
UploadError::TypeNotAllowed => 415,
UploadError::FileTooLarge => 413,
})
.unwrap();

@nitn3lav nitn3lav Oct 18, 2024

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/app.rs
Comment thread src/property.rs
Comment thread src/endpoints/ui.rs
Comment thread src/endpoints/ui.rs
@nitn3lav nitn3lav mentioned this pull request Oct 18, 2024
@nitn3lav nitn3lav merged commit f149bf5 into nitn3lav:main Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants