Add setting for smart quotes (#960)
parent
1fc061ac6a
commit
e2cb2ab6e7
|
@ -18,6 +18,7 @@ export type BuiltinSettings = {
|
||||||
shortcuts?: Shortcut[];
|
shortcuts?: Shortcut[];
|
||||||
hideSyncButton?: boolean;
|
hideSyncButton?: boolean;
|
||||||
hideEditButton?: boolean;
|
hideEditButton?: boolean;
|
||||||
|
useSmartQuotes?: boolean;
|
||||||
maximumAttachmentSize?: number;
|
maximumAttachmentSize?: number;
|
||||||
defaultLinkStyle?: string;
|
defaultLinkStyle?: string;
|
||||||
actionButtons: ActionButton[];
|
actionButtons: ActionButton[];
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { KeyBinding } from "@codemirror/view";
|
import { KeyBinding } from "@codemirror/view";
|
||||||
import { syntaxTree } from "@codemirror/language";
|
import { syntaxTree } from "@codemirror/language";
|
||||||
import { EditorSelection } from "@codemirror/state";
|
import { EditorSelection } from "@codemirror/state";
|
||||||
|
import { Client } from "../client.ts";
|
||||||
|
|
||||||
const straightQuoteContexts = [
|
const straightQuoteContexts = [
|
||||||
"CommentBlock",
|
"CommentBlock",
|
||||||
|
@ -78,7 +79,13 @@ function keyBindingForQuote(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const smartQuoteKeymap: KeyBinding[] = [
|
export function createSmartQuoteKeyBindings(client: Client): KeyBinding[] {
|
||||||
keyBindingForQuote('"', "“", "”"),
|
if (client.settings.useSmartQuotes === false) {
|
||||||
keyBindingForQuote("'", "‘", "’"),
|
return [];
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
keyBindingForQuote('"', "“", "”"),
|
||||||
|
keyBindingForQuote("'", "‘", "’"),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import { Client } from "./client.ts";
|
||||||
import { inlineImagesPlugin } from "./cm_plugins/inline_content.ts";
|
import { inlineImagesPlugin } from "./cm_plugins/inline_content.ts";
|
||||||
import { cleanModePlugins } from "./cm_plugins/clean.ts";
|
import { cleanModePlugins } from "./cm_plugins/clean.ts";
|
||||||
import { lineWrapper } from "./cm_plugins/line_wrapper.ts";
|
import { lineWrapper } from "./cm_plugins/line_wrapper.ts";
|
||||||
import { smartQuoteKeymap } from "./cm_plugins/smart_quotes.ts";
|
import { createSmartQuoteKeyBindings } from "./cm_plugins/smart_quotes.ts";
|
||||||
import { ClickEvent } from "../plug-api/types.ts";
|
import { ClickEvent } from "../plug-api/types.ts";
|
||||||
import {
|
import {
|
||||||
attachmentExtension,
|
attachmentExtension,
|
||||||
|
@ -345,7 +345,7 @@ export function createCommandKeyBindings(client: Client): KeyBinding[] {
|
||||||
export function createKeyBindings(client: Client): Extension {
|
export function createKeyBindings(client: Client): Extension {
|
||||||
return keymap.of([
|
return keymap.of([
|
||||||
...createCommandKeyBindings(client),
|
...createCommandKeyBindings(client),
|
||||||
...smartQuoteKeymap,
|
...createSmartQuoteKeyBindings(client),
|
||||||
...closeBracketsKeymap,
|
...closeBracketsKeymap,
|
||||||
...standardKeymap,
|
...standardKeymap,
|
||||||
...completionKeymap,
|
...completionKeymap,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#meta
|
#meta
|
||||||
|
|
||||||
This page contains settings for configuring SilverBullet and its Plugs. Changing any of these will go into effect immediately in most cases except `indexPage` which requires a page reload.
|
This page contains settings for configuring SilverBullet and its Plugs. Changing any of these will go into effect immediately in most cases, some require a page reload.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Initial page to load when launching SB, can contain template variables
|
# Initial page to load when launching SB, can contain template variables
|
||||||
|
@ -60,6 +60,9 @@ pageDecorations:
|
||||||
- where: 'tags = "plug"'
|
- where: 'tags = "plug"'
|
||||||
prefix: "🔌 "
|
prefix: "🔌 "
|
||||||
|
|
||||||
|
# Toggles between “smart” ‘quotes’ (left and right) and "simple" 'quotes' (good ol' ASCII)
|
||||||
|
useSmartQuotes: true
|
||||||
|
|
||||||
# Defines files to ignore in a format compatible with .gitignore
|
# Defines files to ignore in a format compatible with .gitignore
|
||||||
spaceIgnore: |
|
spaceIgnore: |
|
||||||
dist
|
dist
|
||||||
|
|
Loading…
Reference in New Issue