Skip to main content

Static assets and helpers for the BlockWriteAI JSON-first editor with free core blocks and license-gated premium plugins.

Project description

BlockWriteAI

BlockWriteAI is a JSON-first block editor for web apps. It works with a script tag, npm, PHP/Composer, and Python static-file workflows.

Use the free core editor for normal documents. Serve premium tools such as AI, Mermaid, Drawing, Signature, and Signature Flow only through your licensed server endpoint.

Quick Start With CDN

Add the stylesheet, editor script, and free plugin bundle:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/blockwriteai.min.css">

<div id="editor"></div>

<script src="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/blockwriteai.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/plugins/blockwriteai-code-assist.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/plugins/blockwriteai-advanced-blocks.min.js"></script>
<script>
  const editor = new BlockWriteAI({
    holder: "#editor",
    placeholder: "Write something, or press / for blocks",
    async onSave(data) {
      await fetch("/api/documents", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(data)
      });
    }
  });
</script>

Use these CDN URLs for production:

https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/blockwriteai.min.css
https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/blockwriteai.min.js
https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/plugins/blockwriteai-code-assist.min.js
https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/plugins/blockwriteai-advanced-blocks.min.js

Optional history plugin:

<script src="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/plugins/blockwriteai-history.min.js"></script>

Premium CDN integrations should load licensed plugins and verify usage through the production BlockWriteAI Platform:

await BlockWriteAI.loadPremiumPlugins({
  licenseKey: "bwai_live_xxxxx",
  endpoint: BlockWriteAI.platformEndpoints.premiumPlugins,
  features: ["drawing", "mermaid", "signature", "signature_flow", "ai"]
});

Install With Node

npm install @qarakash/blockwriteai
import BlockWriteAI from "@qarakash/blockwriteai";
import "@qarakash/blockwriteai/css";
import "@qarakash/blockwriteai/plugins/code-assist/min";
import "@qarakash/blockwriteai/plugins/advanced/min";

const editor = new BlockWriteAI({
  holder: "#editor",
  premium: {
    licenseKey: "bwai_live_xxxxx",
    verifyEndpoint: BlockWriteAI.platformEndpoints.licenseVerify,
    usageEndpoint: BlockWriteAI.platformEndpoints.aiUsage,
    featureUsageEndpoint: BlockWriteAI.platformEndpoints.premiumUsage,
    eventEndpoint: BlockWriteAI.platformEndpoints.premiumEvent,
    signatureEventEndpoint: BlockWriteAI.platformEndpoints.signatureEvent
  },
  async onSave(data) {
    await fetch("/api/documents", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(data)
    });
  }
});

Install With PHP

composer require qarakash/blockwriteai

Publish the package dist assets into a public asset directory in your app, then print the tags:

<?php

use QarAkash\BlockWriteAI\BlockWriteAIAssets;

echo BlockWriteAIAssets::stylesheetTag('/assets/blockwriteai');
echo BlockWriteAIAssets::scriptTags('/assets/blockwriteai');

$platform = BlockWriteAIAssets::platformEndpoints();

Create the editor:

<div id="editor"></div>
<script>
  const editor = new BlockWriteAI({
    holder: "#editor",
    async onSave(data) {
      await fetch("/api/documents/save.php", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(data)
      });
    }
  });
</script>

Install With Python

pip install blockwriteai-editor

Copy the packaged assets into your app static directory:

from blockwriteai_editor import copy_static

copy_static("static/blockwriteai")

Generate tags in Flask, Django, or any Python web app:

from blockwriteai_editor import platform_endpoints, stylesheet_tag, script_tags

print(stylesheet_tag("/static/blockwriteai"))
print(script_tags("/static/blockwriteai"))

platform = platform_endpoints()

Then mount the editor in your template:

<div id="editor"></div>
<script>
  const editor = new BlockWriteAI({
    holder: "#editor",
    async onSave(data) {
      await fetch("/api/documents", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(data)
      });
    }
  });
</script>

Read Saved Documents

BlockWriteAI saves JSON. Store that JSON in your database, then render it later with a preview container:

<link rel="stylesheet" href="/assets/blockwriteai/blockwriteai.min.css">

<div class="blockwriteai-preview" data-source="/api/documents/123.json"></div>

<script src="/assets/blockwriteai/blockwriteai.min.js"></script>
<script src="/assets/blockwriteai/plugins/blockwriteai-advanced-blocks.min.js"></script>
<script>
  BlockWriteAI.mountPreviews();
</script>

The JSON endpoint can return a document directly:

{
  "time": 1779540000000,
  "version": "1.0.16",
  "blocks": []
}

It can also return a wrapper:

{
  "ok": true,
  "data": {
    "time": 1779540000000,
    "version": "1.0.16",
    "blocks": []
  }
}

Premium Plugins

Do not expose premium plugin files as normal public scripts. Load them after your server verifies an active license:

<script>
  async function bootEditor() {
    await BlockWriteAI.loadPremiumPlugins({
      licenseKey: "bwai_live_xxxxx",
      endpoint: "https://blockwriteai.in/api/premium_plugins.php",
      features: ["drawing", "mermaid", "signature", "signature_flow", "ai"]
    });

    window.editor = new BlockWriteAI({
      holder: "#editor",
      premium: {
        licenseKey: "bwai_live_xxxxx",
        verifyEndpoint: "https://blockwriteai.in/api/license_verify.php",
        usageEndpoint: "https://blockwriteai.in/api/ai_usage.php"
      },
      ai: {
        endpoint: "https://blockwriteai.in/api/ai_generate.php"
      }
    });
  }

  bootEditor();
</script>

The browser plugin must never receive private API keys. Keep OpenAI, billing, usage limits, and license checks on your server.

Release Checklist

  1. Run npm run build:min.
  2. Run npm run check.
  3. Publish @qarakash/blockwriteai to npm.
  4. Publish qarakash/blockwriteai to Packagist.
  5. Publish blockwriteai-editor to PyPI.
  6. Serve only the public asset directory from your application.

Notes For Production

  • Use the .min.css and .min.js files in public pages.
  • Do not publish source folders, examples, build artifacts, package caches, or private configuration files.
  • Browser-delivered CSS and JavaScript can always be downloaded. Protect paid features with server-side license checks and metered premium bundle delivery.
  • Keep secret keys in backend environment variables only.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blockwriteai_editor-1.1.0.tar.gz (118.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blockwriteai_editor-1.1.0-py3-none-any.whl (129.5 kB view details)

Uploaded Python 3

File details

Details for the file blockwriteai_editor-1.1.0.tar.gz.

File metadata

  • Download URL: blockwriteai_editor-1.1.0.tar.gz
  • Upload date:
  • Size: 118.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for blockwriteai_editor-1.1.0.tar.gz
Algorithm Hash digest
SHA256 87c64af1ee85c52d26ea25e41ac619c6380e2c1e9750b5ff9a17c5a8758e5b7d
MD5 4695eb43889f32e0d02044c673d7b7a0
BLAKE2b-256 6d2e8a082a5d12396d13e6ead1ee1dd01bf77281e0cdcefe2528a0aeb7b62f0c

See more details on using hashes here.

File details

Details for the file blockwriteai_editor-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for blockwriteai_editor-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a579aebc08f1a5f38eb2a28098af1344fcc21ab5f480b271ab6e1a00b53b286
MD5 f40c894a0cab59da8c7d8d681271ef8b
BLAKE2b-256 984d8f0a26f4abc9e8cdb72f7f0bf5ff3eaee2346abc8d49e9e113d19cc2f4bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page