Mount an editable text view in a browser application. You need a client-side JavaScript entry point and a bundler that resolves ESM and CSS imports, such as Vite.
1. Install the core
1
2
3
4
npm install
@singapore-editor/core
# or: pnpm add
@singapore-editor/core
# or: bun add
@singapore-editor/core
# or: yarn add
@singapore-editor/core
1
2
3
4
npm install
@singapore-editor/core
# or: pnpm add
@singapore-editor/core
# or: bun add
@singapore-editor/core
# or: yarn add
@singapore-editor/core
1
2
3
4
npm install
@singapore-editor/core
# or: pnpm add
@singapore-editor/core
# or: bun add
@singapore-editor/core
# or: yarn add
@singapore-editor/core
1
2
3
4
npm install
@singapore-editor/core
# or: pnpm add
@singapore-editor/core
# or: bun add
@singapore-editor/core
# or: yarn add
@singapore-editor/core
1
2
3
4
npm install @singapore-editor/core
# or: pnpm add
@singapore-editor/core
# or: bun add @singapore-editor/core
# or: yarn add
@singapore-editor/core
1
2
3
4
npm install @singapore-editor/core
# or: pnpm add
@singapore-editor/core
# or: bun add @singapore-editor/core
# or: yarn add
@singapore-editor/core
1
2
3
4
npm install @singapore-editor/core
# or: pnpm add @singapore-editor/core
# or: bun add @singapore-editor/core
# or: yarn add @singapore-editor/core
1
2
3
4
npm install @singapore-editor/core
# or: pnpm add @singapore-editor/core
# or: bun add @singapore-editor/core
# or: yarn add @singapore-editor/core
1
2
3
4
npm install @singapore-editor/core
# or: pnpm add @singapore-editor/core
# or: bun add @singapore-editor/core
# or: yarn add @singapore-editor/core
1
2
3
4
npm install @singapore-editor/core
# or: pnpm add @singapore-editor/core
# or: bun add @singapore-editor/core
# or: yarn add @singapore-editor/core
1
2
3
4
npm install @singapore-editor/core
# or: pnpm add @singapore-editor/core
# or: bun add @singapore-editor/core
# or: yarn add @singapore-editor/core
1
2
3
4
npm install @singapore-editor/core
# or: pnpm add @singapore-editor/core
# or: bun add @singapore-editor/core
# or: yarn add @singapore-editor/core
1
2
3
4
npm install @singapore-editor/core
# or: pnpm add @singapore-editor/core
# or: bun add @singapore-editor/core
# or: yarn add @singapore-editor/core
1
2
3
4
npm install @singapore-editor/core
# or: pnpm add @singapore-editor/core
# or: bun add @singapore-editor/core
# or: yarn add @singapore-editor/core
sh example
2. Give the editor a container
Add an HTML element with the id editor. Set height: 20rem, display: flex and flex-direction: column in your stylesheet. This constrains the editor’s scroll area to the element’s height.
3. Mount it
Save this as main.ts. Retain the editor so you can release it when the view closes.
You should see one line of text and be able to move the caret, select text and type. Undo returns to an earlier edit. Syntax colours need a highlighting plugin. If nothing shows, see If it doesn’t work.
Choose Make live under a code example to try editing it. Changes stay in this browser tab.
Open a named document
Use a document id when a view needs identity, such as a tab or a language-server URI. Plain setText remains useful for unnamed text.