diff --git a/docs/src/pages/api/core.svelte.md b/docs/src/pages/api/core.svelte.md index 4a733daf..91dc87f9 100644 --- a/docs/src/pages/api/core.svelte.md +++ b/docs/src/pages/api/core.svelte.md @@ -66,6 +66,12 @@ Type: `(html: string) => void` HTML sanitizer. See [here]({base}/getting-started#sanitization) for more details. +### `labels` + +Type: `Partial` + +Can be used to provide custom text for labels in the editor. + # `CartaEditor` options List of options that can be used in the `` component. diff --git a/package.json b/package.json index 2239bd79..26acf644 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "husky": "^8.0.3", "lint-staged": "^13.2.2", "ora": "^6.3.0", - "prettier": "^3.1.0", + "prettier": "3.1.0", "prettier-plugin-svelte": "^3.1.0", "prettier-plugin-tailwindcss": "^0.5.7", "semantic-release": "^20.1.3", diff --git a/packages/carta-md/src/lib/CartaEditor.svelte b/packages/carta-md/src/lib/CartaEditor.svelte index a8c339a8..ef93f5ac 100644 --- a/packages/carta-md/src/lib/CartaEditor.svelte +++ b/packages/carta-md/src/lib/CartaEditor.svelte @@ -5,6 +5,7 @@ import MarkdownInput from './internal/components/MarkdownInput.svelte'; import { debounce } from './internal/utils'; import type { TextAreaProps } from './internal/textarea-props'; + import { DefaultCartaLabels, type CartaLabels } from './internal/labels'; export let carta: Carta; export let theme = 'default'; @@ -15,6 +16,13 @@ export let placeholder = ''; export let textarea: TextAreaProps = {}; + let userLabels: Partial = {}; + export { userLabels as labels }; + const labels: CartaLabels = { + ...DefaultCartaLabels, + ...userLabels + }; + let width: number; let selectedTab: 'write' | 'preview' = 'write'; let windowMode: 'tabs' | 'split'; @@ -99,14 +107,14 @@ on:click={() => (selectedTab = 'write')} class={selectedTab === 'write' ? 'carta-active' : ''} > - Write + {labels.writeTab} {/if} diff --git a/packages/carta-md/src/lib/index.ts b/packages/carta-md/src/lib/index.ts index 3c450b45..57264d9a 100644 --- a/packages/carta-md/src/lib/index.ts +++ b/packages/carta-md/src/lib/index.ts @@ -7,5 +7,6 @@ export type { Prefix } from '$lib/internal/prefixes'; export * from '$lib/internal/carta'; export * from '$lib/internal/highlight'; export * from '$lib/internal/textarea-props'; +export * from '$lib/internal/labels'; export * from './default.css?inline'; export * from './light.css?inline'; diff --git a/packages/carta-md/src/lib/internal/labels.ts b/packages/carta-md/src/lib/internal/labels.ts new file mode 100644 index 00000000..00fa5dca --- /dev/null +++ b/packages/carta-md/src/lib/internal/labels.ts @@ -0,0 +1,12 @@ +/** + * Labels that may appear in the editor. + */ +export interface CartaLabels { + writeTab: string; + previewTab: string; +} + +export const DefaultCartaLabels: CartaLabels = { + writeTab: 'Write', + previewTab: 'Preview' +};