Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions assets/locales/pending/review-markups.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"en": {
"cmd.markup_add": "Add Markup",
"cmd.markup_delete": "Delete Markup",
"cmd.markup_edit": "Edit Markup",
"cmd.markup_image": "Markup Picture",
"cmd.markup_list": "List Markups",
"cmd.markup_reject": "Reject Markup",
"cmd.markup_reopen": "Reopen Markup",
"cmd.markup_reply": "Reply to Markup",
"cmd.markup_resolve": "Resolve Markup"
},
"ar": {
"cmd.markup_add": "إضافة ملاحظة مراجعة",
"cmd.markup_delete": "حذف ملاحظة المراجعة",
"cmd.markup_edit": "تعديل ملاحظة المراجعة",
"cmd.markup_image": "صورة ملاحظة المراجعة",
"cmd.markup_list": "عرض ملاحظات المراجعة",
"cmd.markup_reject": "رفض ملاحظة المراجعة",
"cmd.markup_reopen": "إعادة فتح ملاحظة المراجعة",
"cmd.markup_reply": "الرد على ملاحظة المراجعة",
"cmd.markup_resolve": "إنهاء ملاحظة المراجعة"
},
"de": {
"cmd.markup_add": "Markierung hinzufügen",
"cmd.markup_delete": "Markierung löschen",
"cmd.markup_edit": "Markierung bearbeiten",
"cmd.markup_image": "Bild zur Markierung",
"cmd.markup_list": "Markierungen auflisten",
"cmd.markup_reject": "Markierung ablehnen",
"cmd.markup_reopen": "Markierung wieder öffnen",
"cmd.markup_reply": "Auf Markierung antworten",
"cmd.markup_resolve": "Markierung erledigen"
},
"he": {
"cmd.markup_add": "הוספת הערת סקירה",
"cmd.markup_delete": "מחיקת הערת סקירה",
"cmd.markup_edit": "עריכת הערת סקירה",
"cmd.markup_image": "תמונה להערת סקירה",
"cmd.markup_list": "רשימת הערות סקירה",
"cmd.markup_reject": "דחיית הערת סקירה",
"cmd.markup_reopen": "פתיחה מחדש של הערת סקירה",
"cmd.markup_reply": "תגובה להערת סקירה",
"cmd.markup_resolve": "סגירת הערת סקירה כטופלה"
},
"ja": {
"cmd.markup_add": "マークアップを追加",
"cmd.markup_delete": "マークアップを削除",
"cmd.markup_edit": "マークアップを編集",
"cmd.markup_image": "マークアップの画像",
"cmd.markup_list": "マークアップ一覧",
"cmd.markup_reject": "マークアップを却下",
"cmd.markup_reopen": "マークアップを再オープン",
"cmd.markup_reply": "マークアップに返信",
"cmd.markup_resolve": "マークアップを解決"
},
"vi": {
"cmd.markup_add": "Thêm ghi chú duyệt",
"cmd.markup_delete": "Xóa ghi chú duyệt",
"cmd.markup_edit": "Sửa ghi chú duyệt",
"cmd.markup_image": "Ảnh của ghi chú duyệt",
"cmd.markup_list": "Danh sách ghi chú duyệt",
"cmd.markup_reject": "Từ chối ghi chú duyệt",
"cmd.markup_reopen": "Mở lại ghi chú duyệt",
"cmd.markup_reply": "Trả lời ghi chú duyệt",
"cmd.markup_resolve": "Hoàn tất ghi chú duyệt"
},
"zh": {
"cmd.markup_add": "添加批注",
"cmd.markup_delete": "删除批注",
"cmd.markup_edit": "编辑批注",
"cmd.markup_image": "批注图片",
"cmd.markup_list": "批注列表",
"cmd.markup_reject": "拒绝批注",
"cmd.markup_reopen": "重新打开批注",
"cmd.markup_reply": "回复批注",
"cmd.markup_resolve": "解决批注"
}
}
562 changes: 562 additions & 0 deletions assets/locales/pending/review-pins.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions attribution/pending/review-pins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
| crates/look/icons/design/svg/flat/review_mark.svg | SolidCraft contributors | Original analytic pin-with-plus icon for marking a place for review | SolidCraft Brand and Interface Licence (LICENSE-BRAND) |
10 changes: 10 additions & 0 deletions crates/doc/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4429,6 +4429,12 @@ pub struct Document {
/// copies the design does not copy a plugin's large files.
#[serde(default, skip_serializing, deserialize_with = "crate::plugin_data::deserialize")]
pub plugin_data: std::collections::BTreeMap<String, crate::blob::Blob>,
/// Review markup pictures, by entry name (`<guid>.png` or `.jpg`), as bytes
/// ([`crate::markup_image`]). A container keeps each under `markups/`, as a canvas keeps its
/// image; a plain JSON design can't hold them ([`Document::binary_data`]). Shared, so an edit
/// that copies the design does not copy the pictures.
#[serde(default, skip_serializing, deserialize_with = "crate::markup_image::deserialize")]
pub markup_images: std::collections::BTreeMap<String, crate::blob::Blob>,
}

/// The browser's view of a design: items and folders hidden or shown, sketch profiles and
Expand Down Expand Up @@ -4733,6 +4739,7 @@ impl Document {
visibility: Visibility::default(),
drawings: Vec::new(),
plugin_data: Default::default(),
markup_images: Default::default(),
}
}

Expand Down Expand Up @@ -5247,6 +5254,9 @@ impl Document {
if !self.plugin_data.is_empty() {
kinds.push("plugin files");
}
if !self.markup_images.is_empty() {
kinds.push("review pictures");
}
kinds
}

Expand Down
5 changes: 5 additions & 0 deletions crates/doc/src/format/pending/review-markup-pictures.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! A design may carry review markup pictures: the bytes of each picture attached to a markup
//! (`markup.image`), a part of its own at `markups/<guid>.png` or `.jpg` in the container
//! (`markup_images`, never written as text). The markup set beside the design names each one by
//! that entry. An older design has none. The last release warns about the newer format number,
//! opens the design, and keeps those parts as they are when it saves.
1 change: 1 addition & 0 deletions crates/doc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub use inline_params::Defined;
pub mod joints;
pub mod json_layout;
mod lineage;
pub mod markup_image;
pub mod metadata;
pub use metadata::Metadata;
pub mod motion;
Expand Down
59 changes: 59 additions & 0 deletions crates/doc/src/markup_image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//! Review markup pictures (`markup.image`): each picture's bytes in the design, a part of the
//! container of its own under `markups/`, the way a canvas keeps its image. The markup set beside
//! the design (`solidcraft_io::markups`) keeps the threads and anchors and names each picture by
//! its entry here; the design holds the bytes, never text.
use std::collections::BTreeMap;

use serde::{Deserialize, Deserializer};

use crate::blob::Blob;

/// The container folder the pictures live in.
pub const PREFIX: &str = "markups/";
/// The largest picture, in bytes.
pub const MAX_BYTES: usize = 16 << 20;
/// At most this many pictures in one design; past it the rest is left out as it opens.
pub const MAX_FILES: usize = 4096;
/// The most the pictures of one design take together, in bytes.
pub const MAX_TOTAL_BYTES: u64 = 1 << 30;

/// Whether `name` is a picture's entry name: 32 hexadecimal digits and `.png` or `.jpg`, so it can
/// never name a part outside its folder.
pub fn valid_name(name: &str) -> bool {
name.strip_suffix(".png").or_else(|| name.strip_suffix(".jpg")).is_some_and(|g| g.len() == 32 && g.bytes().all(|b| b.is_ascii_hexdigit()))
}

/// The kind of picture `bytes` hold by their first bytes: `png` or `jpg` (`None`: neither).
pub fn kind(bytes: &[u8]) -> Option<&'static str> {
if bytes.starts_with(&[0x89, b'P', b'N', b'G', 0x0D, 0x0A, 0x1A, 0x0A]) {
Some("png")
} else if bytes.starts_with(&[0xFF, 0xD8, 0xFF]) {
Some("jpg")
} else {
None
}
}

/// A design's JSON never holds the pictures: whatever a hand-edited file has there is left out.
pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result<BTreeMap<String, Blob>, D::Error> {
serde::de::IgnoredAny::deserialize(deserializer)?;
Ok(BTreeMap::new())
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn names_and_kinds() {
let guid = "0123456789abcdef0123456789ABCDEF";
assert!(valid_name(&format!("{guid}.png")));
assert!(valid_name(&format!("{guid}.jpg")));
for bad in ["x.png", "../x.png", &format!("{guid}.gif"), &format!("a/{guid}.png"), ""] {
assert!(!valid_name(bad), "{bad}");
}
assert_eq!(kind(&[0x89, b'P', b'N', b'G', 0x0D, 0x0A, 0x1A, 0x0A, 0]), Some("png"));
assert_eq!(kind(&[0xFF, 0xD8, 0xFF, 0xE0]), Some("jpg"));
assert_eq!(kind(b"GIF89a"), None);
}
}
2 changes: 2 additions & 0 deletions crates/doc/src/placement_reuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ fn same_geometry_inputs(a: &Document, b: &Document) -> bool {
notes: _,
// Plugin data is kept beside the design; no feature reads it.
plugin_data: _,
// Review pictures: no feature reads them.
markup_images: _,
} = a;
(Arc::ptr_eq(render, &b.render) || *render == b.render)
&& *format == b.format
Expand Down
Loading
Loading