diff --git a/type/web.ts b/type/web.ts index 5181c204..86d3d37d 100644 --- a/type/web.ts +++ b/type/web.ts @@ -18,6 +18,7 @@ export type BuiltinSettings = { shortcuts?: Shortcut[]; hideSyncButton?: boolean; hideEditButton?: boolean; + useSmartQuotes?: boolean; maximumAttachmentSize?: number; defaultLinkStyle?: string; actionButtons: ActionButton[]; diff --git a/web/cm_plugins/smart_quotes.ts b/web/cm_plugins/smart_quotes.ts index ecf178f3..88cc584b 100644 --- a/web/cm_plugins/smart_quotes.ts +++ b/web/cm_plugins/smart_quotes.ts @@ -1,6 +1,7 @@ import { KeyBinding } from "@codemirror/view"; import { syntaxTree } from "@codemirror/language"; import { EditorSelection } from "@codemirror/state"; +import { Client } from "../client.ts"; const straightQuoteContexts = [ "CommentBlock", @@ -78,7 +79,13 @@ function keyBindingForQuote( }; } -export const smartQuoteKeymap: KeyBinding[] = [ - keyBindingForQuote('"', "“", "”"), - keyBindingForQuote("'", "‘", "’"), -]; +export function createSmartQuoteKeyBindings(client: Client): KeyBinding[] { + if (client.settings.useSmartQuotes === false) { + return []; + } + + return [ + keyBindingForQuote('"', "“", "”"), + keyBindingForQuote("'", "‘", "’"), + ]; +} diff --git a/web/editor_state.ts b/web/editor_state.ts index bb8b09dd..357fb49d 100644 --- a/web/editor_state.ts +++ b/web/editor_state.ts @@ -30,7 +30,7 @@ import { Client } from "./client.ts"; import { inlineImagesPlugin } from "./cm_plugins/inline_content.ts"; import { cleanModePlugins } from "./cm_plugins/clean.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 { attachmentExtension, @@ -345,7 +345,7 @@ export function createCommandKeyBindings(client: Client): KeyBinding[] { export function createKeyBindings(client: Client): Extension { return keymap.of([ ...createCommandKeyBindings(client), - ...smartQuoteKeymap, + ...createSmartQuoteKeyBindings(client), ...closeBracketsKeymap, ...standardKeymap, ...completionKeymap, diff --git a/website/SETTINGS.md b/website/SETTINGS.md index ddb3822c..664ac49b 100644 --- a/website/SETTINGS.md +++ b/website/SETTINGS.md @@ -1,6 +1,6 @@ #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 # Initial page to load when launching SB, can contain template variables @@ -60,6 +60,9 @@ pageDecorations: - where: 'tags = "plug"' 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 spaceIgnore: | dist