Free & open source · v1.0.1

Kalpna Editor — Free Rich Text Editor for Angular & HTML Websites

Kalpna Editor is a free, open-source (MIT) WYSIWYG rich text editor built by Simplycode Technology. Use it as an Angular component with npm install kalpna-editor, or add one script tag to any plain HTML or PHP website. It includes tables with merged cells, image upload and resize, Microsoft Word (.docx) import, media embeds, find & replace, a built-in HTML sanitizer and an English or Marathi interface.

MIT licence · ₹0Angular 17–19Plain HTML / PHPEnglish & मराठी UINo runtime dependencies
npm install kalpna-editor
Try the live demo View on GitHub

Live demo

This is the real editor, running in your browser. Type, paste, add a table, drop in an image or import a .docx file. Nothing you type here is sent to our server.

Loading Kalpna Editor…
See the HTML output
HTML output

Features

Text & fonts

Bold, italic, underline, strikethrough, subscript, superscript, inline code, font family and size, text and background colour, highlight pens, line height, change case and format painter.

Paragraphs & lists

Headings 1–6, alignment, indent, block quote, LTR/RTL direction, bulleted and numbered lists with list styles, start number and reversed order, plus to-do lists with checkboxes.

Tables

Grid picker, insert and delete rows or columns, merge and split cells, header row and column, table and cell properties (border, background, padding, size, alignment), captions and Tab navigation.

Images & media

Upload, paste, drag & drop or insert by URL; resize with handles, captions, alt text and six alignment styles. Embed YouTube, Vimeo, Dailymotion, Spotify, Google Maps, Facebook video and SoundCloud.

Word import

Import .docx files in the browser with headings, styles, colours, lists, tables with merged cells, images, links and page breaks. Paste from Word and Google Docs is cleaned automatically.

Writing tools

Find & replace, autoformat (#, *, 1., [], ```), text transformation, @mentions and #tags, special characters (including ₹ and Devanagari), emoji and paste as plain text.

View & export

Source editing, show blocks, preview, fullscreen, print, export to Word (.doc) and PDF (via print), word and character count, character limit and autosave.

Security

A built-in sanitizer cleans every value, paste, drop and source edit: scripts, event handlers, javascript: URLs and unsafe CSS are removed; iframes are allowed only for known embed players.

English & Marathi

Switch the whole interface to Marathi with one setting, or override any label to translate it into another language.

Setup guide

Choose your stack. Both options run the same editor and produce the same HTML.

Angular setup (Angular 17, 18, 19)

1Install the package

bash
npm install kalpna-editor

2Import the standalone component

TypeScript
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { KalpnaEditorComponent } from 'kalpna-editor';

@Component({
  selector: 'app-post-editor',
  standalone: true,
  imports: [FormsModule, KalpnaEditorComponent],
  template: `
    <kalpna-editor [(ngModel)]="html" placeholder="Start writing…"></kalpna-editor>
    <button (click)="save()">Save</button>
  `
})
export class PostEditorComponent {
  html = '<p>Hello</p>';

  save() {
    console.log(this.html); // send this HTML to your API
  }
}

3Reactive forms (optional)

TypeScript
import { FormControl, ReactiveFormsModule } from '@angular/forms';

body = new FormControl('<p></p>');

// template:
// <kalpna-editor [formControl]="body"></kalpna-editor>

4Configure the toolbar, language and image upload

TypeScript
import { KalpnaEditorConfig, KalpnaUploadHook, BASIC_TOOLBAR } from 'kalpna-editor';

config: KalpnaEditorConfig = {
  language: 'mr',                 // 'en' (default) | 'mr'
  maxHeight: '600px',
  maxCharacters: 5000,
  fontFamilies: ['Arial', 'Mukta', 'Noto Sans Devanagari'],
  wordCount: true,
  autosaveDelay: 1500
};

toolbar = BASIC_TOOLBAR;          // or DEFAULT_TOOLBAR, or your own list

uploadHook: KalpnaUploadHook = {
  image: async (file: File) => {
    const form = new FormData();
    form.append('file', file);
    const res = await fetch('/api/upload', { method: 'POST', body: form });
    return (await res.json()).url;   // must be an http(s) or relative URL
  }
};

// template:
// <kalpna-editor [config]="config" [toolbar]="toolbar" [uploadHook]="uploadHook"
//                (autosave)="saveDraft($event)"></kalpna-editor>
Angular inputs and outputs
Input / outputTypeWhat it does
[(ngModel)] / [formControl]string (HTML)Two-way value through Angular forms
placeholderstringText shown when the editor is empty
readOnly / disabledbooleanRead-only view (toolbar hidden) or disabled form control
toolbarKalpnaToolbarItem[]Toolbar items in order; '|' adds a separator
configKalpnaEditorConfigLanguage, heights, fonts, limits, mentions, autosave
uploadHookKalpnaUploadHookYour image upload function; returns the image URL
minHeightstringMinimum editing area height (default 200px)
(contentChange) / (textChange)stringSanitized HTML / plain text on every change
(autosave)stringDebounced HTML for saving drafts
(wordCountChange){ words, characters }Live word and character count

HTML / PHP setup (no Angular needed)

For WordPress themes, PHP admin panels, static sites or any backend, use the ready-made Web Component <kalpna-html-editor>. Your page does not need Angular, npm or a build step.

1Add the script once, before </body>

HTML
<script type="module" src="https://www.simplycode.in/kalpna-editor/cdn/kalpna-editor.js"></script>

You can also download kalpna-editor.js (about 170 KB gzipped) and serve it from your own server.

2Add a textarea and the editor inside your form

HTML
<form action="save.php" method="post">
  <label for="title">Title</label>
  <input id="title" name="title" type="text">

  <!-- The editor reads its starting content from this textarea and keeps it updated -->
  <textarea id="body" name="body" hidden><p>Hello world</p></textarea>
  <kalpna-html-editor target="#body" placeholder="Start writing…"></kalpna-html-editor>

  <button type="submit">Save</button>
</form>

3Save the HTML on your server (PHP example)

PHP
<?php
// save.php
$html = isset($_POST['body']) ? $_POST['body'] : '';

// Always sanitize again on the server before storing.
// Example: HTML Purifier (composer require ezyang/htmlpurifier)
require 'vendor/autoload.php';
$config   = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config);
$cleanHtml = $purifier->purify($html);

