Skip to content

Commit b8cb6dc

Browse files
authored
Update package references and enhance README (#4)
* fix: update package references to use '@Labbs' namespace * feat: enhance README with table commands and updated installation instructions * fix: update package filters in deploy workflow to use '@Labbs' namespace * feat: add GitHub Actions workflow for publishing to GitHub Packages * feat: update package names and imports to use '@Labbs' namespace; add table support in sample document * refactor: rename package and update imports to @Labbs scope - Updated package name from @openblock/react to @labbs/openblock-react. - Changed dependencies and imports to use @labbs/openblock-core. - Added new components: TableHandles and TableMenu for enhanced table editing. - Updated README and package.json for new package details and installation instructions. - Refactored existing components to align with new package structure.
1 parent 034c7ad commit b8cb6dc

40 files changed

Lines changed: 2877 additions & 55 deletions

.github/workflows/deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
node-version: '20'
2626
cache: 'pnpm'
2727
- run: pnpm install
28-
- run: pnpm --filter @openblock/core build && pnpm --filter @openblock/react build
29-
- run: pnpm --filter @openblock/example-basic build
28+
- run: pnpm --filter @labbs/openblock-core build && pnpm --filter @labbs/openblock-react build
29+
- run: pnpm --filter @labbs/openblock-example-basic build
3030
- uses: actions/configure-pages@v4
3131
- uses: actions/upload-pages-artifact@v3
3232
with:

.github/workflows/publish.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish to GitHub Packages
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
packages: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: pnpm/action-setup@v2
17+
with:
18+
version: 8
19+
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
cache: 'pnpm'
24+
registry-url: 'https://npm.pkg.github.com'
25+
scope: '@labbs'
26+
27+
- run: pnpm install
28+
29+
- name: Build packages
30+
run: |
31+
pnpm --filter @labbs/openblock-core build
32+
pnpm --filter @labbs/openblock-react build
33+
34+
- name: Publish @labbs/openblock-core
35+
run: pnpm --filter @labbs/openblock-core publish --access public --no-git-checks
36+
env:
37+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Publish @labbs/openblock-react
40+
run: pnpm --filter @labbs/openblock-react publish --access public --no-git-checks
41+
env:
42+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 102 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

5765
function 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

8594
const editor = new OpenBlockEditor({
8695
initialContent: [/* blocks */],
@@ -122,6 +131,39 @@ editor.setBlockType('codeBlock', { language: 'typescript' })
122131
editor.setBlockType('bulletList')
123132
editor.setBlockType('orderedList')
124133
editor.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

examples/basic/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@openblock/example-basic",
2+
"name": "@labbs/openblock-example-basic",
33
"version": "0.0.1",
44
"private": true,
55
"type": "module",
@@ -9,8 +9,8 @@
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12-
"@openblock/core": "workspace:*",
13-
"@openblock/react": "workspace:*",
12+
"@labbs/openblock-core": "workspace:*",
13+
"@labbs/openblock-react": "workspace:*",
1414
"react": "^18.3.1",
1515
"react-dom": "^18.3.1"
1616
},

examples/basic/src/App.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { useOpenBlock, OpenBlockView, useEditorContent, SlashMenu, BubbleMenu } from '@openblock/react';
1+
import { useOpenBlock, OpenBlockView, useEditorContent, SlashMenu, BubbleMenu, TableHandles } from '@labbs/openblock-react';
22
import { sampleDocument } from './data';
3-
import '@openblock/core/styles/editor.css';
3+
import '@labbs/openblock-core/styles/editor.css';
44
import './styles.css';
55

66
export default function App() {
@@ -48,6 +48,7 @@ export default function App() {
4848
<OpenBlockView editor={editor} />
4949
<SlashMenu editor={editor} />
5050
<BubbleMenu editor={editor} />
51+
<TableHandles editor={editor} />
5152
</div>
5253
</div>
5354

examples/basic/src/data.ts

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Block } from '@openblock/core';
1+
import type { Block } from '@labbs/openblock-core';
22

33
/**
44
* Sample document with all formatting options for testing.
@@ -250,6 +250,130 @@ export const sampleDocument: Block[] = [
250250
type: 'divider',
251251
props: {},
252252
},
253+
{
254+
id: 'heading-tables',
255+
type: 'heading',
256+
props: { level: 2 },
257+
content: [{ type: 'text', text: 'Tables', styles: {} }],
258+
},
259+
{
260+
id: 'para-tables-intro',
261+
type: 'paragraph',
262+
props: {},
263+
content: [{ type: 'text', text: 'Tables support headers, multiple columns, and formatted content:', styles: {} }],
264+
},
265+
{
266+
id: 'table-1',
267+
type: 'table',
268+
props: {},
269+
children: [
270+
{
271+
id: 'table-row-header',
272+
type: 'tableRow',
273+
props: {},
274+
children: [
275+
{
276+
id: 'header-cell-1',
277+
type: 'tableHeader',
278+
props: {},
279+
content: [{ type: 'text', text: 'Feature', styles: { bold: true } }],
280+
},
281+
{
282+
id: 'header-cell-2',
283+
type: 'tableHeader',
284+
props: {},
285+
content: [{ type: 'text', text: 'Status', styles: { bold: true } }],
286+
},
287+
{
288+
id: 'header-cell-3',
289+
type: 'tableHeader',
290+
props: {},
291+
content: [{ type: 'text', text: 'Description', styles: { bold: true } }],
292+
},
293+
],
294+
},
295+
{
296+
id: 'table-row-1',
297+
type: 'tableRow',
298+
props: {},
299+
children: [
300+
{
301+
id: 'cell-1-1',
302+
type: 'tableCell',
303+
props: {},
304+
content: [{ type: 'text', text: 'Rich Text', styles: {} }],
305+
},
306+
{
307+
id: 'cell-1-2',
308+
type: 'tableCell',
309+
props: {},
310+
content: [{ type: 'text', text: 'Complete', styles: { bold: true } }],
311+
},
312+
{
313+
id: 'cell-1-3',
314+
type: 'tableCell',
315+
props: {},
316+
content: [{ type: 'text', text: 'Bold, italic, underline, code', styles: {} }],
317+
},
318+
],
319+
},
320+
{
321+
id: 'table-row-2',
322+
type: 'tableRow',
323+
props: {},
324+
children: [
325+
{
326+
id: 'cell-2-1',
327+
type: 'tableCell',
328+
props: {},
329+
content: [{ type: 'text', text: 'Columns', styles: {} }],
330+
},
331+
{
332+
id: 'cell-2-2',
333+
type: 'tableCell',
334+
props: {},
335+
content: [{ type: 'text', text: 'Complete', styles: { bold: true } }],
336+
},
337+
{
338+
id: 'cell-2-3',
339+
type: 'tableCell',
340+
props: {},
341+
content: [{ type: 'text', text: 'Resizable multi-column layouts', styles: {} }],
342+
},
343+
],
344+
},
345+
{
346+
id: 'table-row-3',
347+
type: 'tableRow',
348+
props: {},
349+
children: [
350+
{
351+
id: 'cell-3-1',
352+
type: 'tableCell',
353+
props: {},
354+
content: [{ type: 'text', text: 'Tables', styles: {} }],
355+
},
356+
{
357+
id: 'cell-3-2',
358+
type: 'tableCell',
359+
props: {},
360+
content: [{ type: 'text', text: 'New', styles: { italic: true } }],
361+
},
362+
{
363+
id: 'cell-3-3',
364+
type: 'tableCell',
365+
props: {},
366+
content: [{ type: 'text', text: 'Header rows and data cells', styles: {} }],
367+
},
368+
],
369+
},
370+
],
371+
},
372+
{
373+
id: 'divider-4',
374+
type: 'divider',
375+
props: {},
376+
},
253377
{
254378
id: 'heading-api',
255379
type: 'heading',

0 commit comments

Comments
 (0)