parent
cb39ad5004
commit
f37cf23ba7
|
@ -39,3 +39,9 @@ export type ActionButton = {
|
||||||
export type EmojiConfig = {
|
export type EmojiConfig = {
|
||||||
aliases: string[][];
|
aliases: string[][];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type SmartQuotesConfig = {
|
||||||
|
enabled?: boolean;
|
||||||
|
double?: { left?: string; right?: string };
|
||||||
|
single?: { left?: string; right?: string };
|
||||||
|
};
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
import type { ActionButton, EmojiConfig, Shortcut } from "./client.ts";
|
import type {
|
||||||
|
ActionButton,
|
||||||
|
EmojiConfig,
|
||||||
|
Shortcut,
|
||||||
|
SmartQuotesConfig,
|
||||||
|
} from "./client.ts";
|
||||||
|
|
||||||
export interface ConfigContainer {
|
export interface ConfigContainer {
|
||||||
config: Config;
|
config: Config;
|
||||||
|
@ -30,6 +35,7 @@ export type LibraryDef = {
|
||||||
export type Config = {
|
export type Config = {
|
||||||
indexPage: string;
|
indexPage: string;
|
||||||
shortcuts?: Shortcut[];
|
shortcuts?: Shortcut[];
|
||||||
|
// DEPRECATED: Use smartQuotes instead
|
||||||
useSmartQuotes?: boolean;
|
useSmartQuotes?: boolean;
|
||||||
maximumAttachmentSize?: number;
|
maximumAttachmentSize?: number;
|
||||||
libraries?: LibraryDef[];
|
libraries?: LibraryDef[];
|
||||||
|
@ -44,6 +50,7 @@ export type Config = {
|
||||||
spaceIgnore?: string;
|
spaceIgnore?: string;
|
||||||
emoji?: EmojiConfig;
|
emoji?: EmojiConfig;
|
||||||
autoCloseBrackets: string;
|
autoCloseBrackets: string;
|
||||||
|
smartQuotes?: SmartQuotesConfig;
|
||||||
|
|
||||||
schema: SchemaConfig;
|
schema: SchemaConfig;
|
||||||
|
|
||||||
|
|
|
@ -81,12 +81,36 @@ function keyBindingForQuote(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createSmartQuoteKeyBindings(client: Client): KeyBinding[] {
|
export function createSmartQuoteKeyBindings(client: Client): KeyBinding[] {
|
||||||
if (client.config?.useSmartQuotes === false) {
|
// Also check the deprecated useSmartQuotes, default is true so either can disable
|
||||||
|
if (
|
||||||
|
client.config?.useSmartQuotes === false ||
|
||||||
|
client.config?.smartQuotes?.enabled === false
|
||||||
|
) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let doubleLeft = "“";
|
||||||
|
let doubleRight = "”";
|
||||||
|
let singleLeft = "‘";
|
||||||
|
let singleRight = "’";
|
||||||
|
const config = client.config?.smartQuotes;
|
||||||
|
if (config) {
|
||||||
|
if (typeof config.double?.left === "string") {
|
||||||
|
doubleLeft = config.double!.left;
|
||||||
|
}
|
||||||
|
if (typeof config.double?.right === "string") {
|
||||||
|
doubleRight = config.double!.right;
|
||||||
|
}
|
||||||
|
if (typeof config.single?.left === "string") {
|
||||||
|
singleLeft = config.single!.left;
|
||||||
|
}
|
||||||
|
if (typeof config.single?.right === "string") {
|
||||||
|
singleRight = config.single!.right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
keyBindingForQuote('"', "“", "”"),
|
keyBindingForQuote('"', doubleLeft, doubleRight),
|
||||||
keyBindingForQuote("'", "‘", "’"),
|
keyBindingForQuote("'", singleLeft, singleRight),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,10 +56,17 @@ shortcuts:
|
||||||
- command: "{[Upload: File]}"
|
- command: "{[Upload: File]}"
|
||||||
priority: 1
|
priority: 1
|
||||||
|
|
||||||
# Toggles between “smart” ‘quotes’ (left and right) and "simple" 'quotes' (good ol' ASCII)
|
|
||||||
useSmartQuotes: true
|
|
||||||
# Choose which characters to auto-close
|
# Choose which characters to auto-close
|
||||||
autoCloseBrackets: "([{`"
|
autoCloseBrackets: "([{`"
|
||||||
|
# Options for “smart” ‘quotes’ (left and right) used outside of code fragments, these are the defaults:
|
||||||
|
smartQuotes:
|
||||||
|
enabled: true # Set to false for "simple" 'quotes' (good ol' ASCII)
|
||||||
|
double:
|
||||||
|
left: '“'
|
||||||
|
right: '”'
|
||||||
|
single:
|
||||||
|
left: "‘"
|
||||||
|
right: "’"
|
||||||
|
|
||||||
# Defines files to ignore in a format compatible with .gitignore
|
# Defines files to ignore in a format compatible with .gitignore
|
||||||
spaceIgnore: |
|
spaceIgnore: |
|
||||||
|
|
Loading…
Reference in New Issue