$pdo  = new PDO('mysql:host=localhost;dbname=site;charset=utf8mb4', 'user', 'pass');
$stmt = $pdo->prepare('INSERT INTO posts (title, body) VALUES (?, ?)');
$stmt->execute([$_POST['title'], $cleanHtml]);

4Options and JavaScript access (optional)

HTML
<kalpna-html-editor
  id="editor"
  target="#body"
  language="mr"
  toolbar="basic"
  min-height="300px"
  max-height="600px"
  max-characters="5000"
  upload-url="/upload-image.php">
</kalpna-html-editor>

<script>
  const editor = document.getElementById('editor');

  // Fires on every change
  editor.addEventListener('kalpna-change', (e) => {
    console.log(e.detail.html, e.detail.text);
  });

  // Methods (available after the script has loaded)
  document.addEventListener('kalpna-ready', () => {
    // editor.getHtml(), editor.getText(), editor.setHtml('<p>New content</p>')
  });
</script>
<kalpna-html-editor> attributes
AttributeDefaultWhat it does
target—CSS selector of a <textarea>: the editor loads its content and keeps it updated for form submission
value—Starting HTML when you do not use target
placeholder—Text shown when the editor is empty
languageenen or mr (Marathi interface)
toolbarfullfull, basic, or a comma list such as bold,italic,|,link,image,table
min-height / max-height250px / —Editing area height limits
max-characters—Character limit
readonlyoffShows content without the toolbar
upload-url—POST endpoint for images; receives file, must return {"url": "…"}. Without it, images are stored as base64.

Image upload endpoint (PHP example)

PHP
<?php
// upload-image.php — returns {"url": "..."} for Kalpna Editor
header('Content-Type: application/json');
$allowed = ['image/jpeg' => 'jpg', 'image/png' => 'png', 'image/webp' => 'webp', 'image/gif' => 'gif'];
$f = $_FILES['file'] ?? null;
if (!$f || $f['error'] !== UPLOAD_ERR_OK || $f['size'] > 5 * 1024 * 1024) {
    http_response_code(400); echo json_encode(['error' => 'Invalid file']); exit;
}
$type = mime_content_type($f['tmp_name']);
if (!isset($allowed[$type])) { http_response_code(415); echo json_encode(['error' => 'Type not allowed']); exit; }
$name = bin2hex(random_bytes(8)) . '.' . $allowed[$type];
move_uploaded_file($f['tmp_name'], __DIR__ . '/uploads/' . $name);
echo json_encode(['url' => '/uploads/' . $name]);

Showing saved content on your website

Saved HTML uses a few classes for images, to-do lists, highlights and page breaks. Wrap it in .kalpna-content and add the content stylesheet once so it looks the same as in the editor.

Angular
import { KALPNA_CONTENT_CSS } from 'kalpna-editor';
document.head.insertAdjacentHTML('beforeend', `<style>${KALPNA_CONTENT_CSS}</style>`);

