mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-04 13:23:28 +00:00
[ENG-1124 | ENG-1154] Ephemeral location bug: Opening files | Path should always be in present in Inspector (#1401)
* New functions to open ephemeral files * Review items for ephemeral files * Open and OpenWith context menu for ephemeral paths * Some warnings * Fixing inspector * Fixing windows * Format * Messy rebase * Fix macos * Cargo fmt * Removing devtools as it can be opened with keybind * Fix macos * Separating ext for ephemeral files on inspector * Fixing bad rebase * Removing rename button from quickpreview for ephemeral files * Quick Preview for ephemeral files * Requested changes
This commit is contained in:
parent
9c6e418e0f
commit
774e5b7839
3
.vscode/launch.json
vendored
3
.vscode/launch.json
vendored
|
@ -17,8 +17,7 @@
|
||||||
"problemMatcher": "$rustc"
|
"problemMatcher": "$rustc"
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"RUST_BACKTRACE": "short",
|
"RUST_BACKTRACE": "short"
|
||||||
"SD_DEVTOOLS": "true"
|
|
||||||
// "RUST_LOG": "sd_core::invalidate-query=trace"
|
// "RUST_LOG": "sd_core::invalidate-query=trace"
|
||||||
},
|
},
|
||||||
"sourceLanguages": ["rust"],
|
"sourceLanguages": ["rust"],
|
||||||
|
|
3
.vscode/tasks.json
vendored
3
.vscode/tasks.json
vendored
|
@ -52,8 +52,7 @@
|
||||||
"--no-default-features"
|
"--no-default-features"
|
||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"RUST_BACKTRACE": "short",
|
"RUST_BACKTRACE": "short"
|
||||||
"SD_DEVTOOLS": "true"
|
|
||||||
// "RUST_LOG": "sd_core::invalidate-query=trace"
|
// "RUST_LOG": "sd_core::invalidate-query=trace"
|
||||||
},
|
},
|
||||||
"problemMatcher": ["$rustc"],
|
"problemMatcher": ["$rustc"],
|
||||||
|
|
|
@ -50,11 +50,7 @@ To quickly run only the desktop app after `prep`, you can use:
|
||||||
|
|
||||||
- `pnpm tauri dev`
|
- `pnpm tauri dev`
|
||||||
|
|
||||||
If necessary, the webview devtools can be opened automatically by passing the following environment variable before starting the desktop app:
|
If necessary, the webview devtools can be opened by pressing Ctrl + Shift + I in the desktop app.
|
||||||
|
|
||||||
- \[Bash]: `export SD_DEVTOOLS=1`
|
|
||||||
|
|
||||||
- \[Powershell]: `$env:SD_DEVTOOLS=1`
|
|
||||||
|
|
||||||
Also, the react-devtools can be launched using `pnpm dlx react-devtools`.
|
Also, the react-devtools can be launched using `pnpm dlx react-devtools`.
|
||||||
However, it must be executed before starting the desktop app for it qto connect.
|
However, it must be executed before starting the desktop app for it qto connect.
|
||||||
|
|
|
@ -134,7 +134,7 @@ pub fn open_files_path_with(file_paths: &[impl AsRef<Path>], id: &str) -> Result
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn open_file_path(file_path: &impl AsRef<Path>) -> Result<(), GlibError> {
|
pub fn open_file_path(file_path: impl AsRef<Path>) -> Result<(), GlibError> {
|
||||||
let file_uri = GioFile::for_path(file_path).uri().to_string();
|
let file_uri = GioFile::for_path(file_path).uri().to_string();
|
||||||
LAUNCH_CTX.with(|ctx| AppInfo::launch_default_for_uri(&file_uri.to_string(), Some(ctx)))
|
LAUNCH_CTX.with(|ctx| AppInfo::launch_default_for_uri(&file_uri.to_string(), Some(ctx)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ class OpenWithApplication: NSObject {
|
||||||
var id: SRString
|
var id: SRString
|
||||||
var url: SRString
|
var url: SRString
|
||||||
var icon: SRData
|
var icon: SRData
|
||||||
|
|
||||||
init(name: SRString, id: SRString, url: SRString, icon: SRData) {
|
init(name: SRString, id: SRString, url: SRString, icon: SRData) {
|
||||||
self.name = name
|
self.name = name
|
||||||
self.id = id
|
self.id = id
|
||||||
|
@ -36,13 +36,13 @@ func getOpenWithApplications(urlString: SRString) -> SRObjectArray {
|
||||||
// Fallback on earlier versions
|
// Fallback on earlier versions
|
||||||
url = URL(fileURLWithPath: urlString.toString())
|
url = URL(fileURLWithPath: urlString.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
let appURLs: [URL]
|
let appURLs: [URL]
|
||||||
if #available(macOS 12.0, *) {
|
if #available(macOS 12.0, *) {
|
||||||
appURLs = NSWorkspace.shared.urlsForApplications(toOpen: url)
|
appURLs = NSWorkspace.shared.urlsForApplications(toOpen: url)
|
||||||
} else {
|
} else {
|
||||||
// Fallback for macOS versions prior to 12
|
// Fallback for macOS versions prior to 12
|
||||||
|
|
||||||
// Get type identifier from file URL
|
// Get type identifier from file URL
|
||||||
let fileType: String
|
let fileType: String
|
||||||
if #available(macOS 11.0, *) {
|
if #available(macOS 11.0, *) {
|
||||||
|
@ -51,7 +51,7 @@ func getOpenWithApplications(urlString: SRString) -> SRObjectArray {
|
||||||
print("Failed to fetch file type for the specified file URL")
|
print("Failed to fetch file type for the specified file URL")
|
||||||
return SRObjectArray([])
|
return SRObjectArray([])
|
||||||
}
|
}
|
||||||
|
|
||||||
fileType = _fileType
|
fileType = _fileType
|
||||||
} else {
|
} else {
|
||||||
// Fallback for macOS versions prior to 11
|
// Fallback for macOS versions prior to 11
|
||||||
|
@ -64,7 +64,7 @@ func getOpenWithApplications(urlString: SRString) -> SRObjectArray {
|
||||||
}
|
}
|
||||||
fileType = _fileType as String
|
fileType = _fileType as String
|
||||||
}
|
}
|
||||||
|
|
||||||
// Locates an array of bundle identifiers for apps capable of handling a specified content type with the specified roles.
|
// Locates an array of bundle identifiers for apps capable of handling a specified content type with the specified roles.
|
||||||
guard
|
guard
|
||||||
let bundleIds = LSCopyAllRoleHandlersForContentType(fileType as CFString, LSRolesMask.all)?
|
let bundleIds = LSCopyAllRoleHandlersForContentType(fileType as CFString, LSRolesMask.all)?
|
||||||
|
@ -73,7 +73,7 @@ func getOpenWithApplications(urlString: SRString) -> SRObjectArray {
|
||||||
print("Failed to fetch bundle IDs for the specified file type")
|
print("Failed to fetch bundle IDs for the specified file type")
|
||||||
return SRObjectArray([])
|
return SRObjectArray([])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve all URLs for the app identified by a bundle id
|
// Retrieve all URLs for the app identified by a bundle id
|
||||||
appURLs = bundleIds.compactMap { bundleId -> URL? in
|
appURLs = bundleIds.compactMap { bundleId -> URL? in
|
||||||
guard let retVal = LSCopyApplicationURLsForBundleIdentifier(bundleId as CFString, nil) else {
|
guard let retVal = LSCopyApplicationURLsForBundleIdentifier(bundleId as CFString, nil) else {
|
||||||
|
@ -82,19 +82,19 @@ func getOpenWithApplications(urlString: SRString) -> SRObjectArray {
|
||||||
return retVal.takeRetainedValue() as? URL
|
return retVal.takeRetainedValue() as? URL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SRObjectArray(
|
return SRObjectArray(
|
||||||
appURLs.compactMap { url -> NSObject? in
|
appURLs.compactMap { url -> NSObject? in
|
||||||
guard !url.path.contains("/Applications/"),
|
guard url.path.contains("/Applications/"),
|
||||||
let infoDict = Bundle(url: url)?.infoDictionary,
|
let infoDict = Bundle(url: url)?.infoDictionary,
|
||||||
let name = (infoDict["CFBundleDisplayName"] ?? infoDict["CFBundleName"]) as? String,
|
let name = (infoDict["CFBundleDisplayName"] ?? infoDict["CFBundleName"]) as? String,
|
||||||
let appId = infoDict["CFBundleIdentifier"] as? String
|
let appId = infoDict["CFBundleIdentifier"] as? String
|
||||||
else {
|
else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let icon = NSWorkspace.shared.icon(forFile: url.path)
|
let icon = NSWorkspace.shared.icon(forFile: url.path)
|
||||||
|
|
||||||
return OpenWithApplication(
|
return OpenWithApplication(
|
||||||
name: SRString(name),
|
name: SRString(name),
|
||||||
id: SRString(appId),
|
id: SRString(appId),
|
||||||
|
@ -108,13 +108,13 @@ func getOpenWithApplications(urlString: SRString) -> SRObjectArray {
|
||||||
func openFilePathsWith(filePath: SRString, withUrl: SRString) {
|
func openFilePathsWith(filePath: SRString, withUrl: SRString) {
|
||||||
let config = NSWorkspace.OpenConfiguration()
|
let config = NSWorkspace.OpenConfiguration()
|
||||||
let at = URL(fileURLWithPath: withUrl.toString())
|
let at = URL(fileURLWithPath: withUrl.toString())
|
||||||
|
|
||||||
// FIX-ME(HACK): The NULL split here is because I was not able to make this function accept a SRArray<SRString> argument.
|
// FIX-ME(HACK): The NULL split here is because I was not able to make this function accept a SRArray<SRString> argument.
|
||||||
// So, considering these are file paths, and \0 is not a valid character for a file path,
|
// So, considering these are file paths, and \0 is not a valid character for a file path,
|
||||||
// I am using it as a delimitor to allow the rust side to pass in an array of files paths to this function
|
// I am using it as a delimitor to allow the rust side to pass in an array of files paths to this function
|
||||||
let fileURLs = filePath.toString().split(separator: "\0").map {
|
let fileURLs = filePath.toString().split(separator: "\0").map {
|
||||||
filePath in URL(fileURLWithPath: String(filePath))
|
filePath in URL(fileURLWithPath: String(filePath))
|
||||||
}
|
}
|
||||||
|
|
||||||
NSWorkspace.shared.open(fileURLs, withApplicationAt: at, configuration: config)
|
NSWorkspace.shared.open(fileURLs, withApplicationAt: at, configuration: config)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub struct OpenWithApplication {
|
||||||
swift!(pub fn get_open_with_applications(url: &SRString) -> SRObjectArray<OpenWithApplication>);
|
swift!(pub fn get_open_with_applications(url: &SRString) -> SRObjectArray<OpenWithApplication>);
|
||||||
swift!(pub(crate) fn open_file_path_with(file_url: &SRString, with_url: &SRString));
|
swift!(pub(crate) fn open_file_path_with(file_url: &SRString, with_url: &SRString));
|
||||||
|
|
||||||
pub fn open_file_paths_with(file_urls: &[&str], with_url: &str) {
|
pub fn open_file_paths_with(file_urls: &[String], with_url: &str) {
|
||||||
let file_url = file_urls.join("\0");
|
let file_url = file_urls.join("\0");
|
||||||
unsafe { open_file_path_with(&file_url.as_str().into(), &with_url.into()) }
|
unsafe { open_file_path_with(&file_url.as_str().into(), &with_url.into()) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,8 +93,9 @@ pub fn list_apps_associated_with_ext(ext: &OsStr) -> Result<Vec<IAssocHandler>>
|
||||||
Ok(vec)
|
Ok(vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn open_file_path_with(path: &Path, url: &str) -> Result<()> {
|
pub fn open_file_path_with(path: impl AsRef<Path>, url: &str) -> Result<()> {
|
||||||
ensure_com_initialized();
|
ensure_com_initialized();
|
||||||
|
let path = path.as_ref();
|
||||||
|
|
||||||
let ext = path.extension().ok_or(Error::OK)?;
|
let ext = path.extension().ok_or(Error::OK)?;
|
||||||
for handler in list_apps_associated_with_ext(ext)?.iter() {
|
for handler in list_apps_associated_with_ext(ext)?.iter() {
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeSet, HashMap, HashSet},
|
collections::{BTreeSet, HashMap, HashSet},
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
|
path::PathBuf,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use futures::future::join_all;
|
||||||
use sd_core::{
|
use sd_core::{
|
||||||
prisma::{file_path, location},
|
prisma::{file_path, location},
|
||||||
Node,
|
Node,
|
||||||
};
|
};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use specta::Type;
|
use specta::Type;
|
||||||
|
use tauri::async_runtime::spawn_blocking;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
type NodeState<'a> = tauri::State<'a, Arc<Node>>;
|
type NodeState<'a> = tauri::State<'a, Arc<Node>>;
|
||||||
|
@ -39,11 +42,17 @@ pub async fn open_file_paths(
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(id, maybe_path)| {
|
.map(|(id, maybe_path)| {
|
||||||
if let Some(path) = maybe_path {
|
if let Some(path) = maybe_path {
|
||||||
#[cfg(target_os = "linux")]
|
let open_result = {
|
||||||
let open_result = sd_desktop_linux::open_file_path(&path);
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
sd_desktop_linux::open_file_path(path)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
let open_result = opener::open(path);
|
{
|
||||||
|
opener::open(path)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
open_result
|
open_result
|
||||||
.map(|_| OpenFilePathResult::AllGood(id))
|
.map(|_| OpenFilePathResult::AllGood(id))
|
||||||
|
@ -65,6 +74,39 @@ pub async fn open_file_paths(
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Type)]
|
||||||
|
#[serde(tag = "t", content = "c")]
|
||||||
|
pub enum EphemeralFileOpenResult {
|
||||||
|
Ok(PathBuf),
|
||||||
|
Err(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command(async)]
|
||||||
|
#[specta::specta]
|
||||||
|
pub async fn open_ephemeral_files(paths: Vec<PathBuf>) -> Result<Vec<EphemeralFileOpenResult>, ()> {
|
||||||
|
Ok(paths
|
||||||
|
.into_iter()
|
||||||
|
.map(|path| {
|
||||||
|
if let Err(e) = {
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
sd_desktop_linux::open_file_path(&path)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
{
|
||||||
|
opener::open(&path)
|
||||||
|
}
|
||||||
|
} {
|
||||||
|
error!("Failed to open file: {e:#?}");
|
||||||
|
EphemeralFileOpenResult::Err(e.to_string())
|
||||||
|
} else {
|
||||||
|
EphemeralFileOpenResult::Ok(path)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Type, Debug, Clone)]
|
#[derive(Serialize, Type, Debug, Clone)]
|
||||||
pub struct OpenWithApplication {
|
pub struct OpenWithApplication {
|
||||||
url: String,
|
url: String,
|
||||||
|
@ -85,6 +127,100 @@ impl PartialEq for OpenWithApplication {
|
||||||
|
|
||||||
impl Eq for OpenWithApplication {}
|
impl Eq for OpenWithApplication {}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
async fn get_file_path_open_apps_set(path: PathBuf) -> Option<HashSet<OpenWithApplication>> {
|
||||||
|
let Some(path_str) = path.to_str() else {
|
||||||
|
error!(
|
||||||
|
"File path contains non-UTF8 characters: '{}'",
|
||||||
|
path.display()
|
||||||
|
);
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
|
||||||
|
let res = unsafe { sd_desktop_macos::get_open_with_applications(&path_str.into()) }
|
||||||
|
.as_slice()
|
||||||
|
.iter()
|
||||||
|
.map(|app| OpenWithApplication {
|
||||||
|
url: app.url.to_string(),
|
||||||
|
name: app.name.to_string(),
|
||||||
|
})
|
||||||
|
.collect::<HashSet<_>>();
|
||||||
|
|
||||||
|
Some(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
async fn get_file_path_open_apps_set(path: PathBuf) -> Option<HashSet<OpenWithApplication>> {
|
||||||
|
Some(
|
||||||
|
sd_desktop_linux::list_apps_associated_with_ext(&path)
|
||||||
|
.await
|
||||||
|
.into_iter()
|
||||||
|
.map(|app| OpenWithApplication {
|
||||||
|
url: app.id,
|
||||||
|
name: app.name,
|
||||||
|
})
|
||||||
|
.collect::<HashSet<_>>(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
async fn get_file_path_open_apps_set(path: PathBuf) -> Option<HashSet<OpenWithApplication>> {
|
||||||
|
let Some(ext) = path.extension() else {
|
||||||
|
error!("Failed to extract file extension for '{}'", path.display());
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
|
||||||
|
sd_desktop_windows::list_apps_associated_with_ext(ext)
|
||||||
|
.map_err(|e| {
|
||||||
|
error!("{e:#?}");
|
||||||
|
})
|
||||||
|
.map(|handlers| {
|
||||||
|
handlers
|
||||||
|
.iter()
|
||||||
|
.filter_map(|handler| {
|
||||||
|
let (Ok(name), Ok(url)) = (
|
||||||
|
unsafe { handler.GetUIName() }
|
||||||
|
.map_err(|e| {
|
||||||
|
error!("Error on '{}': {e:#?}", path.display());
|
||||||
|
})
|
||||||
|
.and_then(|name| {
|
||||||
|
unsafe { name.to_string() }.map_err(|e| {
|
||||||
|
error!("Error on '{}': {e:#?}", path.display());
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
unsafe { handler.GetName() }
|
||||||
|
.map_err(|e| {
|
||||||
|
error!("Error on '{}': {e:#?}", path.display());
|
||||||
|
})
|
||||||
|
.and_then(|name| {
|
||||||
|
unsafe { name.to_string() }.map_err(|e| {
|
||||||
|
error!("Error on '{}': {e:#?}", path.display());
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
) else {
|
||||||
|
error!("Failed to get handler info for '{}'", path.display());
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(OpenWithApplication { name, url })
|
||||||
|
})
|
||||||
|
.collect::<HashSet<_>>()
|
||||||
|
})
|
||||||
|
.ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn aggregate_open_with_apps(
|
||||||
|
paths: impl Iterator<Item = PathBuf>,
|
||||||
|
) -> Result<Vec<OpenWithApplication>, ()> {
|
||||||
|
Ok(join_all(paths.map(get_file_path_open_apps_set))
|
||||||
|
.await
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
|
.reduce(|intersection, set| intersection.intersection(&set).cloned().collect())
|
||||||
|
.map(|set| set.into_iter().collect())
|
||||||
|
.unwrap_or(vec![]))
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[specta::specta]
|
#[specta::specta]
|
||||||
pub async fn get_file_path_open_with_apps(
|
pub async fn get_file_path_open_with_apps(
|
||||||
|
@ -102,123 +238,21 @@ pub async fn get_file_path_open_with_apps(
|
||||||
return Ok(vec![]);
|
return Ok(vec![]);
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
aggregate_open_with_apps(paths.into_values().filter_map(|maybe_path| {
|
||||||
return {
|
if maybe_path.is_none() {
|
||||||
Ok(paths
|
error!("File not found in database");
|
||||||
.into_values()
|
}
|
||||||
.flat_map(|path| {
|
maybe_path
|
||||||
let Some(path) = path.and_then(|path| path.into_os_string().into_string().ok())
|
}))
|
||||||
else {
|
.await
|
||||||
error!("File not found in database");
|
}
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
Some(
|
#[tauri::command(async)]
|
||||||
unsafe { sd_desktop_macos::get_open_with_applications(&path.as_str().into()) }
|
#[specta::specta]
|
||||||
.as_slice()
|
pub async fn get_ephemeral_files_open_with_apps(
|
||||||
.iter()
|
paths: Vec<PathBuf>,
|
||||||
.map(|app| OpenWithApplication {
|
) -> Result<Vec<OpenWithApplication>, ()> {
|
||||||
url: app.url.to_string(),
|
aggregate_open_with_apps(paths.into_iter()).await
|
||||||
name: app.name.to_string(),
|
|
||||||
})
|
|
||||||
.collect::<HashSet<_>>(),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.reduce(|intersection, set| intersection.intersection(&set).cloned().collect())
|
|
||||||
.map(|set| set.into_iter().collect())
|
|
||||||
.unwrap_or(vec![]))
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
{
|
|
||||||
use futures::future;
|
|
||||||
use sd_desktop_linux::list_apps_associated_with_ext;
|
|
||||||
|
|
||||||
let apps = future::join_all(paths.into_values().map(|path| async {
|
|
||||||
let Some(path) = path else {
|
|
||||||
error!("File not found in database");
|
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
Some(
|
|
||||||
list_apps_associated_with_ext(&path)
|
|
||||||
.await
|
|
||||||
.into_iter()
|
|
||||||
.map(|app| OpenWithApplication {
|
|
||||||
url: app.id,
|
|
||||||
name: app.name,
|
|
||||||
})
|
|
||||||
.collect::<HashSet<_>>(),
|
|
||||||
)
|
|
||||||
}))
|
|
||||||
.await;
|
|
||||||
|
|
||||||
return Ok(apps
|
|
||||||
.into_iter()
|
|
||||||
.flatten()
|
|
||||||
.reduce(|intersection, set| intersection.intersection(&set).cloned().collect())
|
|
||||||
.map(|set| set.into_iter().collect())
|
|
||||||
.unwrap_or(vec![]));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
return Ok(paths
|
|
||||||
.into_values()
|
|
||||||
.filter_map(|path| {
|
|
||||||
let Some(path) = path else {
|
|
||||||
error!("File not found in database");
|
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
let Some(ext) = path.extension() else {
|
|
||||||
error!("Failed to extract file extension");
|
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
sd_desktop_windows::list_apps_associated_with_ext(ext)
|
|
||||||
.map_err(|e| {
|
|
||||||
error!("{e:#?}");
|
|
||||||
})
|
|
||||||
.ok()
|
|
||||||
})
|
|
||||||
.map(|handler| {
|
|
||||||
handler
|
|
||||||
.iter()
|
|
||||||
.filter_map(|handler| {
|
|
||||||
let (Ok(name), Ok(url)) = (
|
|
||||||
unsafe { handler.GetUIName() }
|
|
||||||
.map_err(|e| {
|
|
||||||
error!("{e:#?}");
|
|
||||||
})
|
|
||||||
.and_then(|name| {
|
|
||||||
unsafe { name.to_string() }.map_err(|e| {
|
|
||||||
error!("{e:#?}");
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
unsafe { handler.GetName() }
|
|
||||||
.map_err(|e| {
|
|
||||||
error!("{e:#?}");
|
|
||||||
})
|
|
||||||
.and_then(|name| {
|
|
||||||
unsafe { name.to_string() }.map_err(|e| {
|
|
||||||
error!("{e:#?}");
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
) else {
|
|
||||||
error!("Failed to get handler info");
|
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
Some(OpenWithApplication { name, url })
|
|
||||||
})
|
|
||||||
.collect::<HashSet<_>>()
|
|
||||||
})
|
|
||||||
.reduce(|intersection, set| intersection.intersection(&set).cloned().collect())
|
|
||||||
.map(|set| set.into_iter().collect())
|
|
||||||
.unwrap_or(vec![]));
|
|
||||||
|
|
||||||
#[allow(unreachable_code)]
|
|
||||||
Ok(vec![])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileIdAndUrl = (i32, String);
|
type FileIdAndUrl = (i32, String);
|
||||||
|
@ -248,10 +282,11 @@ pub async fn open_file_path_with(
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(id, path)| {
|
.map(|(id, path)| {
|
||||||
let (Some(path), Some(url)) = (
|
let (Some(path), Some(url)) = (
|
||||||
#[cfg(windows)]
|
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||||
path.as_ref(),
|
path.as_ref(),
|
||||||
#[cfg(not(windows))]
|
#[cfg(target_os = "macos")]
|
||||||
path.as_ref().and_then(|path| path.to_str()),
|
path.as_ref()
|
||||||
|
.and_then(|path| path.to_str().map(str::to_string)),
|
||||||
url_by_id.get(id),
|
url_by_id.get(id),
|
||||||
) else {
|
) else {
|
||||||
error!("File not found in database");
|
error!("File not found in database");
|
||||||
|
@ -269,7 +304,7 @@ pub async fn open_file_path_with(
|
||||||
error!("{e:#?}");
|
error!("{e:#?}");
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(target_os = "windows")]
|
||||||
return sd_desktop_windows::open_file_path_with(path, url).map_err(|e| {
|
return sd_desktop_windows::open_file_path_with(path, url).map_err(|e| {
|
||||||
error!("{e:#?}");
|
error!("{e:#?}");
|
||||||
});
|
});
|
||||||
|
@ -282,10 +317,85 @@ pub async fn open_file_path_with(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PathAndUrl = (PathBuf, String);
|
||||||
|
|
||||||
|
#[tauri::command(async)]
|
||||||
|
#[specta::specta]
|
||||||
|
pub async fn open_ephemeral_file_with(paths_and_urls: Vec<PathAndUrl>) -> Result<(), ()> {
|
||||||
|
join_all(
|
||||||
|
paths_and_urls
|
||||||
|
.into_iter()
|
||||||
|
.collect::<HashMap<_, _>>() // Just to avoid duplicates
|
||||||
|
.into_iter()
|
||||||
|
.map(|(path, url)| async move {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
if let Some(path) = path.to_str().map(str::to_string) {
|
||||||
|
if let Err(e) = spawn_blocking(move || {
|
||||||
|
sd_desktop_macos::open_file_paths_with(&[path], &url)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
error!("Error joining spawned task for opening files with: {e:#?}");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error!(
|
||||||
|
"File path contains non-UTF8 characters: '{}'",
|
||||||
|
path.display()
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
match spawn_blocking(move || sd_desktop_linux::open_files_path_with(&[path], &url))
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(Ok(())) => (),
|
||||||
|
Ok(Err(e)) => error!("Error opening file with: {e:#?}"),
|
||||||
|
Err(e) => error!("Error joining spawned task for opening files with: {e:#?}"),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
match spawn_blocking(move || sd_desktop_windows::open_file_path_with(path, &url))
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(Ok(())) => (),
|
||||||
|
Ok(Err(e)) => error!("Error opening file with: {e:#?}"),
|
||||||
|
Err(e) => error!("Error joining spawned task for opening files with: {e:#?}"),
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn inner_reveal_paths(paths: impl Iterator<Item = PathBuf>) {
|
||||||
|
for path in paths {
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
if sd_desktop_linux::is_appimage() {
|
||||||
|
// This is a workaround for the app, when package inside an AppImage, crashing when using opener::reveal.
|
||||||
|
if let Err(e) = sd_desktop_linux::open_file_path(if path.is_file() {
|
||||||
|
path.parent().unwrap_or(&path)
|
||||||
|
} else {
|
||||||
|
&path
|
||||||
|
}) {
|
||||||
|
error!("Failed to open logs dir: {e:#?}");
|
||||||
|
}
|
||||||
|
} else if let Err(e) = opener::reveal(path) {
|
||||||
|
error!("Failed to open logs dir: {e:#?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
if let Err(e) = opener::reveal(path) {
|
||||||
|
error!("Failed to open logs dir: {e:#?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(specta::Type, serde::Deserialize)]
|
#[derive(specta::Type, serde::Deserialize)]
|
||||||
pub enum RevealItem {
|
pub enum RevealItem {
|
||||||
Location { id: location::id::Type },
|
Location { id: location::id::Type },
|
||||||
FilePath { id: file_path::id::Type },
|
FilePath { id: file_path::id::Type },
|
||||||
|
Ephemeral { path: PathBuf },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
|
@ -299,6 +409,8 @@ pub async fn reveal_items(
|
||||||
return Err(());
|
return Err(());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut paths_to_open = BTreeSet::new();
|
||||||
|
|
||||||
let (paths, locations): (Vec<_>, Vec<_>) =
|
let (paths, locations): (Vec<_>, Vec<_>) =
|
||||||
items
|
items
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -306,13 +418,14 @@ pub async fn reveal_items(
|
||||||
match item {
|
match item {
|
||||||
RevealItem::FilePath { id } => paths.push(id),
|
RevealItem::FilePath { id } => paths.push(id),
|
||||||
RevealItem::Location { id } => locations.push(id),
|
RevealItem::Location { id } => locations.push(id),
|
||||||
|
RevealItem::Ephemeral { path } => {
|
||||||
|
paths_to_open.insert(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(paths, locations)
|
(paths, locations)
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut paths_to_open = BTreeSet::new();
|
|
||||||
|
|
||||||
if !paths.is_empty() {
|
if !paths.is_empty() {
|
||||||
paths_to_open.extend(
|
paths_to_open.extend(
|
||||||
library
|
library
|
||||||
|
@ -343,35 +456,8 @@ pub async fn reveal_items(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for path in paths_to_open {
|
if let Err(e) = spawn_blocking(|| inner_reveal_paths(paths_to_open.into_iter())).await {
|
||||||
#[cfg(target_os = "linux")]
|
error!("Error joining reveal paths thread: {e:#?}");
|
||||||
if sd_desktop_linux::is_appimage() {
|
|
||||||
// This is a workaround for the app, when package inside an AppImage, crashing when using opener::reveal.
|
|
||||||
sd_desktop_linux::open_file_path(
|
|
||||||
&(if path.is_file() {
|
|
||||||
path.parent().unwrap_or(&path)
|
|
||||||
} else {
|
|
||||||
&path
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.map_err(|err| {
|
|
||||||
error!("Failed to open logs dir: {err}");
|
|
||||||
})
|
|
||||||
.ok()
|
|
||||||
} else {
|
|
||||||
opener::reveal(path)
|
|
||||||
.map_err(|err| {
|
|
||||||
error!("Failed to open logs dir: {err}");
|
|
||||||
})
|
|
||||||
.ok()
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
|
||||||
opener::reveal(path)
|
|
||||||
.map_err(|err| {
|
|
||||||
error!("Failed to open logs dir: {err}");
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -51,13 +51,13 @@ async fn open_logs_dir(node: tauri::State<'_, Arc<Node>>) -> Result<(), ()> {
|
||||||
let logs_path = node.data_dir.join("logs");
|
let logs_path = node.data_dir.join("logs");
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
let open_result = sd_desktop_linux::open_file_path(&logs_path);
|
let open_result = sd_desktop_linux::open_file_path(logs_path);
|
||||||
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
let open_result = opener::open(logs_path);
|
let open_result = opener::open(logs_path);
|
||||||
|
|
||||||
open_result.map_err(|err| {
|
open_result.map_err(|e| {
|
||||||
error!("Failed to open logs dir: {err}");
|
error!("Failed to open logs dir: {e:#?}");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ async fn main() -> tauri::Result<()> {
|
||||||
.plugin(sd_server_plugin(node.clone()).unwrap()) // TODO: Handle `unwrap`
|
.plugin(sd_server_plugin(node.clone()).unwrap()) // TODO: Handle `unwrap`
|
||||||
.manage(node),
|
.manage(node),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Error starting up the node: {err}");
|
error!("Error starting up the node: {err:#?}");
|
||||||
app.plugin(sd_error_plugin(err))
|
app.plugin(sd_error_plugin(err))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -153,13 +153,6 @@ async fn main() -> tauri::Result<()> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
{
|
|
||||||
if std::env::var("SD_DEVTOOLS").is_ok() {
|
|
||||||
window.open_devtools();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
window.set_decorations(true).unwrap();
|
window.set_decorations(true).unwrap();
|
||||||
|
|
||||||
|
@ -190,8 +183,11 @@ async fn main() -> tauri::Result<()> {
|
||||||
reset_spacedrive,
|
reset_spacedrive,
|
||||||
open_logs_dir,
|
open_logs_dir,
|
||||||
file::open_file_paths,
|
file::open_file_paths,
|
||||||
|
file::open_ephemeral_files,
|
||||||
file::get_file_path_open_with_apps,
|
file::get_file_path_open_with_apps,
|
||||||
|
file::get_ephemeral_files_open_with_apps,
|
||||||
file::open_file_path_with,
|
file::open_file_path_with,
|
||||||
|
file::open_ephemeral_file_with,
|
||||||
file::reveal_items,
|
file::reveal_items,
|
||||||
theme::lock_app_theme
|
theme::lock_app_theme
|
||||||
])
|
])
|
||||||
|
|
|
@ -65,6 +65,8 @@ const platform: Platform = {
|
||||||
.join('/')}.webp${queryParams}`,
|
.join('/')}.webp${queryParams}`,
|
||||||
getFileUrl: (libraryId, locationLocalId, filePathId) =>
|
getFileUrl: (libraryId, locationLocalId, filePathId) =>
|
||||||
`${customUriServerUrl}file/${libraryId}/${locationLocalId}/${filePathId}${queryParams}`,
|
`${customUriServerUrl}file/${libraryId}/${locationLocalId}/${filePathId}${queryParams}`,
|
||||||
|
getFileUrlByPath: (path) =>
|
||||||
|
`${customUriServerUrl}local-file-by-path/${encodeURIComponent(path)}${queryParams}`,
|
||||||
openLink: shell.open,
|
openLink: shell.open,
|
||||||
getOs,
|
getOs,
|
||||||
openDirectoryPickerDialog: () => dialog.open({ directory: true }),
|
openDirectoryPickerDialog: () => dialog.open({ directory: true }),
|
||||||
|
|
|
@ -26,14 +26,26 @@ export function openFilePaths(library: string, ids: number[]) {
|
||||||
return invoke()<OpenFilePathResult[]>("open_file_paths", { library,ids })
|
return invoke()<OpenFilePathResult[]>("open_file_paths", { library,ids })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function openEphemeralFiles(paths: string[]) {
|
||||||
|
return invoke()<EphemeralFileOpenResult[]>("open_ephemeral_files", { paths })
|
||||||
|
}
|
||||||
|
|
||||||
export function getFilePathOpenWithApps(library: string, ids: number[]) {
|
export function getFilePathOpenWithApps(library: string, ids: number[]) {
|
||||||
return invoke()<OpenWithApplication[]>("get_file_path_open_with_apps", { library,ids })
|
return invoke()<OpenWithApplication[]>("get_file_path_open_with_apps", { library,ids })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getEphemeralFilesOpenWithApps(paths: string[]) {
|
||||||
|
return invoke()<OpenWithApplication[]>("get_ephemeral_files_open_with_apps", { paths })
|
||||||
|
}
|
||||||
|
|
||||||
export function openFilePathWith(library: string, fileIdsAndUrls: ([number, string])[]) {
|
export function openFilePathWith(library: string, fileIdsAndUrls: ([number, string])[]) {
|
||||||
return invoke()<null>("open_file_path_with", { library,fileIdsAndUrls })
|
return invoke()<null>("open_file_path_with", { library,fileIdsAndUrls })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function openEphemeralFileWith(pathsAndUrls: ([string, string])[]) {
|
||||||
|
return invoke()<null>("open_ephemeral_file_with", { pathsAndUrls })
|
||||||
|
}
|
||||||
|
|
||||||
export function revealItems(library: string, items: RevealItem[]) {
|
export function revealItems(library: string, items: RevealItem[]) {
|
||||||
return invoke()<null>("reveal_items", { library,items })
|
return invoke()<null>("reveal_items", { library,items })
|
||||||
}
|
}
|
||||||
|
@ -43,6 +55,7 @@ export function lockAppTheme(themeType: AppThemeType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AppThemeType = "Auto" | "Light" | "Dark"
|
export type AppThemeType = "Auto" | "Light" | "Dark"
|
||||||
export type OpenFilePathResult = { t: "NoLibrary" } | { t: "NoFile"; c: number } | { t: "OpenError"; c: [number, string] } | { t: "AllGood"; c: number } | { t: "Internal"; c: string }
|
export type EphemeralFileOpenResult = { t: "Ok"; c: string } | { t: "Err"; c: string }
|
||||||
export type RevealItem = { Location: { id: number } } | { FilePath: { id: number } }
|
|
||||||
export type OpenWithApplication = { url: string; name: string }
|
export type OpenWithApplication = { url: string; name: string }
|
||||||
|
export type OpenFilePathResult = { t: "NoLibrary" } | { t: "NoFile"; c: number } | { t: "OpenError"; c: [number, string] } | { t: "AllGood"; c: number } | { t: "Internal"; c: string }
|
||||||
|
export type RevealItem = { Location: { id: number } } | { FilePath: { id: number } } | { Ephemeral: { path: string } }
|
||||||
|
|
|
@ -41,6 +41,7 @@ const platform: Platform = {
|
||||||
`${spacedriveURL}/file/${encodeURIComponent(libraryId)}/${encodeURIComponent(
|
`${spacedriveURL}/file/${encodeURIComponent(libraryId)}/${encodeURIComponent(
|
||||||
locationLocalId
|
locationLocalId
|
||||||
)}/${encodeURIComponent(filePathId)}`,
|
)}/${encodeURIComponent(filePathId)}`,
|
||||||
|
getFileUrlByPath: (path) => `${spacedriveURL}/local-file-by-path/${encodeURIComponent(path)}`,
|
||||||
openLink: (url) => window.open(url, '_blank')?.focus(),
|
openLink: (url) => window.open(url, '_blank')?.focus(),
|
||||||
confirm: (message, cb) => cb(window.confirm(message)),
|
confirm: (message, cb) => cb(window.confirm(message)),
|
||||||
auth: {
|
auth: {
|
||||||
|
|
|
@ -34,7 +34,7 @@ use mini_moka::sync::Cache;
|
||||||
use sd_file_ext::text::is_text;
|
use sd_file_ext::text::is_text;
|
||||||
use sd_p2p::{spaceblock::Range, spacetunnel::RemoteIdentity};
|
use sd_p2p::{spaceblock::Range, spacetunnel::RemoteIdentity};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
fs::File,
|
fs::{self, File},
|
||||||
io::{AsyncReadExt, AsyncSeekExt},
|
io::{AsyncReadExt, AsyncSeekExt},
|
||||||
};
|
};
|
||||||
use tokio_util::sync::PollSender;
|
use tokio_util::sync::PollSender;
|
||||||
|
@ -202,8 +202,8 @@ pub fn router(node: Arc<Node>) -> Router<()> {
|
||||||
|
|
||||||
match serve_from {
|
match serve_from {
|
||||||
ServeFrom::Local => {
|
ServeFrom::Local => {
|
||||||
let metadata = file_path_full_path
|
let metadata = fs::metadata(&file_path_full_path)
|
||||||
.metadata()
|
.await
|
||||||
.map_err(internal_server_error)?;
|
.map_err(internal_server_error)?;
|
||||||
(!metadata.is_dir())
|
(!metadata.is_dir())
|
||||||
.then_some(())
|
.then_some(())
|
||||||
|
@ -286,6 +286,43 @@ pub fn router(node: Arc<Node>) -> Router<()> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.route(
|
||||||
|
"/local-file-by-path/:path",
|
||||||
|
get(
|
||||||
|
|extract::Path(path): extract::Path<String>, request: Request<Body>| async move {
|
||||||
|
let path = PathBuf::from(path);
|
||||||
|
|
||||||
|
let metadata = fs::metadata(&path).await.map_err(internal_server_error)?;
|
||||||
|
(!metadata.is_dir())
|
||||||
|
.then_some(())
|
||||||
|
.ok_or_else(|| not_found(()))?;
|
||||||
|
|
||||||
|
let mut file = File::open(&path).await.map_err(|err| {
|
||||||
|
InfallibleResponse::builder()
|
||||||
|
.status(if err.kind() == io::ErrorKind::NotFound {
|
||||||
|
StatusCode::NOT_FOUND
|
||||||
|
} else {
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})
|
||||||
|
.body(body::boxed(Full::from("")))
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let resp = InfallibleResponse::builder().header(
|
||||||
|
"Content-Type",
|
||||||
|
HeaderValue::from_str(&match path.extension().and_then(OsStr::to_str) {
|
||||||
|
None => "text/plain".to_string(),
|
||||||
|
Some(ext) => infer_the_mime_type(ext, &mut file, &metadata).await?,
|
||||||
|
})
|
||||||
|
.map_err(|err| {
|
||||||
|
error!("Error converting mime-type into header value: {}", err);
|
||||||
|
internal_server_error(())
|
||||||
|
})?,
|
||||||
|
);
|
||||||
|
|
||||||
|
serve_file(file, Ok(metadata), request.into_parts().0, resp).await
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
.route_layer(middleware::from_fn(cors_middleware))
|
.route_layer(middleware::from_fn(cors_middleware))
|
||||||
.with_state({
|
.with_state({
|
||||||
let file_metadata_cache = Arc::new(Cache::new(150));
|
let file_metadata_cache = Arc::new(Cache::new(150));
|
||||||
|
@ -327,7 +364,8 @@ async fn infer_the_mime_type(
|
||||||
file: &mut File,
|
file: &mut File,
|
||||||
metadata: &Metadata,
|
metadata: &Metadata,
|
||||||
) -> Result<String, Response<BoxBody>> {
|
) -> Result<String, Response<BoxBody>> {
|
||||||
let mime_type = match ext.to_lowercase().as_str() {
|
let ext = ext.to_lowercase();
|
||||||
|
let mime_type = match ext.as_str() {
|
||||||
// AAC audio
|
// AAC audio
|
||||||
"aac" => "audio/aac",
|
"aac" => "audio/aac",
|
||||||
// Musical Instrument Digital Interface (MIDI)
|
// Musical Instrument Digital Interface (MIDI)
|
||||||
|
@ -416,7 +454,7 @@ async fn infer_the_mime_type(
|
||||||
|
|
||||||
// Only browser recognized types, everything else should be text/plain
|
// Only browser recognized types, everything else should be text/plain
|
||||||
// https://www.iana.org/assignments/media-types/media-types.xhtml#table-text
|
// https://www.iana.org/assignments/media-types/media-types.xhtml#table-text
|
||||||
let mime_type = match ext {
|
let mime_type = match ext.as_str() {
|
||||||
// HyperText Markup Language
|
// HyperText Markup Language
|
||||||
"html" | "htm" => "text/html",
|
"html" | "htm" => "text/html",
|
||||||
// Cascading Style Sheets
|
// Cascading Style Sheets
|
||||||
|
|
|
@ -160,6 +160,8 @@ pub fn path_is_hidden(path: &Path, metadata: &Metadata) -> bool {
|
||||||
|
|
||||||
const FILE_ATTRIBUTE_HIDDEN: u32 = 0x2;
|
const FILE_ATTRIBUTE_HIDDEN: u32 = 0x2;
|
||||||
|
|
||||||
|
let _ = path; // just to avoid warnings on Windows
|
||||||
|
|
||||||
if (metadata.file_attributes() & FILE_ATTRIBUTE_HIDDEN) == FILE_ATTRIBUTE_HIDDEN {
|
if (metadata.file_attributes() & FILE_ATTRIBUTE_HIDDEN) == FILE_ATTRIBUTE_HIDDEN {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,13 @@ import { ContextMenu, dialogManager, ModifierKeys, toast } from '@sd/ui';
|
||||||
import { Menu } from '~/components/Menu';
|
import { Menu } from '~/components/Menu';
|
||||||
import { useKeybindFactory } from '~/hooks/useKeybindFactory';
|
import { useKeybindFactory } from '~/hooks/useKeybindFactory';
|
||||||
import { isNonEmpty } from '~/util';
|
import { isNonEmpty } from '~/util';
|
||||||
import { usePlatform } from '~/util/Platform';
|
|
||||||
|
|
||||||
import { useExplorerContext } from '../../Context';
|
import { useExplorerContext } from '../../Context';
|
||||||
import { CopyAsPathBase } from '../../CopyAsPath';
|
import { CopyAsPathBase } from '../../CopyAsPath';
|
||||||
import DeleteDialog from '../../FilePath/DeleteDialog';
|
import DeleteDialog from '../../FilePath/DeleteDialog';
|
||||||
import EraseDialog from '../../FilePath/EraseDialog';
|
import EraseDialog from '../../FilePath/EraseDialog';
|
||||||
import { useViewItemDoubleClick } from '../../View/ViewItem';
|
import { ConditionalItem } from '../ConditionalItem';
|
||||||
import { Conditional, ConditionalItem } from '../ConditionalItem';
|
|
||||||
import { useContextMenuContext } from '../context';
|
import { useContextMenuContext } from '../context';
|
||||||
import OpenWith from './OpenWith';
|
|
||||||
|
|
||||||
export * from './CutCopyItems';
|
export * from './CutCopyItems';
|
||||||
|
|
||||||
|
@ -228,32 +225,3 @@ export const ParentFolderActions = new ConditionalItem({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const OpenOrDownload = new ConditionalItem({
|
|
||||||
useCondition: () => {
|
|
||||||
const { selectedFilePaths } = useContextMenuContext();
|
|
||||||
const { openFilePaths } = usePlatform();
|
|
||||||
|
|
||||||
if (!openFilePaths || !isNonEmpty(selectedFilePaths)) return null;
|
|
||||||
|
|
||||||
return { openFilePaths, selectedFilePaths };
|
|
||||||
},
|
|
||||||
Component: () => {
|
|
||||||
const keybind = useKeybindFactory();
|
|
||||||
const { platform } = usePlatform();
|
|
||||||
const { doubleClick } = useViewItemDoubleClick();
|
|
||||||
|
|
||||||
if (platform === 'web') return <Menu.Item label="Download" />;
|
|
||||||
else
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Menu.Item
|
|
||||||
label="Open"
|
|
||||||
keybind={keybind([ModifierKeys.Control], ['O'])}
|
|
||||||
onClick={() => doubleClick()}
|
|
||||||
/>
|
|
||||||
<Conditional items={[OpenWith]} />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,77 +0,0 @@
|
||||||
import { useQuery } from '@tanstack/react-query';
|
|
||||||
import { Suspense } from 'react';
|
|
||||||
import { useLibraryContext } from '@sd/client';
|
|
||||||
import { toast } from '@sd/ui';
|
|
||||||
import { Menu } from '~/components/Menu';
|
|
||||||
import { Platform, usePlatform } from '~/util/Platform';
|
|
||||||
|
|
||||||
import { ConditionalItem } from '../ConditionalItem';
|
|
||||||
import { useContextMenuContext } from '../context';
|
|
||||||
|
|
||||||
export default new ConditionalItem({
|
|
||||||
useCondition: () => {
|
|
||||||
const { selectedFilePaths } = useContextMenuContext();
|
|
||||||
const { getFilePathOpenWithApps, openFilePathWith } = usePlatform();
|
|
||||||
|
|
||||||
if (!getFilePathOpenWithApps || !openFilePathWith) return null;
|
|
||||||
if (selectedFilePaths.some((p) => p.is_dir)) return null;
|
|
||||||
|
|
||||||
return { getFilePathOpenWithApps, openFilePathWith };
|
|
||||||
},
|
|
||||||
Component: ({ getFilePathOpenWithApps, openFilePathWith }) => (
|
|
||||||
<Menu.SubMenu label="Open with">
|
|
||||||
<Suspense>
|
|
||||||
<Items
|
|
||||||
actions={{
|
|
||||||
getFilePathOpenWithApps,
|
|
||||||
openFilePathWith
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Suspense>
|
|
||||||
</Menu.SubMenu>
|
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
const Items = ({
|
|
||||||
actions
|
|
||||||
}: {
|
|
||||||
actions: Required<Pick<Platform, 'getFilePathOpenWithApps' | 'openFilePathWith'>>;
|
|
||||||
}) => {
|
|
||||||
const { selectedFilePaths } = useContextMenuContext();
|
|
||||||
|
|
||||||
const { library } = useLibraryContext();
|
|
||||||
|
|
||||||
const ids = selectedFilePaths.map((obj) => obj.id);
|
|
||||||
|
|
||||||
const items = useQuery<unknown>(
|
|
||||||
['openWith', ids],
|
|
||||||
() => actions.getFilePathOpenWithApps(library.uuid, ids),
|
|
||||||
{ suspense: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{Array.isArray(items.data) && items.data.length > 0 ? (
|
|
||||||
items.data.map((data, id) => (
|
|
||||||
<Menu.Item
|
|
||||||
key={id}
|
|
||||||
onClick={async () => {
|
|
||||||
try {
|
|
||||||
await actions.openFilePathWith(
|
|
||||||
library.uuid,
|
|
||||||
ids.map((id) => [id, data.url])
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
toast.error(`Failed to open file, with: ${data.url}`);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{data.name}
|
|
||||||
</Menu.Item>
|
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<p className="w-full text-center text-sm text-gray-400"> No apps available </p>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
120
interface/app/$libraryId/Explorer/ContextMenu/OpenWith.tsx
Normal file
120
interface/app/$libraryId/Explorer/ContextMenu/OpenWith.tsx
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
import { Suspense } from 'react';
|
||||||
|
import { useLibraryContext } from '@sd/client';
|
||||||
|
import { toast } from '@sd/ui';
|
||||||
|
import { Menu } from '~/components/Menu';
|
||||||
|
import { Platform, usePlatform } from '~/util/Platform';
|
||||||
|
|
||||||
|
import { ConditionalItem } from './ConditionalItem';
|
||||||
|
import { useContextMenuContext } from './context';
|
||||||
|
|
||||||
|
export default new ConditionalItem({
|
||||||
|
useCondition: () => {
|
||||||
|
const { selectedFilePaths, selectedEphemeralPaths } = useContextMenuContext();
|
||||||
|
const {
|
||||||
|
getFilePathOpenWithApps,
|
||||||
|
openFilePathWith,
|
||||||
|
getEphemeralFilesOpenWithApps,
|
||||||
|
openEphemeralFileWith
|
||||||
|
} = usePlatform();
|
||||||
|
|
||||||
|
if (
|
||||||
|
!getFilePathOpenWithApps ||
|
||||||
|
!openFilePathWith ||
|
||||||
|
!getEphemeralFilesOpenWithApps ||
|
||||||
|
!openEphemeralFileWith
|
||||||
|
)
|
||||||
|
return null;
|
||||||
|
if (selectedFilePaths.some((p) => p.is_dir) || selectedEphemeralPaths.some((p) => p.is_dir))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
getFilePathOpenWithApps,
|
||||||
|
openFilePathWith,
|
||||||
|
getEphemeralFilesOpenWithApps,
|
||||||
|
openEphemeralFileWith
|
||||||
|
};
|
||||||
|
},
|
||||||
|
Component: ({
|
||||||
|
getFilePathOpenWithApps,
|
||||||
|
openFilePathWith,
|
||||||
|
getEphemeralFilesOpenWithApps,
|
||||||
|
openEphemeralFileWith
|
||||||
|
}) => (
|
||||||
|
<Menu.SubMenu label="Open with">
|
||||||
|
<Suspense>
|
||||||
|
<Items
|
||||||
|
actions={{
|
||||||
|
getFilePathOpenWithApps,
|
||||||
|
openFilePathWith,
|
||||||
|
getEphemeralFilesOpenWithApps,
|
||||||
|
openEphemeralFileWith
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
</Menu.SubMenu>
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
const Items = ({
|
||||||
|
actions
|
||||||
|
}: {
|
||||||
|
actions: Required<
|
||||||
|
Pick<
|
||||||
|
Platform,
|
||||||
|
| 'getFilePathOpenWithApps'
|
||||||
|
| 'openFilePathWith'
|
||||||
|
| 'getEphemeralFilesOpenWithApps'
|
||||||
|
| 'openEphemeralFileWith'
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
}) => {
|
||||||
|
const { selectedFilePaths, selectedEphemeralPaths } = useContextMenuContext();
|
||||||
|
|
||||||
|
const { library } = useLibraryContext();
|
||||||
|
|
||||||
|
const ids = selectedFilePaths.map((obj) => obj.id);
|
||||||
|
const paths = selectedEphemeralPaths.map((obj) => obj.path);
|
||||||
|
|
||||||
|
const items = useQuery<unknown>(
|
||||||
|
['openWith', ids, paths],
|
||||||
|
() => {
|
||||||
|
if (ids.length > 0) return actions.getFilePathOpenWithApps(library.uuid, ids);
|
||||||
|
else if (paths.length > 0) return actions.getEphemeralFilesOpenWithApps(paths);
|
||||||
|
else return { data: [] };
|
||||||
|
},
|
||||||
|
{ suspense: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{Array.isArray(items.data) && items.data.length > 0 ? (
|
||||||
|
items.data.map((data, index) => (
|
||||||
|
<Menu.Item
|
||||||
|
key={index}
|
||||||
|
onClick={async () => {
|
||||||
|
try {
|
||||||
|
if (ids.length > 0) {
|
||||||
|
await actions.openFilePathWith(
|
||||||
|
library.uuid,
|
||||||
|
ids.map((id) => [id, data.url])
|
||||||
|
);
|
||||||
|
} else if (paths.length > 0) {
|
||||||
|
await actions.openEphemeralFileWith(
|
||||||
|
paths.map((path) => [path, data.url])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
toast.error(`Failed to open file, with: ${data.url}`);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{data.name}
|
||||||
|
</Menu.Item>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<p className="w-full text-center text-sm text-gray-400"> No apps available </p>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
|
@ -1,18 +1,57 @@
|
||||||
|
// tsc requires this import due to global types defined on it
|
||||||
|
import type {} from '@sd/client';
|
||||||
|
|
||||||
import { FileX, Share as ShareIcon } from '@phosphor-icons/react';
|
import { FileX, Share as ShareIcon } from '@phosphor-icons/react';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { ContextMenu, ModifierKeys } from '@sd/ui';
|
import { ContextMenu, ModifierKeys, toast } from '@sd/ui';
|
||||||
import { Menu } from '~/components/Menu';
|
import { Menu } from '~/components/Menu';
|
||||||
import { useKeybindFactory } from '~/hooks/useKeybindFactory';
|
import { useKeybindFactory } from '~/hooks/useKeybindFactory';
|
||||||
import { isNonEmpty } from '~/util';
|
import { isNonEmpty } from '~/util';
|
||||||
import { type Platform } from '~/util/Platform';
|
import { usePlatform, type Platform } from '~/util/Platform';
|
||||||
|
|
||||||
import { useExplorerContext } from '../Context';
|
import { useExplorerContext } from '../Context';
|
||||||
import { getQuickPreviewStore } from '../QuickPreview/store';
|
import { getQuickPreviewStore } from '../QuickPreview/store';
|
||||||
import { RevealInNativeExplorerBase } from '../RevealInNativeExplorer';
|
import { RevealInNativeExplorerBase } from '../RevealInNativeExplorer';
|
||||||
import { getExplorerStore, useExplorerStore } from '../store';
|
import { getExplorerStore, useExplorerStore } from '../store';
|
||||||
|
import { useViewItemDoubleClick } from '../View/ViewItem';
|
||||||
import { useExplorerViewContext } from '../ViewContext';
|
import { useExplorerViewContext } from '../ViewContext';
|
||||||
import { ConditionalItem } from './ConditionalItem';
|
import { Conditional, ConditionalItem } from './ConditionalItem';
|
||||||
import { useContextMenuContext } from './context';
|
import { useContextMenuContext } from './context';
|
||||||
|
import OpenWith from './OpenWith';
|
||||||
|
|
||||||
|
export const OpenOrDownload = new ConditionalItem({
|
||||||
|
useCondition: () => {
|
||||||
|
const { selectedFilePaths, selectedEphemeralPaths } = useContextMenuContext();
|
||||||
|
const { openFilePaths, openEphemeralFiles } = usePlatform();
|
||||||
|
|
||||||
|
if (
|
||||||
|
!openFilePaths ||
|
||||||
|
!openEphemeralFiles ||
|
||||||
|
(!isNonEmpty(selectedFilePaths) && !isNonEmpty(selectedEphemeralPaths))
|
||||||
|
)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return { openFilePaths, openEphemeralFiles, selectedFilePaths, selectedEphemeralPaths };
|
||||||
|
},
|
||||||
|
Component: () => {
|
||||||
|
const keybind = useKeybindFactory();
|
||||||
|
const { platform } = usePlatform();
|
||||||
|
const { doubleClick } = useViewItemDoubleClick();
|
||||||
|
|
||||||
|
if (platform === 'web') return <Menu.Item label="Download" />;
|
||||||
|
else
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Menu.Item
|
||||||
|
label="Open"
|
||||||
|
keybind={keybind([ModifierKeys.Control], ['O'])}
|
||||||
|
onClick={() => doubleClick()}
|
||||||
|
/>
|
||||||
|
<Conditional items={[OpenWith]} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
export const OpenQuickView = () => {
|
export const OpenQuickView = () => {
|
||||||
const keybind = useKeybindFactory();
|
const keybind = useKeybindFactory();
|
||||||
|
@ -111,6 +150,14 @@ export const RevealInNativeExplorer = new ConditionalItem({
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'NonIndexedPath': {
|
||||||
|
array.push({
|
||||||
|
Ephemeral: {
|
||||||
|
path: item.item.path
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
import { createContext, PropsWithChildren, useContext } from 'react';
|
import { createContext, PropsWithChildren, useContext } from 'react';
|
||||||
import { ExplorerItem, FilePath, Object, useItemsAsFilePaths, useItemsAsObjects } from '@sd/client';
|
import {
|
||||||
|
ExplorerItem,
|
||||||
|
FilePath,
|
||||||
|
NonIndexedPathItem,
|
||||||
|
Object,
|
||||||
|
useItemsAsEphemeralPaths,
|
||||||
|
useItemsAsFilePaths,
|
||||||
|
useItemsAsObjects
|
||||||
|
} from '@sd/client';
|
||||||
import { NonEmptyArray } from '~/util';
|
import { NonEmptyArray } from '~/util';
|
||||||
|
|
||||||
const ContextMenuContext = createContext<{
|
const ContextMenuContext = createContext<{
|
||||||
selectedItems: NonEmptyArray<ExplorerItem>;
|
selectedItems: NonEmptyArray<ExplorerItem>;
|
||||||
selectedFilePaths: FilePath[];
|
selectedFilePaths: FilePath[];
|
||||||
selectedObjects: Object[];
|
selectedObjects: Object[];
|
||||||
|
selectedEphemeralPaths: NonIndexedPathItem[];
|
||||||
} | null>(null);
|
} | null>(null);
|
||||||
|
|
||||||
export const ContextMenuContextProvider = ({
|
export const ContextMenuContextProvider = ({
|
||||||
|
@ -16,9 +25,12 @@ export const ContextMenuContextProvider = ({
|
||||||
}>) => {
|
}>) => {
|
||||||
const selectedFilePaths = useItemsAsFilePaths(selectedItems);
|
const selectedFilePaths = useItemsAsFilePaths(selectedItems);
|
||||||
const selectedObjects = useItemsAsObjects(selectedItems);
|
const selectedObjects = useItemsAsObjects(selectedItems);
|
||||||
|
const selectedEphemeralPaths = useItemsAsEphemeralPaths(selectedItems);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContextMenuContext.Provider value={{ selectedItems, selectedFilePaths, selectedObjects }}>
|
<ContextMenuContext.Provider
|
||||||
|
value={{ selectedItems, selectedFilePaths, selectedObjects, selectedEphemeralPaths }}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</ContextMenuContext.Provider>
|
</ContextMenuContext.Provider>
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,7 +17,7 @@ export * as SharedItems from './SharedItems';
|
||||||
|
|
||||||
const Items = ({ children }: PropsWithChildren) => (
|
const Items = ({ children }: PropsWithChildren) => (
|
||||||
<>
|
<>
|
||||||
<Conditional items={[FilePathItems.OpenOrDownload]} />
|
<Conditional items={[SharedItems.OpenOrDownload]} />
|
||||||
<SharedItems.OpenQuickView />
|
<SharedItems.OpenQuickView />
|
||||||
|
|
||||||
<SeparatedConditional items={[SharedItems.Details]} />
|
<SeparatedConditional items={[SharedItems.Details]} />
|
||||||
|
|
|
@ -102,13 +102,10 @@ export const FileThumb = memo((props: ThumbProps) => {
|
||||||
|
|
||||||
switch (thumbType) {
|
switch (thumbType) {
|
||||||
case ThumbType.Original:
|
case ThumbType.Original:
|
||||||
if (
|
if (filePath && (itemData.extension !== 'pdf' || pdfViewerEnabled())) {
|
||||||
locationId &&
|
if ('id' in filePath && locationId)
|
||||||
filePath &&
|
setSrc(platform.getFileUrl(library.uuid, locationId, filePath.id));
|
||||||
'id' in filePath &&
|
else if ('path' in filePath) setSrc(platform.getFileUrlByPath(filePath.path));
|
||||||
(itemData.extension !== 'pdf' || pdfViewerEnabled())
|
|
||||||
) {
|
|
||||||
setSrc(platform.getFileUrl(library.uuid, locationId, filePath.id));
|
|
||||||
} else {
|
} else {
|
||||||
setThumbType(ThumbType.Thumbnail);
|
setThumbType(ThumbType.Thumbnail);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,13 @@ import { useLocation } from 'react-router';
|
||||||
import { Link as NavLink } from 'react-router-dom';
|
import { Link as NavLink } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
byteSize,
|
byteSize,
|
||||||
|
FilePath,
|
||||||
|
FilePathWithObject,
|
||||||
getExplorerItemData,
|
getExplorerItemData,
|
||||||
getItemFilePath,
|
NonIndexedPathItem,
|
||||||
getItemObject,
|
Object,
|
||||||
ObjectKindEnum,
|
ObjectKindEnum,
|
||||||
|
ObjectWithFilePaths,
|
||||||
useBridgeQuery,
|
useBridgeQuery,
|
||||||
useItemsAsObjects,
|
useItemsAsObjects,
|
||||||
useLibraryQuery,
|
useLibraryQuery,
|
||||||
|
@ -158,52 +161,67 @@ const Thumbnails = ({ items }: { items: ExplorerItem[] }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SingleItemMetadata = ({ item }: { item: ExplorerItem }) => {
|
export const SingleItemMetadata = ({ item }: { item: ExplorerItem }) => {
|
||||||
const objectData = getItemObject(item);
|
let objectData: Object | ObjectWithFilePaths | null = null;
|
||||||
|
let filePathData: FilePath | FilePathWithObject | null = null;
|
||||||
|
let ephemeralPathData: NonIndexedPathItem | null = null;
|
||||||
|
|
||||||
|
switch (item.type) {
|
||||||
|
case 'NonIndexedPath': {
|
||||||
|
ephemeralPathData = item.item;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Path': {
|
||||||
|
objectData = item.item.object;
|
||||||
|
filePathData = item.item;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Object': {
|
||||||
|
objectData = item.item;
|
||||||
|
filePathData = item.item.file_paths[0] ?? null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const readyToFetch = useIsFetchReady(item);
|
const readyToFetch = useIsFetchReady(item);
|
||||||
const isNonIndexed = item.type === 'NonIndexedPath';
|
|
||||||
const tags = useLibraryQuery(['tags.getForObject', objectData?.id ?? -1], {
|
const tags = useLibraryQuery(['tags.getForObject', objectData?.id ?? -1], {
|
||||||
enabled: !!objectData && readyToFetch
|
enabled: objectData != null && readyToFetch
|
||||||
});
|
});
|
||||||
const { libraryId } = useZodRouteParams(LibraryIdParamsSchema);
|
const { libraryId } = useZodRouteParams(LibraryIdParamsSchema);
|
||||||
|
|
||||||
const object = useLibraryQuery(['files.get', { id: objectData?.id ?? -1 }], {
|
const queriedFullPath = useLibraryQuery(['files.getPath', filePathData?.id ?? -1], {
|
||||||
enabled: !!objectData && readyToFetch
|
enabled: filePathData != null && readyToFetch
|
||||||
});
|
});
|
||||||
|
|
||||||
const filePath = useLibraryQuery(['files.getPath', objectData?.id ?? -1], {
|
|
||||||
enabled: !!objectData && readyToFetch
|
|
||||||
});
|
|
||||||
|
|
||||||
//Images are only supported currently - kind = 5
|
|
||||||
const filesMediaData = useLibraryQuery(['files.getMediaData', objectData?.id ?? -1], {
|
const filesMediaData = useLibraryQuery(['files.getMediaData', objectData?.id ?? -1], {
|
||||||
enabled: objectData?.kind === ObjectKindEnum.Image && !isNonIndexed && readyToFetch
|
enabled: objectData?.kind === ObjectKindEnum.Image && readyToFetch
|
||||||
});
|
});
|
||||||
|
|
||||||
const ephemeralLocationMediaData = useBridgeQuery(
|
const ephemeralLocationMediaData = useBridgeQuery(
|
||||||
['files.getEphemeralMediaData', isNonIndexed ? item.item.path : ''],
|
['files.getEphemeralMediaData', ephemeralPathData != null ? ephemeralPathData.path : ''],
|
||||||
{
|
{
|
||||||
enabled: isNonIndexed && item.item.kind === 5 && readyToFetch
|
enabled: ephemeralPathData?.kind === ObjectKindEnum.Image && readyToFetch
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const mediaData = filesMediaData ?? ephemeralLocationMediaData ?? null;
|
const mediaData = filesMediaData ?? ephemeralLocationMediaData ?? null;
|
||||||
|
|
||||||
if (filePath.data == null && item.type === 'NonIndexedPath') {
|
const fullPath = queriedFullPath.data ?? ephemeralPathData?.path;
|
||||||
filePath.data = item.item.path;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { name, isDir, kind, size, casId, dateCreated, dateAccessed, dateModified, dateIndexed } =
|
const { name, isDir, kind, size, casId, dateCreated, dateAccessed, dateModified, dateIndexed } =
|
||||||
useExplorerItemData(item);
|
useExplorerItemData(item);
|
||||||
|
|
||||||
const pubId = object?.data ? uniqueId(object?.data) : null;
|
const pubId = objectData != null ? uniqueId(objectData) : null;
|
||||||
|
|
||||||
const filePathItem = getItemFilePath(item);
|
|
||||||
let extension, integrityChecksum;
|
let extension, integrityChecksum;
|
||||||
|
|
||||||
if (filePathItem) {
|
if (filePathData != null) {
|
||||||
extension = filePathItem.extension;
|
extension = filePathData.extension;
|
||||||
integrityChecksum =
|
integrityChecksum =
|
||||||
'integrity_checksum' in filePathItem ? filePathItem.integrity_checksum : null;
|
'integrity_checksum' in filePathData ? filePathData.integrity_checksum : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ephemeralPathData != null) {
|
||||||
|
extension = ephemeralPathData.extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -241,21 +259,21 @@ export const SingleItemMetadata = ({ item }: { item: ExplorerItem }) => {
|
||||||
|
|
||||||
<MetaData icon={Eraser} label="Modified" value={formatDate(dateModified)} />
|
<MetaData icon={Eraser} label="Modified" value={formatDate(dateModified)} />
|
||||||
|
|
||||||
{isNonIndexed || (
|
{ephemeralPathData != null || (
|
||||||
<MetaData icon={Barcode} label="Indexed" value={formatDate(dateIndexed)} />
|
<MetaData icon={Barcode} label="Indexed" value={formatDate(dateIndexed)} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isNonIndexed || (
|
{ephemeralPathData != null || (
|
||||||
<MetaData icon={FolderOpen} label="Accessed" value={formatDate(dateAccessed)} />
|
<MetaData icon={FolderOpen} label="Accessed" value={formatDate(dateAccessed)} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<MetaData
|
<MetaData
|
||||||
icon={Path}
|
icon={Path}
|
||||||
label="Path"
|
label="Path"
|
||||||
value={filePath.data}
|
value={fullPath}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
// TODO: Add toast notification
|
// TODO: Add toast notification
|
||||||
filePath.data && navigator.clipboard.writeText(filePath.data);
|
fullPath && navigator.clipboard.writeText(fullPath);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</MetaContainer>
|
</MetaContainer>
|
||||||
|
@ -299,9 +317,7 @@ export const SingleItemMetadata = ({ item }: { item: ExplorerItem }) => {
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|
||||||
<MetaContainer>
|
<MetaContainer>
|
||||||
{isNonIndexed || (
|
<MetaData icon={Snowflake} label="Content ID" value={casId} />
|
||||||
<MetaData icon={Snowflake} label="Content ID" value={casId} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{integrityChecksum && (
|
{integrityChecksum && (
|
||||||
<MetaData
|
<MetaData
|
||||||
|
@ -311,7 +327,7 @@ export const SingleItemMetadata = ({ item }: { item: ExplorerItem }) => {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isNonIndexed || <MetaData icon={Hash} label="Object ID" value={pubId} />}
|
<MetaData icon={Hash} label="Object ID" value={pubId} />
|
||||||
</MetaContainer>
|
</MetaContainer>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -56,7 +56,7 @@ export const QuickPreview = () => {
|
||||||
const rspc = useRspcLibraryContext();
|
const rspc = useRspcLibraryContext();
|
||||||
const isDark = useIsDark();
|
const isDark = useIsDark();
|
||||||
const { library } = useLibraryContext();
|
const { library } = useLibraryContext();
|
||||||
const { openFilePaths, revealItems } = usePlatform();
|
const { openFilePaths, revealItems, openEphemeralFiles } = usePlatform();
|
||||||
|
|
||||||
const explorer = useExplorerContext();
|
const explorer = useExplorerContext();
|
||||||
const { open, itemIndex } = useQuickPreviewStore();
|
const { open, itemIndex } = useQuickPreviewStore();
|
||||||
|
@ -117,14 +117,18 @@ export const QuickPreview = () => {
|
||||||
|
|
||||||
// Open file
|
// Open file
|
||||||
useKeybind([os === 'macOS' ? ModifierKeys.Meta : ModifierKeys.Control, 'o'], () => {
|
useKeybind([os === 'macOS' ? ModifierKeys.Meta : ModifierKeys.Control, 'o'], () => {
|
||||||
if (!item || !openFilePaths) return;
|
if (!item || !openFilePaths || !openEphemeralFiles) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const path = getIndexedItemFilePath(item);
|
if (item.type === 'Path' || item.type === 'Object') {
|
||||||
|
const path = getIndexedItemFilePath(item);
|
||||||
|
|
||||||
if (!path) throw 'No path found';
|
if (!path) throw 'No path found';
|
||||||
|
|
||||||
openFilePaths(library.uuid, [path.id]);
|
openFilePaths(library.uuid, [path.id]);
|
||||||
|
} else if (item.type === 'NonIndexedPath') {
|
||||||
|
openEphemeralFiles([item.item.path]);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error({
|
toast.error({
|
||||||
title: 'Failed to open file',
|
title: 'Failed to open file',
|
||||||
|
@ -138,13 +142,18 @@ export const QuickPreview = () => {
|
||||||
if (!item || !revealItems) return;
|
if (!item || !revealItems) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const id = item.type === 'Location' ? item.item.id : getIndexedItemFilePath(item)?.id;
|
const toReveal = [];
|
||||||
|
if (item.type === 'Location') {
|
||||||
|
toReveal.push({ Location: { id: item.item.id } });
|
||||||
|
} else if (item.type === 'NonIndexedPath') {
|
||||||
|
toReveal.push({ Ephemeral: { path: item.item.path } });
|
||||||
|
} else {
|
||||||
|
const filePath = getIndexedItemFilePath(item);
|
||||||
|
if (!filePath) throw 'No file path found';
|
||||||
|
toReveal.push({ FilePath: { id: filePath.id } });
|
||||||
|
}
|
||||||
|
|
||||||
if (!id) throw 'No id found';
|
revealItems(library.uuid, toReveal);
|
||||||
|
|
||||||
revealItems(library.uuid, [
|
|
||||||
{ ...(item.type === 'Location' ? { Location: { id } } : { FilePath: { id } }) }
|
|
||||||
]);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error({
|
toast.error({
|
||||||
title: 'Failed to reveal',
|
title: 'Failed to reveal',
|
||||||
|
@ -313,66 +322,63 @@ export const QuickPreview = () => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-1 justify-end gap-1">
|
<div className="flex flex-1 justify-end gap-1">
|
||||||
{item.type !== 'NonIndexedPath' && (
|
<DropdownMenu.Root
|
||||||
<DropdownMenu.Root
|
trigger={
|
||||||
trigger={
|
<div className="flex">
|
||||||
<div className="flex">
|
<Tooltip label="More">
|
||||||
<Tooltip label="More">
|
<IconButton>
|
||||||
<IconButton>
|
<DotsThree size={20} weight="bold" />
|
||||||
<DotsThree
|
</IconButton>
|
||||||
size={20}
|
</Tooltip>
|
||||||
weight="bold"
|
</div>
|
||||||
/>
|
}
|
||||||
</IconButton>
|
onOpenChange={setIsContextMenuOpen}
|
||||||
</Tooltip>
|
align="end"
|
||||||
</div>
|
sideOffset={-10}
|
||||||
}
|
>
|
||||||
onOpenChange={setIsContextMenuOpen}
|
<ExplorerContextMenu items={[item]} custom>
|
||||||
align="end"
|
<Conditional
|
||||||
sideOffset={-10}
|
items={[
|
||||||
>
|
SharedItems.OpenOrDownload,
|
||||||
<ExplorerContextMenu items={[item]} custom>
|
SharedItems.RevealInNativeExplorer
|
||||||
<Conditional
|
]}
|
||||||
items={[
|
/>
|
||||||
FilePathItems.OpenOrDownload,
|
|
||||||
SharedItems.RevealInNativeExplorer
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
|
|
||||||
|
{item.type !== 'NonIndexedPath' && (
|
||||||
<DropdownMenu.Item
|
<DropdownMenu.Item
|
||||||
label="Rename"
|
label="Rename"
|
||||||
onClick={() => name && setIsRenaming(true)}
|
onClick={() => name && setIsRenaming(true)}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<SeparatedConditional
|
<SeparatedConditional
|
||||||
items={[ObjectItems.AssignTag]}
|
items={[ObjectItems.AssignTag]}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Conditional
|
<Conditional
|
||||||
items={[
|
items={[
|
||||||
FilePathItems.CopyAsPath,
|
FilePathItems.CopyAsPath,
|
||||||
FilePathItems.Crypto,
|
FilePathItems.Crypto,
|
||||||
FilePathItems.Compress,
|
FilePathItems.Compress,
|
||||||
ObjectItems.ConvertObject,
|
ObjectItems.ConvertObject,
|
||||||
FilePathItems.SecureDelete
|
FilePathItems.SecureDelete
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{(items) => (
|
{(items) => (
|
||||||
<DropdownMenu.SubMenu
|
<DropdownMenu.SubMenu
|
||||||
label="More actions..."
|
label="More actions..."
|
||||||
icon={Plus}
|
icon={Plus}
|
||||||
>
|
>
|
||||||
{items}
|
{items}
|
||||||
</DropdownMenu.SubMenu>
|
</DropdownMenu.SubMenu>
|
||||||
)}
|
)}
|
||||||
</Conditional>
|
</Conditional>
|
||||||
|
|
||||||
<SeparatedConditional
|
<SeparatedConditional
|
||||||
items={[FilePathItems.Delete]}
|
items={[FilePathItems.Delete]}
|
||||||
/>
|
/>
|
||||||
</ExplorerContextMenu>
|
</ExplorerContextMenu>
|
||||||
</DropdownMenu.Root>
|
</DropdownMenu.Root>
|
||||||
)}
|
|
||||||
|
|
||||||
<Tooltip label="Show details">
|
<Tooltip label="Show details">
|
||||||
<IconButton
|
<IconButton
|
||||||
|
|
|
@ -22,7 +22,7 @@ export const useViewItemDoubleClick = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const explorer = useExplorerContext();
|
const explorer = useExplorerContext();
|
||||||
const { library } = useLibraryContext();
|
const { library } = useLibraryContext();
|
||||||
const { openFilePaths } = usePlatform();
|
const { openFilePaths, openEphemeralFiles } = usePlatform();
|
||||||
|
|
||||||
const updateAccessTime = useLibraryMutation('files.updateAccessTime');
|
const updateAccessTime = useLibraryMutation('files.updateAccessTime');
|
||||||
|
|
||||||
|
@ -127,12 +127,28 @@ export const useViewItemDoubleClick = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.non_indexed.length > 0) {
|
if (items.non_indexed.length > 0) {
|
||||||
const [non_indexed] = items.non_indexed;
|
if (items.non_indexed.length === 1) {
|
||||||
if (non_indexed) {
|
const [non_indexed] = items.non_indexed;
|
||||||
navigate({
|
if (non_indexed && non_indexed.is_dir) {
|
||||||
search: createSearchParams({ path: non_indexed.path }).toString()
|
navigate({
|
||||||
});
|
search: createSearchParams({ path: non_indexed.path }).toString()
|
||||||
return;
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (explorer.settingsStore.openOnDoubleClick === 'openFile' && openEphemeralFiles) {
|
||||||
|
try {
|
||||||
|
await openEphemeralFiles(items.non_indexed.map(({ path }) => path));
|
||||||
|
} catch (error) {
|
||||||
|
toast.error({ title: 'Failed to open file', body: `Error: ${error}.` });
|
||||||
|
}
|
||||||
|
} else if (item && explorer.settingsStore.openOnDoubleClick === 'quickPreview') {
|
||||||
|
if (item.type !== 'Location' && !(isPath(item) && item.item.is_dir)) {
|
||||||
|
getQuickPreviewStore().itemIndex = itemIndex;
|
||||||
|
getQuickPreviewStore().open = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -142,6 +158,7 @@ export const useViewItemDoubleClick = () => {
|
||||||
library.uuid,
|
library.uuid,
|
||||||
navigate,
|
navigate,
|
||||||
openFilePaths,
|
openFilePaths,
|
||||||
|
openEphemeralFiles,
|
||||||
updateAccessTime
|
updateAccessTime
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -179,7 +179,7 @@ export const EmptyNotice = (props: {
|
||||||
if (props.loading) return null;
|
if (props.loading) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center h-full text-ink-faint">
|
<div className="flex h-full flex-col items-center justify-center text-ink-faint">
|
||||||
{props.icon
|
{props.icon
|
||||||
? isValidElement(props.icon)
|
? isValidElement(props.icon)
|
||||||
? props.icon
|
? props.icon
|
||||||
|
@ -198,7 +198,7 @@ const useKeyDownHandlers = ({ disabled }: { disabled: boolean }) => {
|
||||||
|
|
||||||
const os = useOperatingSystem();
|
const os = useOperatingSystem();
|
||||||
const { library } = useLibraryContext();
|
const { library } = useLibraryContext();
|
||||||
const { openFilePaths } = usePlatform();
|
const { openFilePaths, openEphemeralFiles } = usePlatform();
|
||||||
|
|
||||||
const handleNewTag = useCallback(
|
const handleNewTag = useCallback(
|
||||||
async (event: KeyboardEvent) => {
|
async (event: KeyboardEvent) => {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Based on Atom's One Dark theme: https://github.com/atom/atom/tree/master/packages/one-dark-syntax
|
* Based on Atom's One Dark theme: https://github.com/atom/atom/tree/master/packages/one-dark-syntax
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One Dark colours (accurate as of commit 8ae45ca on 6 Sep 2018)
|
* One Dark colours (accurate as of commit 8ae45ca on 6 Sep 2018)
|
||||||
* From colors.less
|
* From colors.less
|
||||||
* --mono-1: hsl(220, 14%, 71%);
|
* --mono-1: hsl(220, 14%, 71%);
|
||||||
|
@ -30,413 +30,416 @@
|
||||||
* --syntax-cursor-line: hsla(220, 100%, 80%, 0.04);
|
* --syntax-cursor-line: hsla(220, 100%, 80%, 0.04);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
code[class*="language-"],
|
code[class*='language-'],
|
||||||
pre[class*="language-"] {
|
pre[class*='language-'] {
|
||||||
background: hsl(220, 13%, 18%);
|
background: hsl(220, 13%, 18%);
|
||||||
color: hsl(220, 14%, 71%);
|
color: hsl(220, 14%, 71%);
|
||||||
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
|
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
|
||||||
font-family: "Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
|
font-family: 'Fira Code', 'Fira Mono', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
word-spacing: normal;
|
word-spacing: normal;
|
||||||
word-break: normal;
|
word-break: normal;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
-moz-tab-size: 2;
|
-moz-tab-size: 2;
|
||||||
-o-tab-size: 2;
|
-o-tab-size: 2;
|
||||||
tab-size: 2;
|
tab-size: 2;
|
||||||
-webkit-hyphens: none;
|
-webkit-hyphens: none;
|
||||||
-moz-hyphens: none;
|
-moz-hyphens: none;
|
||||||
-ms-hyphens: none;
|
-ms-hyphens: none;
|
||||||
hyphens: none;
|
hyphens: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Selection */
|
/* Selection */
|
||||||
code[class*="language-"]::-moz-selection,
|
code[class*='language-']::-moz-selection,
|
||||||
code[class*="language-"] *::-moz-selection,
|
code[class*='language-'] *::-moz-selection,
|
||||||
pre[class*="language-"] *::-moz-selection {
|
pre[class*='language-'] *::-moz-selection {
|
||||||
background: hsl(220, 13%, 28%);
|
background: hsl(220, 13%, 28%);
|
||||||
color: inherit;
|
color: inherit;
|
||||||
|
text-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
code[class*='language-']::selection,
|
||||||
|
code[class*='language-'] *::selection,
|
||||||
|
pre[class*='language-'] *::selection {
|
||||||
|
background: hsl(220, 13%, 28%);
|
||||||
|
color: inherit;
|
||||||
|
text-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Code blocks */
|
||||||
|
pre[class*='language-'] {
|
||||||
|
padding: 1em;
|
||||||
|
margin: 0.5em 0;
|
||||||
|
overflow: auto;
|
||||||
|
border-radius: 0.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Inline code */
|
||||||
|
:not(pre) > code[class*='language-'] {
|
||||||
|
padding: 0.2em 0.3em;
|
||||||
|
border-radius: 0.3em;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print */
|
||||||
|
@media print {
|
||||||
|
code[class*='language-'],
|
||||||
|
pre[class*='language-'] {
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
code[class*="language-"]::selection,
|
.token.comment,
|
||||||
code[class*="language-"] *::selection,
|
.token.prolog,
|
||||||
pre[class*="language-"] *::selection {
|
.token.cdata {
|
||||||
background: hsl(220, 13%, 28%);
|
color: hsl(220, 10%, 40%);
|
||||||
color: inherit;
|
}
|
||||||
text-shadow: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Code blocks */
|
.token.doctype,
|
||||||
pre[class*="language-"] {
|
.token.punctuation,
|
||||||
padding: 1em;
|
.token.entity {
|
||||||
margin: 0.5em 0;
|
color: hsl(220, 14%, 71%);
|
||||||
overflow: auto;
|
}
|
||||||
border-radius: 0.3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Inline code */
|
.token.attr-name,
|
||||||
:not(pre) > code[class*="language-"] {
|
.token.class-name,
|
||||||
padding: 0.2em 0.3em;
|
.token.boolean,
|
||||||
border-radius: 0.3em;
|
.token.constant,
|
||||||
white-space: normal;
|
.token.number,
|
||||||
}
|
.token.atrule {
|
||||||
|
color: hsl(29, 54%, 61%);
|
||||||
|
}
|
||||||
|
|
||||||
/* Print */
|
.token.keyword {
|
||||||
@media print {
|
color: hsl(286, 60%, 67%);
|
||||||
code[class*="language-"],
|
}
|
||||||
pre[class*="language-"] {
|
|
||||||
text-shadow: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.comment,
|
.token.property,
|
||||||
.token.prolog,
|
.token.tag,
|
||||||
.token.cdata {
|
.token.symbol,
|
||||||
color: hsl(220, 10%, 40%);
|
.token.deleted,
|
||||||
}
|
.token.important {
|
||||||
|
color: hsl(355, 65%, 65%);
|
||||||
|
}
|
||||||
|
|
||||||
.token.doctype,
|
.token.selector,
|
||||||
.token.punctuation,
|
.token.string,
|
||||||
.token.entity {
|
.token.char,
|
||||||
color: hsl(220, 14%, 71%);
|
.token.builtin,
|
||||||
}
|
.token.inserted,
|
||||||
|
.token.regex,
|
||||||
|
.token.attr-value,
|
||||||
|
.token.attr-value > .token.punctuation {
|
||||||
|
color: hsl(95, 38%, 62%);
|
||||||
|
}
|
||||||
|
|
||||||
.token.attr-name,
|
.token.variable,
|
||||||
.token.class-name,
|
.token.operator,
|
||||||
.token.boolean,
|
.token.function {
|
||||||
.token.constant,
|
color: hsl(207, 82%, 66%);
|
||||||
.token.number,
|
}
|
||||||
.token.atrule {
|
|
||||||
color: hsl(29, 54%, 61%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.keyword {
|
.token.url {
|
||||||
color: hsl(286, 60%, 67%);
|
color: hsl(187, 47%, 55%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.property,
|
/* HTML overrides */
|
||||||
.token.tag,
|
.token.attr-value > .token.punctuation.attr-equals,
|
||||||
.token.symbol,
|
.token.special-attr > .token.attr-value > .token.value.css {
|
||||||
.token.deleted,
|
color: hsl(220, 14%, 71%);
|
||||||
.token.important {
|
}
|
||||||
color: hsl(355, 65%, 65%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.selector,
|
/* CSS overrides */
|
||||||
.token.string,
|
.language-css .token.selector {
|
||||||
.token.char,
|
color: hsl(355, 65%, 65%);
|
||||||
.token.builtin,
|
}
|
||||||
.token.inserted,
|
|
||||||
.token.regex,
|
|
||||||
.token.attr-value,
|
|
||||||
.token.attr-value > .token.punctuation {
|
|
||||||
color: hsl(95, 38%, 62%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.variable,
|
.language-css .token.property {
|
||||||
.token.operator,
|
color: hsl(220, 14%, 71%);
|
||||||
.token.function {
|
}
|
||||||
color: hsl(207, 82%, 66%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.url {
|
.language-css .token.function,
|
||||||
color: hsl(187, 47%, 55%);
|
.language-css .token.url > .token.function {
|
||||||
}
|
color: hsl(187, 47%, 55%);
|
||||||
|
}
|
||||||
|
|
||||||
/* HTML overrides */
|
.language-css .token.url > .token.string.url {
|
||||||
.token.attr-value > .token.punctuation.attr-equals,
|
color: hsl(95, 38%, 62%);
|
||||||
.token.special-attr > .token.attr-value > .token.value.css {
|
}
|
||||||
color: hsl(220, 14%, 71%);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* CSS overrides */
|
.language-css .token.important,
|
||||||
.language-css .token.selector {
|
.language-css .token.atrule .token.rule {
|
||||||
color: hsl(355, 65%, 65%);
|
color: hsl(286, 60%, 67%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-css .token.property {
|
/* JS overrides */
|
||||||
color: hsl(220, 14%, 71%);
|
.language-javascript .token.operator {
|
||||||
}
|
color: hsl(286, 60%, 67%);
|
||||||
|
}
|
||||||
|
|
||||||
.language-css .token.function,
|
.language-javascript
|
||||||
.language-css .token.url > .token.function {
|
.token.template-string
|
||||||
color: hsl(187, 47%, 55%);
|
> .token.interpolation
|
||||||
}
|
> .token.interpolation-punctuation.punctuation {
|
||||||
|
color: hsl(5, 48%, 51%);
|
||||||
|
}
|
||||||
|
|
||||||
.language-css .token.url > .token.string.url {
|
/* JSON overrides */
|
||||||
color: hsl(95, 38%, 62%);
|
.language-json .token.operator {
|
||||||
}
|
color: hsl(220, 14%, 71%);
|
||||||
|
}
|
||||||
|
|
||||||
.language-css .token.important,
|
.language-json .token.null.keyword {
|
||||||
.language-css .token.atrule .token.rule {
|
color: hsl(29, 54%, 61%);
|
||||||
color: hsl(286, 60%, 67%);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* JS overrides */
|
/* MD overrides */
|
||||||
.language-javascript .token.operator {
|
.language-markdown .token.url,
|
||||||
color: hsl(286, 60%, 67%);
|
.language-markdown .token.url > .token.operator,
|
||||||
}
|
.language-markdown .token.url-reference.url > .token.string {
|
||||||
|
color: hsl(220, 14%, 71%);
|
||||||
|
}
|
||||||
|
|
||||||
.language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation {
|
.language-markdown .token.url > .token.content {
|
||||||
color: hsl(5, 48%, 51%);
|
color: hsl(207, 82%, 66%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* JSON overrides */
|
.language-markdown .token.url > .token.url,
|
||||||
.language-json .token.operator {
|
.language-markdown .token.url-reference.url {
|
||||||
color: hsl(220, 14%, 71%);
|
color: hsl(187, 47%, 55%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-json .token.null.keyword {
|
.language-markdown .token.blockquote.punctuation,
|
||||||
color: hsl(29, 54%, 61%);
|
.language-markdown .token.hr.punctuation {
|
||||||
}
|
color: hsl(220, 10%, 40%);
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
/* MD overrides */
|
.language-markdown .token.code-snippet {
|
||||||
.language-markdown .token.url,
|
color: hsl(95, 38%, 62%);
|
||||||
.language-markdown .token.url > .token.operator,
|
}
|
||||||
.language-markdown .token.url-reference.url > .token.string {
|
|
||||||
color: hsl(220, 14%, 71%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.language-markdown .token.url > .token.content {
|
.language-markdown .token.bold .token.content {
|
||||||
color: hsl(207, 82%, 66%);
|
color: hsl(29, 54%, 61%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-markdown .token.url > .token.url,
|
.language-markdown .token.italic .token.content {
|
||||||
.language-markdown .token.url-reference.url {
|
color: hsl(286, 60%, 67%);
|
||||||
color: hsl(187, 47%, 55%);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.language-markdown .token.blockquote.punctuation,
|
.language-markdown .token.strike .token.content,
|
||||||
.language-markdown .token.hr.punctuation {
|
.language-markdown .token.strike .token.punctuation,
|
||||||
color: hsl(220, 10%, 40%);
|
.language-markdown .token.list.punctuation,
|
||||||
font-style: italic;
|
.language-markdown .token.title.important > .token.punctuation {
|
||||||
}
|
color: hsl(355, 65%, 65%);
|
||||||
|
}
|
||||||
|
|
||||||
.language-markdown .token.code-snippet {
|
/* General */
|
||||||
color: hsl(95, 38%, 62%);
|
.token.bold {
|
||||||
}
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
.language-markdown .token.bold .token.content {
|
.token.comment,
|
||||||
color: hsl(29, 54%, 61%);
|
.token.italic {
|
||||||
}
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
.language-markdown .token.italic .token.content {
|
.token.entity {
|
||||||
color: hsl(286, 60%, 67%);
|
cursor: help;
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-markdown .token.strike .token.content,
|
.token.namespace {
|
||||||
.language-markdown .token.strike .token.punctuation,
|
opacity: 0.8;
|
||||||
.language-markdown .token.list.punctuation,
|
}
|
||||||
.language-markdown .token.title.important > .token.punctuation {
|
|
||||||
color: hsl(355, 65%, 65%);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* General */
|
/* Plugin overrides */
|
||||||
.token.bold {
|
/* Selectors should have higher specificity than those in the plugins' default stylesheets */
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.comment,
|
/* Show Invisibles plugin overrides */
|
||||||
.token.italic {
|
.token.token.tab:not(:empty):before,
|
||||||
font-style: italic;
|
.token.token.cr:before,
|
||||||
}
|
.token.token.lf:before,
|
||||||
|
.token.token.space:before {
|
||||||
|
color: hsla(220, 14%, 71%, 0.15);
|
||||||
|
text-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
.token.entity {
|
/* Toolbar plugin overrides */
|
||||||
cursor: help;
|
/* Space out all buttons and move them away from the right edge of the code block */
|
||||||
}
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item {
|
||||||
|
margin-right: 0.4em;
|
||||||
|
}
|
||||||
|
|
||||||
.token.namespace {
|
/* Styling the buttons */
|
||||||
opacity: 0.8;
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > button,
|
||||||
}
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a,
|
||||||
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span {
|
||||||
|
background: hsl(220, 13%, 26%);
|
||||||
|
color: hsl(220, 9%, 55%);
|
||||||
|
padding: 0.1em 0.4em;
|
||||||
|
border-radius: 0.3em;
|
||||||
|
}
|
||||||
|
|
||||||
/* Plugin overrides */
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover,
|
||||||
/* Selectors should have higher specificity than those in the plugins' default stylesheets */
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus,
|
||||||
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover,
|
||||||
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus,
|
||||||
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover,
|
||||||
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus {
|
||||||
|
background: hsl(220, 13%, 28%);
|
||||||
|
color: hsl(220, 14%, 71%);
|
||||||
|
}
|
||||||
|
|
||||||
/* Show Invisibles plugin overrides */
|
/* Line Highlight plugin overrides */
|
||||||
.token.token.tab:not(:empty):before,
|
/* The highlighted line itself */
|
||||||
.token.token.cr:before,
|
.line-highlight.line-highlight {
|
||||||
.token.token.lf:before,
|
background: hsla(220, 100%, 80%, 0.04);
|
||||||
.token.token.space:before {
|
}
|
||||||
color: hsla(220, 14%, 71%, 0.15);
|
|
||||||
text-shadow: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Toolbar plugin overrides */
|
/* Default line numbers in Line Highlight plugin */
|
||||||
/* Space out all buttons and move them away from the right edge of the code block */
|
.line-highlight.line-highlight:before,
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item {
|
.line-highlight.line-highlight[data-end]:after {
|
||||||
margin-right: 0.4em;
|
background: hsl(220, 13%, 26%);
|
||||||
}
|
color: hsl(220, 14%, 71%);
|
||||||
|
padding: 0.1em 0.6em;
|
||||||
|
border-radius: 0.3em;
|
||||||
|
box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.2); /* same as Toolbar plugin default */
|
||||||
|
}
|
||||||
|
|
||||||
/* Styling the buttons */
|
/* Hovering over a linkable line number (in the gutter area) */
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > button,
|
/* Requires Line Numbers plugin as well */
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a,
|
pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before {
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span {
|
background-color: hsla(220, 100%, 80%, 0.04);
|
||||||
background: hsl(220, 13%, 26%);
|
}
|
||||||
color: hsl(220, 9%, 55%);
|
|
||||||
padding: 0.1em 0.4em;
|
|
||||||
border-radius: 0.3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover,
|
/* Line Numbers and Command Line plugins overrides */
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus,
|
/* Line separating gutter from coding area */
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover,
|
.line-numbers.line-numbers .line-numbers-rows,
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus,
|
.command-line .command-line-prompt {
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover,
|
border-right-color: hsla(220, 14%, 71%, 0.15);
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus {
|
}
|
||||||
background: hsl(220, 13%, 28%);
|
|
||||||
color: hsl(220, 14%, 71%);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Line Highlight plugin overrides */
|
/* Stuff in the gutter */
|
||||||
/* The highlighted line itself */
|
.line-numbers .line-numbers-rows > span:before,
|
||||||
.line-highlight.line-highlight {
|
.command-line .command-line-prompt > span:before {
|
||||||
background: hsla(220, 100%, 80%, 0.04);
|
color: hsl(220, 14%, 45%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Default line numbers in Line Highlight plugin */
|
/* Match Braces plugin overrides */
|
||||||
.line-highlight.line-highlight:before,
|
/* Note: Outline colour is inherited from the braces */
|
||||||
.line-highlight.line-highlight[data-end]:after {
|
.rainbow-braces .token.token.punctuation.brace-level-1,
|
||||||
background: hsl(220, 13%, 26%);
|
.rainbow-braces .token.token.punctuation.brace-level-5,
|
||||||
color: hsl(220, 14%, 71%);
|
.rainbow-braces .token.token.punctuation.brace-level-9 {
|
||||||
padding: 0.1em 0.6em;
|
color: hsl(355, 65%, 65%);
|
||||||
border-radius: 0.3em;
|
}
|
||||||
box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.2); /* same as Toolbar plugin default */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Hovering over a linkable line number (in the gutter area) */
|
.rainbow-braces .token.token.punctuation.brace-level-2,
|
||||||
/* Requires Line Numbers plugin as well */
|
.rainbow-braces .token.token.punctuation.brace-level-6,
|
||||||
pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before {
|
.rainbow-braces .token.token.punctuation.brace-level-10 {
|
||||||
background-color: hsla(220, 100%, 80%, 0.04);
|
color: hsl(95, 38%, 62%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Line Numbers and Command Line plugins overrides */
|
.rainbow-braces .token.token.punctuation.brace-level-3,
|
||||||
/* Line separating gutter from coding area */
|
.rainbow-braces .token.token.punctuation.brace-level-7,
|
||||||
.line-numbers.line-numbers .line-numbers-rows,
|
.rainbow-braces .token.token.punctuation.brace-level-11 {
|
||||||
.command-line .command-line-prompt {
|
color: hsl(207, 82%, 66%);
|
||||||
border-right-color: hsla(220, 14%, 71%, 0.15);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Stuff in the gutter */
|
.rainbow-braces .token.token.punctuation.brace-level-4,
|
||||||
.line-numbers .line-numbers-rows > span:before,
|
.rainbow-braces .token.token.punctuation.brace-level-8,
|
||||||
.command-line .command-line-prompt > span:before {
|
.rainbow-braces .token.token.punctuation.brace-level-12 {
|
||||||
color: hsl(220, 14%, 45%);
|
color: hsl(286, 60%, 67%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Match Braces plugin overrides */
|
/* Diff Highlight plugin overrides */
|
||||||
/* Note: Outline colour is inherited from the braces */
|
/* Taken from https://github.com/atom/github/blob/master/styles/variables.less */
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-1,
|
pre.diff-highlight > code .token.token.deleted:not(.prefix),
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-5,
|
pre > code.diff-highlight .token.token.deleted:not(.prefix) {
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-9 {
|
background-color: hsla(353, 100%, 66%, 0.15);
|
||||||
color: hsl(355, 65%, 65%);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-2,
|
pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection,
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-6,
|
pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection,
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-10 {
|
pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection,
|
||||||
color: hsl(95, 38%, 62%);
|
pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection {
|
||||||
}
|
background-color: hsla(353, 95%, 66%, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-3,
|
pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection,
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-7,
|
pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection,
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-11 {
|
pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection,
|
||||||
color: hsl(207, 82%, 66%);
|
pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection {
|
||||||
}
|
background-color: hsla(353, 95%, 66%, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-4,
|
pre.diff-highlight > code .token.token.inserted:not(.prefix),
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-8,
|
pre > code.diff-highlight .token.token.inserted:not(.prefix) {
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-12 {
|
background-color: hsla(137, 100%, 55%, 0.15);
|
||||||
color: hsl(286, 60%, 67%);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Diff Highlight plugin overrides */
|
pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection,
|
||||||
/* Taken from https://github.com/atom/github/blob/master/styles/variables.less */
|
pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection,
|
||||||
pre.diff-highlight > code .token.token.deleted:not(.prefix),
|
pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection,
|
||||||
pre > code.diff-highlight .token.token.deleted:not(.prefix) {
|
pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection {
|
||||||
background-color: hsla(353, 100%, 66%, 0.15);
|
background-color: hsla(135, 73%, 55%, 0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection,
|
pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection,
|
||||||
pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection,
|
pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection,
|
||||||
pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection,
|
pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection,
|
||||||
pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection {
|
pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection {
|
||||||
background-color: hsla(353, 95%, 66%, 0.25);
|
background-color: hsla(135, 73%, 55%, 0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection,
|
/* Previewers plugin overrides */
|
||||||
pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection,
|
/* Based on https://github.com/atom-community/atom-ide-datatip/blob/master/styles/atom-ide-datatips.less and https://github.com/atom/atom/blob/master/packages/one-dark-ui */
|
||||||
pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection,
|
/* Border around popup */
|
||||||
pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection {
|
.prism-previewer.prism-previewer:before,
|
||||||
background-color: hsla(353, 95%, 66%, 0.25);
|
.prism-previewer-gradient.prism-previewer-gradient div {
|
||||||
}
|
border-color: hsl(224, 13%, 17%);
|
||||||
|
}
|
||||||
|
|
||||||
pre.diff-highlight > code .token.token.inserted:not(.prefix),
|
/* Angle and time should remain as circles and are hence not included */
|
||||||
pre > code.diff-highlight .token.token.inserted:not(.prefix) {
|
.prism-previewer-color.prism-previewer-color:before,
|
||||||
background-color: hsla(137, 100%, 55%, 0.15);
|
.prism-previewer-gradient.prism-previewer-gradient div,
|
||||||
}
|
.prism-previewer-easing.prism-previewer-easing:before {
|
||||||
|
border-radius: 0.3em;
|
||||||
|
}
|
||||||
|
|
||||||
pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection,
|
/* Triangles pointing to the code */
|
||||||
pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection,
|
.prism-previewer.prism-previewer:after {
|
||||||
pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection,
|
border-top-color: hsl(224, 13%, 17%);
|
||||||
pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection {
|
}
|
||||||
background-color: hsla(135, 73%, 55%, 0.25);
|
|
||||||
}
|
|
||||||
|
|
||||||
pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection,
|
.prism-previewer-flipped.prism-previewer-flipped.after {
|
||||||
pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection,
|
border-bottom-color: hsl(224, 13%, 17%);
|
||||||
pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection,
|
}
|
||||||
pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection {
|
|
||||||
background-color: hsla(135, 73%, 55%, 0.25);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Previewers plugin overrides */
|
/* Background colour within the popup */
|
||||||
/* Based on https://github.com/atom-community/atom-ide-datatip/blob/master/styles/atom-ide-datatips.less and https://github.com/atom/atom/blob/master/packages/one-dark-ui */
|
.prism-previewer-angle.prism-previewer-angle:before,
|
||||||
/* Border around popup */
|
.prism-previewer-time.prism-previewer-time:before,
|
||||||
.prism-previewer.prism-previewer:before,
|
.prism-previewer-easing.prism-previewer-easing {
|
||||||
.prism-previewer-gradient.prism-previewer-gradient div {
|
background: hsl(219, 13%, 22%);
|
||||||
border-color: hsl(224, 13%, 17%);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Angle and time should remain as circles and are hence not included */
|
/* For angle, this is the positive area (eg. 90deg will display one quadrant in this colour) */
|
||||||
.prism-previewer-color.prism-previewer-color:before,
|
/* For time, this is the alternate colour */
|
||||||
.prism-previewer-gradient.prism-previewer-gradient div,
|
.prism-previewer-angle.prism-previewer-angle circle,
|
||||||
.prism-previewer-easing.prism-previewer-easing:before {
|
.prism-previewer-time.prism-previewer-time circle {
|
||||||
border-radius: 0.3em;
|
stroke: hsl(220, 14%, 71%);
|
||||||
}
|
stroke-opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Triangles pointing to the code */
|
/* Stroke colours of the handle, direction point, and vector itself */
|
||||||
.prism-previewer.prism-previewer:after {
|
.prism-previewer-easing.prism-previewer-easing circle,
|
||||||
border-top-color: hsl(224, 13%, 17%);
|
.prism-previewer-easing.prism-previewer-easing path,
|
||||||
}
|
.prism-previewer-easing.prism-previewer-easing line {
|
||||||
|
stroke: hsl(220, 14%, 71%);
|
||||||
|
}
|
||||||
|
|
||||||
.prism-previewer-flipped.prism-previewer-flipped.after {
|
/* Fill colour of the handle */
|
||||||
border-bottom-color: hsl(224, 13%, 17%);
|
.prism-previewer-easing.prism-previewer-easing circle {
|
||||||
}
|
fill: transparent;
|
||||||
|
}
|
||||||
/* Background colour within the popup */
|
|
||||||
.prism-previewer-angle.prism-previewer-angle:before,
|
|
||||||
.prism-previewer-time.prism-previewer-time:before,
|
|
||||||
.prism-previewer-easing.prism-previewer-easing {
|
|
||||||
background: hsl(219, 13%, 22%);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* For angle, this is the positive area (eg. 90deg will display one quadrant in this colour) */
|
|
||||||
/* For time, this is the alternate colour */
|
|
||||||
.prism-previewer-angle.prism-previewer-angle circle,
|
|
||||||
.prism-previewer-time.prism-previewer-time circle {
|
|
||||||
stroke: hsl(220, 14%, 71%);
|
|
||||||
stroke-opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Stroke colours of the handle, direction point, and vector itself */
|
|
||||||
.prism-previewer-easing.prism-previewer-easing circle,
|
|
||||||
.prism-previewer-easing.prism-previewer-easing path,
|
|
||||||
.prism-previewer-easing.prism-previewer-easing line {
|
|
||||||
stroke: hsl(220, 14%, 71%);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill colour of the handle */
|
|
||||||
.prism-previewer-easing.prism-previewer-easing circle {
|
|
||||||
fill: transparent;
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Based on Atom's One Light theme: https://github.com/atom/atom/tree/master/packages/one-light-syntax
|
* Based on Atom's One Light theme: https://github.com/atom/atom/tree/master/packages/one-light-syntax
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One Light colours (accurate as of commit eb064bf on 19 Feb 2021)
|
* One Light colours (accurate as of commit eb064bf on 19 Feb 2021)
|
||||||
* From colors.less
|
* From colors.less
|
||||||
* --mono-1: hsl(230, 8%, 24%);
|
* --mono-1: hsl(230, 8%, 24%);
|
||||||
|
@ -30,401 +30,404 @@
|
||||||
* --syntax-cursor-line: hsla(230, 8%, 24%, 0.05);
|
* --syntax-cursor-line: hsla(230, 8%, 24%, 0.05);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
code[class*="language-"],
|
code[class*='language-'],
|
||||||
pre[class*="language-"] {
|
pre[class*='language-'] {
|
||||||
background: hsl(230, 1%, 98%);
|
background: hsl(230, 1%, 98%);
|
||||||
color: hsl(230, 8%, 24%);
|
color: hsl(230, 8%, 24%);
|
||||||
font-family: "Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
|
font-family: 'Fira Code', 'Fira Mono', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
word-spacing: normal;
|
word-spacing: normal;
|
||||||
word-break: normal;
|
word-break: normal;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
-moz-tab-size: 2;
|
-moz-tab-size: 2;
|
||||||
-o-tab-size: 2;
|
-o-tab-size: 2;
|
||||||
tab-size: 2;
|
tab-size: 2;
|
||||||
-webkit-hyphens: none;
|
-webkit-hyphens: none;
|
||||||
-moz-hyphens: none;
|
-moz-hyphens: none;
|
||||||
-ms-hyphens: none;
|
-ms-hyphens: none;
|
||||||
hyphens: none;
|
hyphens: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Selection */
|
/* Selection */
|
||||||
code[class*="language-"]::-moz-selection,
|
code[class*='language-']::-moz-selection,
|
||||||
code[class*="language-"] *::-moz-selection,
|
code[class*='language-'] *::-moz-selection,
|
||||||
pre[class*="language-"] *::-moz-selection {
|
pre[class*='language-'] *::-moz-selection {
|
||||||
background: hsl(230, 1%, 90%);
|
background: hsl(230, 1%, 90%);
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
code[class*="language-"]::selection,
|
code[class*='language-']::selection,
|
||||||
code[class*="language-"] *::selection,
|
code[class*='language-'] *::selection,
|
||||||
pre[class*="language-"] *::selection {
|
pre[class*='language-'] *::selection {
|
||||||
background: hsl(230, 1%, 90%);
|
background: hsl(230, 1%, 90%);
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Code blocks */
|
/* Code blocks */
|
||||||
pre[class*="language-"] {
|
pre[class*='language-'] {
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
margin: 0.5em 0;
|
margin: 0.5em 0;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
border-radius: 0.3em;
|
border-radius: 0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inline code */
|
/* Inline code */
|
||||||
:not(pre) > code[class*="language-"] {
|
:not(pre) > code[class*='language-'] {
|
||||||
padding: 0.2em 0.3em;
|
padding: 0.2em 0.3em;
|
||||||
border-radius: 0.3em;
|
border-radius: 0.3em;
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.comment,
|
.token.comment,
|
||||||
.token.prolog,
|
.token.prolog,
|
||||||
.token.cdata {
|
.token.cdata {
|
||||||
color: hsl(230, 4%, 64%);
|
color: hsl(230, 4%, 64%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.doctype,
|
.token.doctype,
|
||||||
.token.punctuation,
|
.token.punctuation,
|
||||||
.token.entity {
|
.token.entity {
|
||||||
color: hsl(230, 8%, 24%);
|
color: hsl(230, 8%, 24%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.attr-name,
|
.token.attr-name,
|
||||||
.token.class-name,
|
.token.class-name,
|
||||||
.token.boolean,
|
.token.boolean,
|
||||||
.token.constant,
|
.token.constant,
|
||||||
.token.number,
|
.token.number,
|
||||||
.token.atrule {
|
.token.atrule {
|
||||||
color: hsl(35, 99%, 36%);
|
color: hsl(35, 99%, 36%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.keyword {
|
.token.keyword {
|
||||||
color: hsl(301, 63%, 40%);
|
color: hsl(301, 63%, 40%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.property,
|
.token.property,
|
||||||
.token.tag,
|
.token.tag,
|
||||||
.token.symbol,
|
.token.symbol,
|
||||||
.token.deleted,
|
.token.deleted,
|
||||||
.token.important {
|
.token.important {
|
||||||
color: hsl(5, 74%, 59%);
|
color: hsl(5, 74%, 59%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.selector,
|
.token.selector,
|
||||||
.token.string,
|
.token.string,
|
||||||
.token.char,
|
.token.char,
|
||||||
.token.builtin,
|
.token.builtin,
|
||||||
.token.inserted,
|
.token.inserted,
|
||||||
.token.regex,
|
.token.regex,
|
||||||
.token.attr-value,
|
.token.attr-value,
|
||||||
.token.attr-value > .token.punctuation {
|
.token.attr-value > .token.punctuation {
|
||||||
color: hsl(119, 34%, 47%);
|
color: hsl(119, 34%, 47%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.variable,
|
.token.variable,
|
||||||
.token.operator,
|
.token.operator,
|
||||||
.token.function {
|
.token.function {
|
||||||
color: hsl(221, 87%, 60%);
|
color: hsl(221, 87%, 60%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.url {
|
.token.url {
|
||||||
color: hsl(198, 99%, 37%);
|
color: hsl(198, 99%, 37%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* HTML overrides */
|
/* HTML overrides */
|
||||||
.token.attr-value > .token.punctuation.attr-equals,
|
.token.attr-value > .token.punctuation.attr-equals,
|
||||||
.token.special-attr > .token.attr-value > .token.value.css {
|
.token.special-attr > .token.attr-value > .token.value.css {
|
||||||
color: hsl(230, 8%, 24%);
|
color: hsl(230, 8%, 24%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CSS overrides */
|
/* CSS overrides */
|
||||||
.language-css .token.selector {
|
.language-css .token.selector {
|
||||||
color: hsl(5, 74%, 59%);
|
color: hsl(5, 74%, 59%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-css .token.property {
|
.language-css .token.property {
|
||||||
color: hsl(230, 8%, 24%);
|
color: hsl(230, 8%, 24%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-css .token.function,
|
.language-css .token.function,
|
||||||
.language-css .token.url > .token.function {
|
.language-css .token.url > .token.function {
|
||||||
color: hsl(198, 99%, 37%);
|
color: hsl(198, 99%, 37%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-css .token.url > .token.string.url {
|
.language-css .token.url > .token.string.url {
|
||||||
color: hsl(119, 34%, 47%);
|
color: hsl(119, 34%, 47%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-css .token.important,
|
.language-css .token.important,
|
||||||
.language-css .token.atrule .token.rule {
|
.language-css .token.atrule .token.rule {
|
||||||
color: hsl(301, 63%, 40%);
|
color: hsl(301, 63%, 40%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* JS overrides */
|
/* JS overrides */
|
||||||
.language-javascript .token.operator {
|
.language-javascript .token.operator {
|
||||||
color: hsl(301, 63%, 40%);
|
color: hsl(301, 63%, 40%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation {
|
.language-javascript
|
||||||
color: hsl(344, 84%, 43%);
|
.token.template-string
|
||||||
}
|
> .token.interpolation
|
||||||
|
> .token.interpolation-punctuation.punctuation {
|
||||||
|
color: hsl(344, 84%, 43%);
|
||||||
|
}
|
||||||
|
|
||||||
/* JSON overrides */
|
/* JSON overrides */
|
||||||
.language-json .token.operator {
|
.language-json .token.operator {
|
||||||
color: hsl(230, 8%, 24%);
|
color: hsl(230, 8%, 24%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-json .token.null.keyword {
|
.language-json .token.null.keyword {
|
||||||
color: hsl(35, 99%, 36%);
|
color: hsl(35, 99%, 36%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MD overrides */
|
/* MD overrides */
|
||||||
.language-markdown .token.url,
|
.language-markdown .token.url,
|
||||||
.language-markdown .token.url > .token.operator,
|
.language-markdown .token.url > .token.operator,
|
||||||
.language-markdown .token.url-reference.url > .token.string {
|
.language-markdown .token.url-reference.url > .token.string {
|
||||||
color: hsl(230, 8%, 24%);
|
color: hsl(230, 8%, 24%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-markdown .token.url > .token.content {
|
.language-markdown .token.url > .token.content {
|
||||||
color: hsl(221, 87%, 60%);
|
color: hsl(221, 87%, 60%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-markdown .token.url > .token.url,
|
.language-markdown .token.url > .token.url,
|
||||||
.language-markdown .token.url-reference.url {
|
.language-markdown .token.url-reference.url {
|
||||||
color: hsl(198, 99%, 37%);
|
color: hsl(198, 99%, 37%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-markdown .token.blockquote.punctuation,
|
.language-markdown .token.blockquote.punctuation,
|
||||||
.language-markdown .token.hr.punctuation {
|
.language-markdown .token.hr.punctuation {
|
||||||
color: hsl(230, 4%, 64%);
|
color: hsl(230, 4%, 64%);
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-markdown .token.code-snippet {
|
.language-markdown .token.code-snippet {
|
||||||
color: hsl(119, 34%, 47%);
|
color: hsl(119, 34%, 47%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-markdown .token.bold .token.content {
|
.language-markdown .token.bold .token.content {
|
||||||
color: hsl(35, 99%, 36%);
|
color: hsl(35, 99%, 36%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-markdown .token.italic .token.content {
|
.language-markdown .token.italic .token.content {
|
||||||
color: hsl(301, 63%, 40%);
|
color: hsl(301, 63%, 40%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-markdown .token.strike .token.content,
|
.language-markdown .token.strike .token.content,
|
||||||
.language-markdown .token.strike .token.punctuation,
|
.language-markdown .token.strike .token.punctuation,
|
||||||
.language-markdown .token.list.punctuation,
|
.language-markdown .token.list.punctuation,
|
||||||
.language-markdown .token.title.important > .token.punctuation {
|
.language-markdown .token.title.important > .token.punctuation {
|
||||||
color: hsl(5, 74%, 59%);
|
color: hsl(5, 74%, 59%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* General */
|
/* General */
|
||||||
.token.bold {
|
.token.bold {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.comment,
|
.token.comment,
|
||||||
.token.italic {
|
.token.italic {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.entity {
|
.token.entity {
|
||||||
cursor: help;
|
cursor: help;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.namespace {
|
.token.namespace {
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Plugin overrides */
|
/* Plugin overrides */
|
||||||
/* Selectors should have higher specificity than those in the plugins' default stylesheets */
|
/* Selectors should have higher specificity than those in the plugins' default stylesheets */
|
||||||
|
|
||||||
/* Show Invisibles plugin overrides */
|
/* Show Invisibles plugin overrides */
|
||||||
.token.token.tab:not(:empty):before,
|
.token.token.tab:not(:empty):before,
|
||||||
.token.token.cr:before,
|
.token.token.cr:before,
|
||||||
.token.token.lf:before,
|
.token.token.lf:before,
|
||||||
.token.token.space:before {
|
.token.token.space:before {
|
||||||
color: hsla(230, 8%, 24%, 0.2);
|
color: hsla(230, 8%, 24%, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Toolbar plugin overrides */
|
/* Toolbar plugin overrides */
|
||||||
/* Space out all buttons and move them away from the right edge of the code block */
|
/* Space out all buttons and move them away from the right edge of the code block */
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item {
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item {
|
||||||
margin-right: 0.4em;
|
margin-right: 0.4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Styling the buttons */
|
/* Styling the buttons */
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > button,
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > button,
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a,
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a,
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span {
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span {
|
||||||
background: hsl(230, 1%, 90%);
|
background: hsl(230, 1%, 90%);
|
||||||
color: hsl(230, 6%, 44%);
|
color: hsl(230, 6%, 44%);
|
||||||
padding: 0.1em 0.4em;
|
padding: 0.1em 0.4em;
|
||||||
border-radius: 0.3em;
|
border-radius: 0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover,
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover,
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus,
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus,
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover,
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover,
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus,
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus,
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover,
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover,
|
||||||
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus {
|
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus {
|
||||||
background: hsl(230, 1%, 78%); /* custom: darken(--syntax-bg, 20%) */
|
background: hsl(230, 1%, 78%); /* custom: darken(--syntax-bg, 20%) */
|
||||||
color: hsl(230, 8%, 24%);
|
color: hsl(230, 8%, 24%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Line Highlight plugin overrides */
|
/* Line Highlight plugin overrides */
|
||||||
/* The highlighted line itself */
|
/* The highlighted line itself */
|
||||||
.line-highlight.line-highlight {
|
.line-highlight.line-highlight {
|
||||||
background: hsla(230, 8%, 24%, 0.05);
|
background: hsla(230, 8%, 24%, 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Default line numbers in Line Highlight plugin */
|
/* Default line numbers in Line Highlight plugin */
|
||||||
.line-highlight.line-highlight:before,
|
.line-highlight.line-highlight:before,
|
||||||
.line-highlight.line-highlight[data-end]:after {
|
.line-highlight.line-highlight[data-end]:after {
|
||||||
background: hsl(230, 1%, 90%);
|
background: hsl(230, 1%, 90%);
|
||||||
color: hsl(230, 8%, 24%);
|
color: hsl(230, 8%, 24%);
|
||||||
padding: 0.1em 0.6em;
|
padding: 0.1em 0.6em;
|
||||||
border-radius: 0.3em;
|
border-radius: 0.3em;
|
||||||
box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.2); /* same as Toolbar plugin default */
|
box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.2); /* same as Toolbar plugin default */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hovering over a linkable line number (in the gutter area) */
|
/* Hovering over a linkable line number (in the gutter area) */
|
||||||
/* Requires Line Numbers plugin as well */
|
/* Requires Line Numbers plugin as well */
|
||||||
pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before {
|
pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before {
|
||||||
background-color: hsla(230, 8%, 24%, 0.05);
|
background-color: hsla(230, 8%, 24%, 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Line Numbers and Command Line plugins overrides */
|
/* Line Numbers and Command Line plugins overrides */
|
||||||
/* Line separating gutter from coding area */
|
/* Line separating gutter from coding area */
|
||||||
.line-numbers.line-numbers .line-numbers-rows,
|
.line-numbers.line-numbers .line-numbers-rows,
|
||||||
.command-line .command-line-prompt {
|
.command-line .command-line-prompt {
|
||||||
border-right-color: hsla(230, 8%, 24%, 0.2);
|
border-right-color: hsla(230, 8%, 24%, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stuff in the gutter */
|
/* Stuff in the gutter */
|
||||||
.line-numbers .line-numbers-rows > span:before,
|
.line-numbers .line-numbers-rows > span:before,
|
||||||
.command-line .command-line-prompt > span:before {
|
.command-line .command-line-prompt > span:before {
|
||||||
color: hsl(230, 1%, 62%);
|
color: hsl(230, 1%, 62%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Match Braces plugin overrides */
|
/* Match Braces plugin overrides */
|
||||||
/* Note: Outline colour is inherited from the braces */
|
/* Note: Outline colour is inherited from the braces */
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-1,
|
.rainbow-braces .token.token.punctuation.brace-level-1,
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-5,
|
.rainbow-braces .token.token.punctuation.brace-level-5,
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-9 {
|
.rainbow-braces .token.token.punctuation.brace-level-9 {
|
||||||
color: hsl(5, 74%, 59%);
|
color: hsl(5, 74%, 59%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-2,
|
.rainbow-braces .token.token.punctuation.brace-level-2,
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-6,
|
.rainbow-braces .token.token.punctuation.brace-level-6,
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-10 {
|
.rainbow-braces .token.token.punctuation.brace-level-10 {
|
||||||
color: hsl(119, 34%, 47%);
|
color: hsl(119, 34%, 47%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-3,
|
.rainbow-braces .token.token.punctuation.brace-level-3,
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-7,
|
.rainbow-braces .token.token.punctuation.brace-level-7,
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-11 {
|
.rainbow-braces .token.token.punctuation.brace-level-11 {
|
||||||
color: hsl(221, 87%, 60%);
|
color: hsl(221, 87%, 60%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-4,
|
.rainbow-braces .token.token.punctuation.brace-level-4,
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-8,
|
.rainbow-braces .token.token.punctuation.brace-level-8,
|
||||||
.rainbow-braces .token.token.punctuation.brace-level-12 {
|
.rainbow-braces .token.token.punctuation.brace-level-12 {
|
||||||
color: hsl(301, 63%, 40%);
|
color: hsl(301, 63%, 40%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Diff Highlight plugin overrides */
|
/* Diff Highlight plugin overrides */
|
||||||
/* Taken from https://github.com/atom/github/blob/master/styles/variables.less */
|
/* Taken from https://github.com/atom/github/blob/master/styles/variables.less */
|
||||||
pre.diff-highlight > code .token.token.deleted:not(.prefix),
|
pre.diff-highlight > code .token.token.deleted:not(.prefix),
|
||||||
pre > code.diff-highlight .token.token.deleted:not(.prefix) {
|
pre > code.diff-highlight .token.token.deleted:not(.prefix) {
|
||||||
background-color: hsla(353, 100%, 66%, 0.15);
|
background-color: hsla(353, 100%, 66%, 0.15);
|
||||||
}
|
}
|
||||||
|
|
||||||
pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection,
|
pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection,
|
||||||
pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection,
|
pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection,
|
||||||
pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection,
|
pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection,
|
||||||
pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection {
|
pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection {
|
||||||
background-color: hsla(353, 95%, 66%, 0.25);
|
background-color: hsla(353, 95%, 66%, 0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection,
|
pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection,
|
||||||
pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection,
|
pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection,
|
||||||
pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection,
|
pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection,
|
||||||
pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection {
|
pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection {
|
||||||
background-color: hsla(353, 95%, 66%, 0.25);
|
background-color: hsla(353, 95%, 66%, 0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
pre.diff-highlight > code .token.token.inserted:not(.prefix),
|
pre.diff-highlight > code .token.token.inserted:not(.prefix),
|
||||||
pre > code.diff-highlight .token.token.inserted:not(.prefix) {
|
pre > code.diff-highlight .token.token.inserted:not(.prefix) {
|
||||||
background-color: hsla(137, 100%, 55%, 0.15);
|
background-color: hsla(137, 100%, 55%, 0.15);
|
||||||
}
|
}
|
||||||
|
|
||||||
pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection,
|
pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection,
|
||||||
pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection,
|
pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection,
|
||||||
pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection,
|
pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection,
|
||||||
pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection {
|
pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection {
|
||||||
background-color: hsla(135, 73%, 55%, 0.25);
|
background-color: hsla(135, 73%, 55%, 0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection,
|
pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection,
|
||||||
pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection,
|
pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection,
|
||||||
pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection,
|
pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection,
|
||||||
pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection {
|
pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection {
|
||||||
background-color: hsla(135, 73%, 55%, 0.25);
|
background-color: hsla(135, 73%, 55%, 0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Previewers plugin overrides */
|
/* Previewers plugin overrides */
|
||||||
/* Based on https://github.com/atom-community/atom-ide-datatip/blob/master/styles/atom-ide-datatips.less and https://github.com/atom/atom/blob/master/packages/one-light-ui */
|
/* Based on https://github.com/atom-community/atom-ide-datatip/blob/master/styles/atom-ide-datatips.less and https://github.com/atom/atom/blob/master/packages/one-light-ui */
|
||||||
/* Border around popup */
|
/* Border around popup */
|
||||||
.prism-previewer.prism-previewer:before,
|
.prism-previewer.prism-previewer:before,
|
||||||
.prism-previewer-gradient.prism-previewer-gradient div {
|
.prism-previewer-gradient.prism-previewer-gradient div {
|
||||||
border-color: hsl(0, 0, 95%);
|
border-color: hsl(0, 0, 95%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Angle and time should remain as circles and are hence not included */
|
/* Angle and time should remain as circles and are hence not included */
|
||||||
.prism-previewer-color.prism-previewer-color:before,
|
.prism-previewer-color.prism-previewer-color:before,
|
||||||
.prism-previewer-gradient.prism-previewer-gradient div,
|
.prism-previewer-gradient.prism-previewer-gradient div,
|
||||||
.prism-previewer-easing.prism-previewer-easing:before {
|
.prism-previewer-easing.prism-previewer-easing:before {
|
||||||
border-radius: 0.3em;
|
border-radius: 0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Triangles pointing to the code */
|
/* Triangles pointing to the code */
|
||||||
.prism-previewer.prism-previewer:after {
|
.prism-previewer.prism-previewer:after {
|
||||||
border-top-color: hsl(0, 0, 95%);
|
border-top-color: hsl(0, 0, 95%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.prism-previewer-flipped.prism-previewer-flipped.after {
|
.prism-previewer-flipped.prism-previewer-flipped.after {
|
||||||
border-bottom-color: hsl(0, 0, 95%);
|
border-bottom-color: hsl(0, 0, 95%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Background colour within the popup */
|
/* Background colour within the popup */
|
||||||
.prism-previewer-angle.prism-previewer-angle:before,
|
.prism-previewer-angle.prism-previewer-angle:before,
|
||||||
.prism-previewer-time.prism-previewer-time:before,
|
.prism-previewer-time.prism-previewer-time:before,
|
||||||
.prism-previewer-easing.prism-previewer-easing {
|
.prism-previewer-easing.prism-previewer-easing {
|
||||||
background: hsl(0, 0%, 100%);
|
background: hsl(0, 0%, 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For angle, this is the positive area (eg. 90deg will display one quadrant in this colour) */
|
/* For angle, this is the positive area (eg. 90deg will display one quadrant in this colour) */
|
||||||
/* For time, this is the alternate colour */
|
/* For time, this is the alternate colour */
|
||||||
.prism-previewer-angle.prism-previewer-angle circle,
|
.prism-previewer-angle.prism-previewer-angle circle,
|
||||||
.prism-previewer-time.prism-previewer-time circle {
|
.prism-previewer-time.prism-previewer-time circle {
|
||||||
stroke: hsl(230, 8%, 24%);
|
stroke: hsl(230, 8%, 24%);
|
||||||
stroke-opacity: 1;
|
stroke-opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stroke colours of the handle, direction point, and vector itself */
|
/* Stroke colours of the handle, direction point, and vector itself */
|
||||||
.prism-previewer-easing.prism-previewer-easing circle,
|
.prism-previewer-easing.prism-previewer-easing circle,
|
||||||
.prism-previewer-easing.prism-previewer-easing path,
|
.prism-previewer-easing.prism-previewer-easing path,
|
||||||
.prism-previewer-easing.prism-previewer-easing line {
|
.prism-previewer-easing.prism-previewer-easing line {
|
||||||
stroke: hsl(230, 8%, 24%);
|
stroke: hsl(230, 8%, 24%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill colour of the handle */
|
/* Fill colour of the handle */
|
||||||
.prism-previewer-easing.prism-previewer-easing circle {
|
.prism-previewer-easing.prism-previewer-easing circle {
|
||||||
fill: transparent;
|
fill: transparent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ export type Platform = {
|
||||||
platform: 'web' | 'tauri'; // This represents the specific platform implementation
|
platform: 'web' | 'tauri'; // This represents the specific platform implementation
|
||||||
getThumbnailUrlByThumbKey: (thumbKey: string[]) => string;
|
getThumbnailUrlByThumbKey: (thumbKey: string[]) => string;
|
||||||
getFileUrl: (libraryId: string, locationLocalId: number, filePathId: number) => string;
|
getFileUrl: (libraryId: string, locationLocalId: number, filePathId: number) => string;
|
||||||
|
getFileUrlByPath: (path: string) => string;
|
||||||
openLink: (url: string) => void;
|
openLink: (url: string) => void;
|
||||||
// Tauri patches `window.confirm` to return `Promise` not `bool`
|
// Tauri patches `window.confirm` to return `Promise` not `bool`
|
||||||
confirm(msg: string, cb: (result: boolean) => void): void;
|
confirm(msg: string, cb: (result: boolean) => void): void;
|
||||||
|
@ -21,12 +22,19 @@ export type Platform = {
|
||||||
userHomeDir?(): Promise<string>;
|
userHomeDir?(): Promise<string>;
|
||||||
// Opens a file path with a given ID
|
// Opens a file path with a given ID
|
||||||
openFilePaths?(library: string, ids: number[]): any;
|
openFilePaths?(library: string, ids: number[]): any;
|
||||||
|
openEphemeralFiles?(paths: string[]): any;
|
||||||
revealItems?(
|
revealItems?(
|
||||||
library: string,
|
library: string,
|
||||||
items: ({ Location: { id: number } } | { FilePath: { id: number } })[]
|
items: (
|
||||||
|
| { Location: { id: number } }
|
||||||
|
| { FilePath: { id: number } }
|
||||||
|
| { Ephemeral: { path: string } }
|
||||||
|
)[]
|
||||||
): Promise<unknown>;
|
): Promise<unknown>;
|
||||||
getFilePathOpenWithApps?(library: string, ids: number[]): Promise<unknown>;
|
getFilePathOpenWithApps?(library: string, ids: number[]): Promise<unknown>;
|
||||||
|
getEphemeralFilesOpenWithApps?(paths: string[]): Promise<unknown>;
|
||||||
openFilePathWith?(library: string, fileIdsAndAppUrls: [number, string][]): Promise<unknown>;
|
openFilePathWith?(library: string, fileIdsAndAppUrls: [number, string][]): Promise<unknown>;
|
||||||
|
openEphemeralFileWith?(pathsAndUrls: [string, string][]): Promise<unknown>;
|
||||||
lockAppTheme?(themeType: 'Auto' | 'Light' | 'Dark'): any;
|
lockAppTheme?(themeType: 'Auto' | 'Light' | 'Dark'): any;
|
||||||
auth: {
|
auth: {
|
||||||
start(key: string): any;
|
start(key: string): any;
|
||||||
|
|
|
@ -53,9 +53,7 @@ export function getExplorerItemData(data?: null | ExplorerItem) {
|
||||||
const location = getItemLocation(data);
|
const location = getItemLocation(data);
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
itemData.name = filePath.name;
|
itemData.name = filePath.name;
|
||||||
itemData.fullName = `${filePath.name}${
|
itemData.fullName = `${filePath.name}${filePath.extension ? `.${filePath.extension}` : ''}`;
|
||||||
filePath.extension ? `.${filePath.extension}` : ''
|
|
||||||
}}`;
|
|
||||||
itemData.size = byteSize(filePath.size_in_bytes_bytes);
|
itemData.size = byteSize(filePath.size_in_bytes_bytes);
|
||||||
itemData.isDir = filePath.is_dir ?? false;
|
itemData.isDir = filePath.is_dir ?? false;
|
||||||
itemData.extension = filePath.extension;
|
itemData.extension = filePath.extension;
|
||||||
|
@ -131,3 +129,11 @@ export const useItemsAsFilePaths = (items: ExplorerItem[]) => {
|
||||||
return array;
|
return array;
|
||||||
}, [items]);
|
}, [items]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useItemsAsEphemeralPaths = (items: ExplorerItem[]) => {
|
||||||
|
return useMemo(() => {
|
||||||
|
return items
|
||||||
|
.filter((item) => item.type === 'NonIndexedPath')
|
||||||
|
.map((item) => item.item as NonIndexedPathItem);
|
||||||
|
}, [items]);
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue