@@ -37,22 +37,30 @@ editor.pm.setNodeAttrs(pos, attrs)
3737- ** Block-based JSON** — Notion-like format, easy to store and transform
3838- ** Framework-agnostic** — Vanilla JS core with React bindings (Vue, Svelte coming)
3939- ** TypeScript first** — Full type safety throughout
40- - ** Rich block types** — Headings, lists, code blocks, columns, and more
41- - ** Built-in UI** — Slash menu, bubble menu, drag & drop
40+ - ** Rich block types** — Headings, lists, code blocks, tables, columns, and more
41+ - ** Built-in UI** — Slash menu, bubble menu, drag & drop, table handles
4242
4343## Quick Start
4444
4545### Installation
4646
47+ First, configure npm to use GitHub Packages for the ` @labbs ` scope. Create or edit ` .npmrc ` in your project:
48+
49+ ```
50+ @labbs:registry=https://npm.pkg.github.com
51+ ```
52+
53+ Then install the packages:
54+
4755``` bash
48- npm install @openblock/ core @openblock/ react
56+ npm install @labbs/openblock- core @labbs/openblock- react
4957```
5058
5159### React
5260
5361``` tsx
54- import { useOpenBlock , OpenBlockView , SlashMenu , BubbleMenu } from ' @openblock/ react' ;
55- import ' @openblock/ core/styles/editor.css' ;
62+ import { useOpenBlock , OpenBlockView , SlashMenu , BubbleMenu , TableHandles } from ' @labbs/openblock- react' ;
63+ import ' @labbs/openblock- core/styles/editor.css' ;
5664
5765function Editor() {
5866 const editor = useOpenBlock ({
@@ -71,6 +79,7 @@ function Editor() {
7179 <OpenBlockView editor = { editor } />
7280 <SlashMenu editor = { editor } />
7381 <BubbleMenu editor = { editor } />
82+ <TableHandles editor = { editor } />
7483 </>
7584 );
7685}
@@ -79,8 +88,8 @@ function Editor() {
7988### Vanilla JS
8089
8190``` typescript
82- import { OpenBlockEditor } from ' @openblock/ core' ;
83- import ' @openblock/ core/styles/editor.css' ;
91+ import { OpenBlockEditor } from ' @labbs/openblock- core' ;
92+ import ' @labbs/openblock- core/styles/editor.css' ;
8493
8594const editor = new OpenBlockEditor ({
8695 initialContent: [/* blocks */ ],
@@ -122,6 +131,39 @@ editor.setBlockType('codeBlock', { language: 'typescript' })
122131editor .setBlockType (' bulletList' )
123132editor .setBlockType (' orderedList' )
124133editor .setBlockType (' blockquote' )
134+ editor .setBlockType (' table' )
135+ ```
136+
137+ ### Table Commands
138+
139+ ``` typescript
140+ import {
141+ addRowAfter ,
142+ addRowBefore ,
143+ deleteRow ,
144+ addColumnAfter ,
145+ addColumnBefore ,
146+ deleteColumn ,
147+ goToNextCell ,
148+ goToPreviousCell ,
149+ isInTable
150+ } from ' @labbs/openblock-core' ;
151+
152+ // Check if cursor is in a table
153+ if (isInTable (editor .pm .state )) {
154+ // Add row after current row
155+ addRowAfter (editor .pm .state , editor .pm .view .dispatch );
156+
157+ // Add column before current column
158+ addColumnBefore (editor .pm .state , editor .pm .view .dispatch );
159+
160+ // Delete current row
161+ deleteRow (editor .pm .state , editor .pm .view .dispatch );
162+ }
163+
164+ // Navigate between cells (Tab / Shift+Tab)
165+ goToNextCell (editor .pm .state , editor .pm .view .dispatch );
166+ goToPreviousCell (editor .pm .state , editor .pm .view .dispatch );
125167```
126168
127169### ProseMirror Access
@@ -158,16 +200,67 @@ const blocks = [
158200 type: ' paragraph' ,
159201 props: {},
160202 content: [{ type: ' text' , text: ' Hello world' , styles: {} }]
203+ },
204+ {
205+ id: ' table-1' ,
206+ type: ' table' ,
207+ props: {},
208+ children: [
209+ {
210+ id: ' row-1' ,
211+ type: ' tableRow' ,
212+ props: {},
213+ children: [
214+ { id: ' header-1' , type: ' tableHeader' , props: {}, content: [{ type: ' text' , text: ' Name' , styles: {} }] },
215+ { id: ' header-2' , type: ' tableHeader' , props: {}, content: [{ type: ' text' , text: ' Value' , styles: {} }] }
216+ ]
217+ },
218+ {
219+ id: ' row-2' ,
220+ type: ' tableRow' ,
221+ props: {},
222+ children: [
223+ { id: ' cell-1' , type: ' tableCell' , props: {}, content: [{ type: ' text' , text: ' Item' , styles: {} }] },
224+ { id: ' cell-2' , type: ' tableCell' , props: {}, content: [{ type: ' text' , text: ' 100' , styles: {} }] }
225+ ]
226+ }
227+ ]
161228 }
162229];
163230```
164231
232+ ## React Components
233+
234+ ### OpenBlockView
235+ The main editor component that renders the ProseMirror view.
236+
237+ ### SlashMenu
238+ Displays a command palette when typing ` / ` to insert blocks.
239+
240+ ### BubbleMenu
241+ Floating toolbar that appears when selecting text for formatting.
242+
243+ ### TableHandles
244+ Renders handles on tables for adding/removing rows and columns.
245+
246+ ``` tsx
247+ import { TableHandles } from ' @labbs/openblock-react' ;
248+
249+ // Add to your editor
250+ <TableHandles editor = { editor } />
251+ ```
252+
253+ When hovering over a table:
254+ - ** Row handles** appear on the left — click to insert/delete rows
255+ - ** Column handles** appear on top — click to insert/delete columns
256+ - ** Extend buttons** appear on the right and bottom — click to add rows/columns
257+
165258## Packages
166259
167260| Package | Description |
168261| ---------| -------------|
169- | [ @openblock/ core ] ( packages/core ) | Framework-agnostic editor core |
170- | [ @openblock/ react ] ( packages/react ) | React bindings and components |
262+ | [ @labbs/openblock- core ] ( packages/core ) | Framework-agnostic editor core |
263+ | [ @labbs/openblock- react ] ( packages/react ) | React bindings and components |
171264
172265## Development
173266
0 commit comments