// template:
// <div class="kalpna-content" [innerHTML]="savedHtml"></div>
HTML / PHP
<div class="kalpna-content"><?= $cleanHtml ?></div>

<script type="module" src="https://www.simplycode.in/kalpna-editor/cdn/kalpna-editor.js"></script>
<script>
  document.addEventListener('kalpna-ready', () => KalpnaEditor.injectContentCss());
</script>

Security, browser support and limits

  • Sanitized input: initial values, paste, drop, source mode and setHtml all pass through the built-in sanitizer.
  • Server-side cleaning is still your job: sanitize HTML again before saving, and use a Content-Security-Policy on pages that show user content.
  • Browsers: current Chrome, Edge, Firefox and Safari. Find highlights use the CSS Custom Highlight API (Chrome 105+, Safari 17.2+, Firefox 140+) and fall back to selecting the match in older browsers.
  • Not included yet: real-time collaboration, track changes, comments, revision history, server-side DOCX/PDF conversion and a file manager.
  • Known limits: table actions work on the cell with the caret (no multi-cell selection); Word import supports .docx only; export to PDF uses the browser print dialog.

कल्पना एडिटर — मराठीत थोडक्यात

कल्पना एडिटर हा सिम्पलीकोड टेक्नॉलॉजीने बनवलेला मोफत, ओपन-सोर्स रिच टेक्स्ट एडिटर आहे. Angular प्रोजेक्टमध्ये npm install kalpna-editor करून वापरा, किंवा साध्या HTML / PHP वेबसाइटमध्ये एक script टॅग जोडून वापरा. टूलबार आणि सर्व संवाद मराठीत दिसू शकतात (language="mr"). टेबल, फोटो, Word (.docx) फाइल इम्पोर्ट, शोधा व बदला अशा सर्व सुविधा यात आहेत.

Kalpna Editor: frequently asked questions

What is Kalpna Editor?

Kalpna Editor is a free, open-source WYSIWYG rich text editor developed by Simplycode Technology. It works as an Angular component (npm install kalpna-editor) and as a standard Web Component (<kalpna-html-editor>) for plain HTML, PHP or any other website. It is released under the MIT licence.

Is Kalpna Editor free for commercial projects?

Yes. Kalpna Editor is released under the MIT licence, so you can use it in personal, client and commercial projects at no cost. Keep the licence notice with the code.

Which Angular versions does Kalpna Editor support?

Version 1.0.1 supports Angular 17, 18 and 19 as a standalone component. It works with both template-driven forms (ngModel) and reactive forms (formControl). Node.js 18 or newer is recommended.

Can I use Kalpna Editor without Angular, on a plain HTML or PHP website?

Yes. Add one script tag and place <kalpna-html-editor target="#body"></kalpna-html-editor> in your page. The editor keeps a normal <textarea> updated, so a regular HTML form posts the content to PHP, Node.js, .NET or any backend without extra JavaScript.

Does Kalpna Editor support Marathi and Devanagari?

Yes. The toolbar and dialogs are available in English and Marathi (set language="mr"), the special-character panel includes Devanagari and the ₹ sign, and you can add Devanagari fonts such as Mukta or Noto Sans Devanagari to the font list.

Can Kalpna Editor import Microsoft Word documents?

Yes. Kalpna Editor imports .docx files in the browser, without a server, keeping headings, text styles, colours, lists, tables with merged cells, images, links and page breaks. Old .doc files need to be re-saved as .docx first. Footnotes, headers and footers, comments, charts and SmartArt are skipped.

How do I upload images to my own server?

Without an upload handler, images are stored inside the HTML as base64. For production sites, pass an uploadHook in Angular, or the upload-url attribute on the HTML editor. Your endpoint receives the file as file in a POST request and returns JSON like {"url": "/uploads/photo.jpg"}.

Is the HTML produced by Kalpna Editor safe?

Everything that enters the editor is cleaned by a built-in sanitizer that removes scripts, event handlers, javascript: links and unsafe CSS, and only allows iframes from known video, music and map players. You should still sanitize the HTML again on your server before saving it, and use a Content-Security-Policy where users can submit content.

What is not included in Kalpna Editor yet?

Real-time collaboration, track changes, comments, revision history, server-side DOCX or PDF conversion and a file manager are not included yet. Export to PDF uses the browser's print dialog, and export to Word creates an HTML-based .doc file.

Can Simplycode Technology integrate Kalpna Editor into my project?

Yes. Simplycode Technology can add Kalpna Editor to your Angular application, PHP website, CMS or admin panel, including image upload, server-side sanitizing and storage. Contact us for a free quote.

Need Kalpna Editor integrated into your project?

We can set it up in your Angular app, PHP site or CMS, with image upload and server-side sanitizing. Free consultation.