inkpen 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.rubocop.yml +8 -0
  4. data/.yardopts +11 -0
  5. data/CLAUDE.md +141 -0
  6. data/README.md +409 -0
  7. data/Rakefile +19 -0
  8. data/app/assets/javascripts/inkpen/controllers/editor_controller.js +2050 -0
  9. data/app/assets/javascripts/inkpen/controllers/sticky_toolbar_controller.js +667 -0
  10. data/app/assets/javascripts/inkpen/controllers/toolbar_controller.js +693 -0
  11. data/app/assets/javascripts/inkpen/export/html.js +637 -0
  12. data/app/assets/javascripts/inkpen/export/index.js +30 -0
  13. data/app/assets/javascripts/inkpen/export/markdown.js +697 -0
  14. data/app/assets/javascripts/inkpen/export/pdf.js +372 -0
  15. data/app/assets/javascripts/inkpen/extensions/advanced_table.js +640 -0
  16. data/app/assets/javascripts/inkpen/extensions/block_commands.js +300 -0
  17. data/app/assets/javascripts/inkpen/extensions/block_gutter.js +338 -0
  18. data/app/assets/javascripts/inkpen/extensions/callout.js +303 -0
  19. data/app/assets/javascripts/inkpen/extensions/columns.js +403 -0
  20. data/app/assets/javascripts/inkpen/extensions/database.js +990 -0
  21. data/app/assets/javascripts/inkpen/extensions/document_section.js +352 -0
  22. data/app/assets/javascripts/inkpen/extensions/drag_handle.js +407 -0
  23. data/app/assets/javascripts/inkpen/extensions/embed.js +629 -0
  24. data/app/assets/javascripts/inkpen/extensions/enhanced_image.js +566 -0
  25. data/app/assets/javascripts/inkpen/extensions/export_commands.js +271 -0
  26. data/app/assets/javascripts/inkpen/extensions/file_attachment.js +593 -0
  27. data/app/assets/javascripts/inkpen/extensions/inkpen_table/index.js +58 -0
  28. data/app/assets/javascripts/inkpen/extensions/inkpen_table/inkpen_table.js +638 -0
  29. data/app/assets/javascripts/inkpen/extensions/inkpen_table/inkpen_table_cell.js +100 -0
  30. data/app/assets/javascripts/inkpen/extensions/inkpen_table/inkpen_table_header.js +100 -0
  31. data/app/assets/javascripts/inkpen/extensions/inkpen_table/table_constants.js +152 -0
  32. data/app/assets/javascripts/inkpen/extensions/inkpen_table/table_helpers.js +254 -0
  33. data/app/assets/javascripts/inkpen/extensions/inkpen_table/table_menu.js +282 -0
  34. data/app/assets/javascripts/inkpen/extensions/preformatted.js +239 -0
  35. data/app/assets/javascripts/inkpen/extensions/section.js +281 -0
  36. data/app/assets/javascripts/inkpen/extensions/section_title.js +126 -0
  37. data/app/assets/javascripts/inkpen/extensions/slash_commands.js +439 -0
  38. data/app/assets/javascripts/inkpen/extensions/table_of_contents.js +474 -0
  39. data/app/assets/javascripts/inkpen/extensions/toggle_block.js +332 -0
  40. data/app/assets/javascripts/inkpen/index.js +87 -0
  41. data/app/assets/stylesheets/inkpen/advanced_table.css +514 -0
  42. data/app/assets/stylesheets/inkpen/animations.css +626 -0
  43. data/app/assets/stylesheets/inkpen/block_gutter.css +265 -0
  44. data/app/assets/stylesheets/inkpen/callout.css +359 -0
  45. data/app/assets/stylesheets/inkpen/columns.css +314 -0
  46. data/app/assets/stylesheets/inkpen/database.css +658 -0
  47. data/app/assets/stylesheets/inkpen/document_section.css +305 -0
  48. data/app/assets/stylesheets/inkpen/drag_drop.css +220 -0
  49. data/app/assets/stylesheets/inkpen/editor.css +652 -0
  50. data/app/assets/stylesheets/inkpen/embed.css +468 -0
  51. data/app/assets/stylesheets/inkpen/enhanced_image.css +453 -0
  52. data/app/assets/stylesheets/inkpen/export.css +499 -0
  53. data/app/assets/stylesheets/inkpen/file_attachment.css +347 -0
  54. data/app/assets/stylesheets/inkpen/footnotes.css +136 -0
  55. data/app/assets/stylesheets/inkpen/inkpen_table.css +608 -0
  56. data/app/assets/stylesheets/inkpen/preformatted.css +215 -0
  57. data/app/assets/stylesheets/inkpen/search_replace.css +58 -0
  58. data/app/assets/stylesheets/inkpen/section.css +236 -0
  59. data/app/assets/stylesheets/inkpen/slash_menu.css +252 -0
  60. data/app/assets/stylesheets/inkpen/sticky_toolbar.css +314 -0
  61. data/app/assets/stylesheets/inkpen/toc.css +386 -0
  62. data/app/assets/stylesheets/inkpen/toggle.css +260 -0
  63. data/app/helpers/inkpen/editor_helper.rb +114 -0
  64. data/app/views/inkpen/_editor.html.erb +139 -0
  65. data/config/importmap.rb +170 -0
  66. data/docs/.DS_Store +0 -0
  67. data/docs/CHANGELOG.md +571 -0
  68. data/docs/FEATURES.md +436 -0
  69. data/docs/ROADMAP.md +3029 -0
  70. data/docs/VISION.md +235 -0
  71. data/docs/extensions/INKPEN_TABLE.md +482 -0
  72. data/docs/thinking/CORRECTED_NO_VUE.md +756 -0
  73. data/docs/thinking/EXECUTIVE_SUMMARY.md +403 -0
  74. data/docs/thinking/INKPEN_CODE_SAMPLES.md +1479 -0
  75. data/docs/thinking/INKPEN_MASTER_GUIDE.md +891 -0
  76. data/docs/thinking/README_START_HERE.md +341 -0
  77. data/lib/inkpen/configuration.rb +175 -0
  78. data/lib/inkpen/editor.rb +204 -0
  79. data/lib/inkpen/engine.rb +32 -0
  80. data/lib/inkpen/extensions/base.rb +109 -0
  81. data/lib/inkpen/extensions/code_block_syntax.rb +177 -0
  82. data/lib/inkpen/extensions/document_section.rb +111 -0
  83. data/lib/inkpen/extensions/forced_document.rb +183 -0
  84. data/lib/inkpen/extensions/mention.rb +155 -0
  85. data/lib/inkpen/extensions/preformatted.rb +111 -0
  86. data/lib/inkpen/extensions/section.rb +139 -0
  87. data/lib/inkpen/extensions/slash_commands.rb +100 -0
  88. data/lib/inkpen/extensions/table.rb +182 -0
  89. data/lib/inkpen/extensions/task_list.rb +145 -0
  90. data/lib/inkpen/sticky_toolbar.rb +157 -0
  91. data/lib/inkpen/toolbar.rb +145 -0
  92. data/lib/inkpen/version.rb +5 -0
  93. data/lib/inkpen.rb +101 -0
  94. data/sig/inkpen.rbs +4 -0
  95. metadata +165 -0
@@ -0,0 +1,891 @@
1
+ # Inkpen: Complete RichText Editor Gem for Rails
2
+ ## Comprehensive Architecture, Strategy & Implementation Guide
3
+
4
+ ---
5
+
6
+ ## Table of Contents
7
+
8
+ 1. [Executive Summary](#executive-summary)
9
+ 2. [Architecture Overview](#architecture-overview)
10
+ 3. [Gem Structure & Setup](#gem-structure--setup)
11
+ 4. [Extension System](#extension-system)
12
+ 5. [Feature Sets](#feature-sets)
13
+ 6. [Integration Pattern](#integration-pattern)
14
+ 7. [Custom Blocks](#custom-blocks)
15
+ 8. [Implementation Steps](#implementation-steps)
16
+ 9. [Code Samples](#code-samples)
17
+ 10. [Testing Strategy](#testing-strategy)
18
+ 11. [Deployment & Versioning](#deployment--versioning)
19
+
20
+ ---
21
+
22
+ ## Executive Summary
23
+
24
+ **Inkpen** is a professional-grade **Rails gem** that wraps **TipTap** (modern rich-text editor) and provides a reusable solution for both **mademysite.com** (page builder) and **kuickr.co** (document collaboration).
25
+
26
+ ### What You Get
27
+
28
+ - **One gem, two products** - DRY editor implementation shared across apps
29
+ - **Feature sets** - Different editor configurations (page_builder, document, standard)
30
+ - **6 core extensions** - ForcedDocument, CodeBlockSyntax, TaskList, Table, Mention, SlashCommands
31
+ - **Custom blocks** - Hero sections, columns, CTAs for mademysite; Collaboration features for kuickr
32
+ - **Professional styling** - CSS framework with dark mode, responsive design, customizable tokens
33
+ - **Autosave & collaboration** - Built-in support for auto-save and real-time collaboration
34
+
35
+ ### Key Statistics
36
+
37
+ | Metric | Value |
38
+ |--------|-------|
39
+ | **Lines of Ruby** | ~2,600 (extension classes + helpers) |
40
+ | **Lines of JavaScript** | ~23,000 (editor + controllers + utilities) |
41
+ | **Lines of CSS** | ~12,000 (editor + toolbar + theme system) |
42
+ | **Extension Types** | 6 core + custom blocks |
43
+ | **Supported Languages** | 30+ (Ruby, Python, JS, SQL, Go, Rust, etc.) |
44
+ | **Feature Sets** | 3 (page_builder, document, standard) |
45
+ | **Customization Points** | 50+ CSS variables, 100+ config options |
46
+
47
+ ---
48
+
49
+ ## Architecture Overview
50
+
51
+ ### System Layers
52
+
53
+ ```
54
+ ┌─────────────────────────────────────────┐
55
+ │ Rails Application Layer │
56
+ │ (mademysite.com, kuickr.co) │
57
+ └────────┬────────────────────────────────┘
58
+
59
+ ┌────────┴──────────────────────────────────┐
60
+ │ Inkpen Gem Engine (Rails::Engine) │
61
+ │ - Helpers, Controllers, Assets │
62
+ │ - Feature Sets Configuration │
63
+ │ - Extension Loader │
64
+ └────────┬──────────────────────────────────┘
65
+
66
+ ┌────────┴──────────────────────────────────┐
67
+ │ Extension Configuration System (Ruby) │
68
+ │ - Base class │
69
+ │ - 6 Core Extensions │
70
+ │ - JSON Serialization (to_config) │
71
+ │ - Custom Block Registration │
72
+ └────────┬──────────────────────────────────┘
73
+
74
+ ┌────────┴──────────────────────────────────┐
75
+ │ JavaScript/TipTap Layer │
76
+ │ - Stimulus Controllers │
77
+ │ - TipTap Extensions │
78
+ │ - UI Components (toolbars, menus) │
79
+ │ - Real-time Collaboration │
80
+ └─────────────────────────────────────────┘
81
+ ```
82
+
83
+ ### Data Flow
84
+
85
+ ```
86
+ User opens editor in app
87
+
88
+ View helper: <%= tiptap_editor(@model, :field, features: :page_builder) %>
89
+
90
+ Rails renders partial with Stimulus controller
91
+
92
+ Stimulus controller calls /inkpen/extensions/page_builder.json
93
+
94
+ Rails controller builds extension config using Ruby classes
95
+
96
+ Extensions call .to_config() → converts to JSON-safe Hash
97
+
98
+ JSON sent to JavaScript
99
+
100
+ JavaScript ExtensionsLoader maps config to TipTap
101
+
102
+ TipTap editor initialized with all configured extensions
103
+
104
+ User can now create/edit content with all features
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Gem Structure & Setup
110
+
111
+ ### Directory Layout
112
+
113
+ ```
114
+ inkpen-gem/
115
+ ├── lib/
116
+ │ ├── inkpen.rb # Main gem file
117
+ │ ├── inkpen/
118
+ │ │ ├── version.rb # Version constant
119
+ │ │ ├── engine.rb # Rails::Engine setup
120
+ │ │ ├── configuration.rb # Gem configuration
121
+ │ │ ├── editor.rb # TiptapEditor class
122
+ │ │ ├── toolbar.rb # Toolbar config
123
+ │ │ └── extensions/
124
+ │ │ ├── base.rb # Base extension class
125
+ │ │ ├── forced_document.rb # Document structure
126
+ │ │ ├── code_block_syntax.rb # Syntax highlighting
127
+ │ │ ├── task_list.rb # Checklists
128
+ │ │ ├── table.rb # Data tables
129
+ │ │ ├── mention.rb # @mentions
130
+ │ │ └── slash_commands.rb # Command palette
131
+ │ │
132
+ │ └── generators/
133
+ │ └── install_generator.rb # rails generate inkpen:install
134
+
135
+ ├── app/
136
+ │ ├── controllers/
137
+ │ │ └── inkpen/
138
+ │ │ ├── extensions_controller.rb # Serves extension configs
139
+ │ │ └── base_controller.rb
140
+ │ │
141
+ │ ├── helpers/
142
+ │ │ └── inkpen/
143
+ │ │ └── editor_helper.rb # tiptap_editor helper
144
+ │ │
145
+ │ ├── views/
146
+ │ │ └── inkpen/
147
+ │ │ ├── _editor.html.erb # Main editor partial
148
+ │ │ └── _floating_menu.html.erb
149
+ │ │
150
+ │ ├── javascript/
151
+ │ │ ├── controllers/
152
+ │ │ │ ├── inkpen/
153
+ │ │ │ │ ├── editor_controller.js # Main Stimulus controller
154
+ │ │ │ │ ├── toolbar_controller.js # Toolbar Stimulus
155
+ │ │ │ │ └── sticky_toolbar_controller.js
156
+ │ │ │ │
157
+ │ │ ├── utils/
158
+ │ │ │ ├── extensions_loader.js # Extension loader
159
+ │ │ │ ├── syntax_highlighter.js
160
+ │ │ │ └── collaboration.js
161
+ │ │ │
162
+ │ │ ├── components/
163
+ │ │ │ ├── mention_list.js
164
+ │ │ │ ├── command_palette.js
165
+ │ │ │ ├── floating_toolbar.js
166
+ │ │ │ └── widget_modal.js
167
+ │ │ │
168
+ │ │ └── entrypoints/
169
+ │ │ └── inkpen.js # Main entrypoint
170
+ │ │
171
+ │ └── assets/
172
+ │ └── stylesheets/
173
+ │ ├── inkpen/
174
+ │ │ ├── editor.css # Core editor styles
175
+ │ │ ├── sticky_toolbar.css # Toolbar styles
176
+ │ │ ├── dark_mode.css
177
+ │ │ └── responsive.css
178
+ │ │
179
+ │ └── themes/
180
+ │ ├── github.css # Code highlight theme
181
+ │ ├── monokai.css
182
+ │ └── dracula.css
183
+
184
+ ├── spec/
185
+ │ ├── lib/
186
+ │ │ └── inkpen/
187
+ │ │ └── extensions/
188
+ │ │ ├── base_spec.rb
189
+ │ │ ├── code_block_syntax_spec.rb
190
+ │ │ └── slash_commands_spec.rb
191
+ │ │
192
+ │ └── dummy/ # Dummy Rails app for testing
193
+ │ ├── app/
194
+ │ ├── config/
195
+ │ └── db/
196
+
197
+ ├── inkpen.gemspec # Gem specification
198
+ ├── Rakefile
199
+ └── README.md
200
+ ```
201
+
202
+ ### Gem Dependencies
203
+
204
+ Reference: See `inkpen.gemspec` and `Gemfile`
205
+
206
+ Key dependencies:
207
+ - Rails >= 7.0
208
+ - JavaScript bundler (Importmap/Webpack/Esbuild)
209
+ - TipTap core packages
210
+ - Stimulus Rails
211
+ - Highlight.js (syntax highlighting)
212
+
213
+ ---
214
+
215
+ ## Extension System
216
+
217
+ ### Core Concept
218
+
219
+ **Extensions** are Ruby configuration classes that describe how to enhance the TipTap editor. Each extension:
220
+ 1. Inherits from `Base`
221
+ 2. Implements `name` and `to_config` methods
222
+ 3. Provides sensible defaults
223
+ 4. Serializes to JSON for JavaScript consumption
224
+
225
+ ### The 6 Core Extensions
226
+
227
+ #### 1. ForcedDocument
228
+ **Purpose**: Enforce a specific document structure (title + optional subtitle)
229
+ **Use Case**: Blog posts, articles, Medium-style documents
230
+ **Key Features**: Title protection, subtitle toggle, custom placeholders
231
+
232
+ Reference: See [Code Sample A1](#a1-forceddocument)
233
+
234
+ #### 2. CodeBlockSyntax
235
+ **Purpose**: Syntax highlighting with 30+ languages
236
+ **Use Case**: Developer tutorials, documentation, code snippets
237
+ **Key Features**: Language selector, copy button, line numbers, themes
238
+
239
+ Reference: See [Code Sample A2](#a2-codeblacksyntax)
240
+
241
+ #### 3. TaskList
242
+ **Purpose**: Interactive checkbox lists
243
+ **Use Case**: Todo posts, planning documents, checklists
244
+ **Key Features**: Nesting support, keyboard shortcuts, state persistence
245
+
246
+ Reference: See [Code Sample A3](#a3-tasklist)
247
+
248
+ #### 4. Table
249
+ **Purpose**: Full-featured data tables with ProseMirror
250
+ **Use Case**: Data comparison, pricing tables, specifications
251
+ **Key Features**: Resizable columns, cell merge, headers, backgrounds
252
+
253
+ Reference: See [Code Sample A4](#a4-table)
254
+
255
+ #### 5. Mention
256
+ **Purpose**: @mention users or entities
257
+ **Use Case**: Collaboration, notifications, tagging
258
+ **Key Features**: Dynamic search, static items option, custom trigger
259
+
260
+ Reference: See [Code Sample A5](#a5-mention)
261
+
262
+ #### 6. SlashCommands
263
+ **Purpose**: Notion-style command palette for rapid block insertion
264
+ **Use Case**: Power users, content creators, documentation
265
+ **Key Features**: 13 built-in commands, grouping, filtering, icons
266
+
267
+ Reference: See [Code Sample A6](#a6-slashcommands)
268
+
269
+ ### Extension Configuration Hierarchy
270
+
271
+ ```
272
+ Base
273
+ ├── Attributes
274
+ │ ├── name (Symbol)
275
+ │ ├── enabled (Boolean)
276
+ │ └── options (Hash)
277
+
278
+ ├── Methods
279
+ │ ├── initialize(**options)
280
+ │ ├── name
281
+ │ ├── enabled?
282
+ │ ├── to_config
283
+ │ ├── to_h
284
+ │ └── to_json
285
+
286
+ └── Subclasses
287
+ ├── ForcedDocument
288
+ ├── CodeBlockSyntax
289
+ ├── TaskList
290
+ ├── Table
291
+ ├── Mention
292
+ └── SlashCommands
293
+ ```
294
+
295
+ ---
296
+
297
+ ## Feature Sets
298
+
299
+ ### Concept
300
+
301
+ **Feature Sets** are predefined configurations that determine which editor features are available in different contexts.
302
+
303
+ ### Three Predefined Sets
304
+
305
+ #### 1. Page Builder (mademysite.com)
306
+ **Target**: Landing pages, custom site builder
307
+ **Blocks Available**:
308
+ - Text formatting (bold, italic, underline)
309
+ - Headings (1-6)
310
+ - Lists (bullet, ordered, task)
311
+ - Media (image, video, embed)
312
+ - Layout (columns, hero, testimonials)
313
+ - Advanced (table, code block, blockquote)
314
+ **Extensions**: ForcedDocument, CodeBlockSyntax, TaskList, Table, SlashCommands, Custom layout blocks
315
+
316
+ Reference: See [Code Sample B1](#b1-page-builder-feature-set)
317
+
318
+ #### 2. Document (kuickr.co)
319
+ **Target**: Collaboration documents, internal wikis
320
+ **Blocks Available**:
321
+ - Text (bold, italic, code)
322
+ - Headings (1-3, minimal)
323
+ - Lists (bullet, ordered)
324
+ - Code (syntax highlighting)
325
+ - Collaboration (comments, suggestions)
326
+ - Advanced (table, TOC)
327
+ **Extensions**: CodeBlockSyntax, Mention, TaskList, Table, SlashCommands
328
+
329
+ Reference: See [Code Sample B2](#b2-document-feature-set)
330
+
331
+ #### 3. Standard
332
+ **Target**: Blog posts, articles, general content
333
+ **Blocks Available**:
334
+ - Text (bold, italic, underline)
335
+ - Headings (1-3)
336
+ - Lists (bullet, ordered)
337
+ - Media (image, link)
338
+ - Advanced (blockquote, code block)
339
+ **Extensions**: ForcedDocument, CodeBlockSyntax, TaskList, SlashCommands
340
+
341
+ Reference: See [Code Sample B3](#b3-standard-feature-set)
342
+
343
+ ### Feature Set Architecture
344
+
345
+ ```
346
+ TiptapEditor.extensions_for(:page_builder)
347
+
348
+ Looks up FEATURE_SETS[:page_builder]
349
+
350
+ Maps to: { text: [...], headings: [...], layout: [...] }
351
+
352
+ build_extensions(features)
353
+
354
+ Instantiates extension classes with feature-specific config
355
+
356
+ Returns: [ForcedDocument, CodeBlockSyntax, Table, SlashCommands, ...]
357
+ ```
358
+
359
+ ---
360
+
361
+ ## Integration Pattern
362
+
363
+ ### Step 1: Rails Backend
364
+
365
+ The Rails application serves extension configurations as JSON.
366
+
367
+ **Responsibilities**:
368
+ - Determine which feature set to load
369
+ - Instantiate extension classes
370
+ - Serialize to JSON
371
+ - Return to JavaScript
372
+
373
+ Reference: See [Code Sample C1](#c1-rails-controller)
374
+
375
+ ### Step 2: View Helper
376
+
377
+ The view helper provides a clean API for developers.
378
+
379
+ **Usage**:
380
+ ```
381
+ <%= tiptap_editor(@model, :field, features: :page_builder) %>
382
+ ```
383
+
384
+ **Responsibilities**:
385
+ - Render editor partial
386
+ - Pass configuration to Stimulus
387
+ - Handle form integration
388
+
389
+ Reference: See [Code Sample C2](#c2-view-helper)
390
+
391
+ ### Step 3: Stimulus Controller
392
+
393
+ The Stimulus controller bridges Rails and JavaScript.
394
+
395
+ **Responsibilities**:
396
+ - Load extension config from server
397
+ - Initialize TipTap editor
398
+ - Handle autosave
399
+ - Manage editor lifecycle
400
+
401
+ Reference: See [Code Sample C3](#c3-stimulus-controller)
402
+
403
+ ### Step 4: JavaScript Extension Loader
404
+
405
+ The ExtensionsLoader maps Ruby configs to TipTap extensions.
406
+
407
+ **Responsibilities**:
408
+ - Parse JSON config
409
+ - Load appropriate TipTap packages
410
+ - Configure each extension
411
+ - Return ready-to-use extensions array
412
+
413
+ Reference: See [Code Sample C4](#c4-extensions-loader)
414
+
415
+ ### Step 5: TipTap Initialization
416
+
417
+ TipTap editor is finally initialized with all extensions.
418
+
419
+ **Responsibilities**:
420
+ - Create editor instance
421
+ - Attach to DOM element
422
+ - Wire up event handlers
423
+ - Enable collaboration features
424
+
425
+ Reference: See [Code Sample C5](#c5-tiptap-initialization)
426
+
427
+ ---
428
+
429
+ ## Custom Blocks
430
+
431
+ ### Concept
432
+
433
+ Custom blocks are domain-specific components beyond standard TipTap extensions.
434
+
435
+ ### mademysite.com Custom Blocks
436
+
437
+ #### Hero Section
438
+ **Purpose**: Eye-catching homepage header
439
+ **Properties**: Background image, headline, subtitle, CTA button
440
+ **Editor UI**: Modal for uploading image, setting text
441
+
442
+ #### Columns Layout
443
+ **Purpose**: Multi-column content organization
444
+ **Properties**: Number of columns (2-4), column widths, gaps
445
+ **Editor UI**: Drag-to-resize column borders
446
+
447
+ #### Callout/Alert
448
+ **Purpose**: Highlighted information boxes
449
+ **Properties**: Type (info, warning, success, error), text content
450
+ **Editor UI**: Type selector dropdown
451
+
452
+ #### Testimonial
453
+ **Purpose**: Customer quotes with attribution
454
+ **Properties**: Quote text, author name, author image, company
455
+ **Editor UI**: Form fields for each property
456
+
457
+ ### kuickr.co Custom Blocks
458
+
459
+ #### Comment Thread
460
+ **Purpose**: Inline comments and discussions
461
+ **Properties**: User, timestamp, text, replies
462
+ **Editor UI**: Comment composer, reply thread
463
+
464
+ #### Suggestion/Tracked Changes
465
+ **Purpose**: Edit suggestions for collaboration
466
+ **Properties**: Original text, suggested text, author, status
467
+ **Editor UI**: Accept/reject buttons
468
+
469
+ #### Document Outline/TOC
470
+ **Purpose**: Auto-generated table of contents
471
+ **Properties**: Auto-populated from headings
472
+ **Editor UI**: Read-only, clickable navigation
473
+
474
+ ### Custom Block Pattern
475
+
476
+ Each custom block implements:
477
+ 1. **Server-side (Ruby)** - Configuration class inheriting from `Inkpen::Extensions::Base`
478
+ 2. **JavaScript** - TipTap extension with editor plugin
479
+ 3. **UI Component** - Editor toolbar or modal for configuration
480
+ 4. **Styling** - CSS for rendering in editor and content
481
+
482
+ Reference: See [Code Sample D1](#d1-custom-block-hero)
483
+
484
+ ---
485
+
486
+ ## Implementation Steps
487
+
488
+ ### Phase 1: Gem Foundation
489
+ 1. Create gem structure with `bundle gem inkpen`
490
+ 2. Setup Rails::Engine
491
+ 3. Create configuration class
492
+ 4. Setup generators
493
+
494
+ Reference: See [Code Sample E1](#e1-gem-setup)
495
+
496
+ ### Phase 2: Extension Classes
497
+ 1. Implement Base class
498
+ 2. Create 6 core extension classes
499
+ 3. Add validation and defaults
500
+ 4. Write unit tests
501
+
502
+ Reference: See [Code Samples A1-A6](#code-samples)
503
+
504
+ ### Phase 3: Backend Integration
505
+ 1. Create ExtensionsController
506
+ 2. Implement EditorHelper
507
+ 3. Create TiptapEditor class with feature sets
508
+ 4. Setup routes
509
+
510
+ Reference: See [Code Sample E2](#e2-backend-setup)
511
+
512
+ ### Phase 4: Frontend Integration
513
+ 1. Create Stimulus controller
514
+ 2. Implement ExtensionsLoader
515
+ 3. Setup TipTap initialization
516
+ 4. Wire event handlers
517
+
518
+ Reference: See [Code Sample E3](#e3-frontend-setup)
519
+
520
+ ### Phase 5: Styling
521
+ 1. Setup CSS variables
522
+ 2. Create editor.css
523
+ 3. Create sticky_toolbar.css
524
+ 4. Add dark mode support
525
+
526
+ Reference: See [Code Sample E4](#e4-styling-setup)
527
+
528
+ ### Phase 6: Testing
529
+ 1. Write unit tests for extensions
530
+ 2. Write integration tests
531
+ 3. Test in both apps
532
+ 4. Test custom blocks
533
+
534
+ Reference: See [Code Sample E5](#e5-testing-setup)
535
+
536
+ ### Phase 7: Deployment
537
+ 1. Publish gem to internal server or GitHub
538
+ 2. Add as dependency in both apps
539
+ 3. Generate initial setup
540
+ 4. Test end-to-end
541
+
542
+ Reference: See [Code Sample E6](#e6-deployment)
543
+
544
+ ---
545
+
546
+ ## Testing Strategy
547
+
548
+ ### Unit Tests
549
+
550
+ Test extension classes in isolation.
551
+
552
+ **Targets**:
553
+ - Configuration merging
554
+ - Default options
555
+ - JSON serialization
556
+ - Validation
557
+
558
+ Reference: See [Code Sample F1](#f1-unit-tests)
559
+
560
+ ### Integration Tests
561
+
562
+ Test extension loading and initialization.
563
+
564
+ **Targets**:
565
+ - Feature set loading
566
+ - Extension controller response
567
+ - Stimulus controller initialization
568
+ - TipTap editor creation
569
+
570
+ Reference: See [Code Sample F2](#f2-integration-tests)
571
+
572
+ ### Browser Tests
573
+
574
+ Test editor functionality in real browser.
575
+
576
+ **Targets**:
577
+ - Typing and formatting
578
+ - Toolbar interaction
579
+ - Floating menu
580
+ - Slash commands
581
+ - Autosave
582
+
583
+ Reference: See [Code Sample F3](#f3-browser-tests)
584
+
585
+ ---
586
+
587
+ ## Deployment & Versioning
588
+
589
+ ### Version Strategy
590
+
591
+ ```
592
+ MAJOR.MINOR.PATCH
593
+
594
+ MAJOR - Breaking changes (extension API change)
595
+ MINOR - New features (new extension, new blocks)
596
+ PATCH - Bug fixes
597
+ ```
598
+
599
+ ### Publishing to Internal Server
600
+
601
+ Option 1: Private gem server (Gemfury, Artifactory)
602
+ Option 2: GitHub Private Repository
603
+ Option 3: Internal git repository with SSH key
604
+
605
+ ### Version Pinning in Applications
606
+
607
+ ```ruby
608
+ # Gemfile (mademysite.com)
609
+ gem 'inkpen', '~> 1.2.0' # Allow patch updates, pin minor
610
+
611
+ # Gemfile (kuickr.co)
612
+ gem 'inkpen', '~> 1.1.0' # Different version if different features
613
+ ```
614
+
615
+ ### Changelog Maintenance
616
+
617
+ Reference: See [Code Sample G1](#g1-changelog)
618
+
619
+ ---
620
+
621
+ ## Code Samples
622
+
623
+ ### A1: ForcedDocument
624
+ Reference: `lib/inkpen/extensions/forced_document.rb`
625
+
626
+ Implements document structure enforcement - title is required, subtitle is optional.
627
+
628
+ ### A2: CodeBlockSyntax
629
+ Reference: `lib/inkpen/extensions/code_block_syntax.rb`
630
+
631
+ Implements syntax highlighting with 30+ languages and customizable themes.
632
+
633
+ ### A3: TaskList
634
+ Reference: `lib/inkpen/extensions/task_list.rb`
635
+
636
+ Implements interactive checkboxes with nesting and keyboard shortcuts.
637
+
638
+ ### A4: Table
639
+ Reference: `lib/inkpen/extensions/table.rb`
640
+
641
+ Implements ProseMirror tables with resizing, merging, and styling.
642
+
643
+ ### A5: Mention
644
+ Reference: `lib/inkpen/extensions/mention.rb`
645
+
646
+ Implements @mentions with optional search API integration.
647
+
648
+ ### A6: SlashCommands
649
+ Reference: `lib/inkpen/extensions/slash_commands.rb`
650
+
651
+ Implements Notion-style command palette with 13 built-in commands.
652
+
653
+ ---
654
+
655
+ ### B1: Page Builder Feature Set
656
+
657
+ ```ruby
658
+ # Reference: lib/inkpen/editor.rb - FEATURE_SETS[:page_builder]
659
+ ```
660
+
661
+ Defines all blocks and extensions available for page builder (mademysite.com).
662
+
663
+ ### B2: Document Feature Set
664
+
665
+ ```ruby
666
+ # Reference: lib/inkpen/editor.rb - FEATURE_SETS[:document]
667
+ ```
668
+
669
+ Defines all blocks and extensions available for documents (kuickr.co).
670
+
671
+ ### B3: Standard Feature Set
672
+
673
+ ```ruby
674
+ # Reference: lib/inkpen/editor.rb - FEATURE_SETS[:standard]
675
+ ```
676
+
677
+ Defines all blocks and extensions for standard blog posts.
678
+
679
+ ---
680
+
681
+ ### C1: Rails Controller
682
+
683
+ ```ruby
684
+ # Reference: app/controllers/inkpen/extensions_controller.rb
685
+ ```
686
+
687
+ Serves extension JSON config based on feature set parameter.
688
+
689
+ ### C2: View Helper
690
+
691
+ ```ruby
692
+ # Reference: app/helpers/inkpen/editor_helper.rb
693
+ ```
694
+
695
+ Provides clean API for rendering editor in views.
696
+
697
+ ### C3: Stimulus Controller
698
+
699
+ ```ruby
700
+ # Reference: app/javascript/controllers/inkpen/editor_controller.js
701
+ ```
702
+
703
+ Main Stimulus controller managing editor lifecycle.
704
+
705
+ ### C4: Extensions Loader
706
+
707
+ ```javascript
708
+ // Reference: app/javascript/utils/extensions_loader.js
709
+ ```
710
+
711
+ Loads and configures all TipTap extensions based on JSON config.
712
+
713
+ ### C5: TipTap Initialization
714
+
715
+ ```javascript
716
+ // Reference: app/javascript/utils/tiptap_init.js
717
+ ```
718
+
719
+ Creates TipTap editor instance with extensions.
720
+
721
+ ---
722
+
723
+ ### D1: Custom Block - Hero
724
+
725
+ ```ruby
726
+ # Reference: Custom block implementation pattern
727
+ ```
728
+
729
+ Example of how to create a custom Hero block for page builder.
730
+
731
+ ---
732
+
733
+ ### E1: Gem Setup
734
+
735
+ ```ruby
736
+ # Reference: lib/inkpen/engine.rb, lib/inkpen.rb, inkpen.gemspec
737
+ ```
738
+
739
+ Rails::Engine setup, module structure, and gem configuration.
740
+
741
+ ### E2: Backend Setup
742
+
743
+ ```ruby
744
+ # Reference: app/controllers/inkpen/extensions_controller.rb, lib/inkpen/editor.rb, lib/inkpen/tiptap_editor.rb
745
+ ```
746
+
747
+ Controller, helper, and feature set configuration.
748
+
749
+ ### E3: Frontend Setup
750
+
751
+ ```javascript
752
+ // Reference: app/javascript/controllers/inkpen/editor_controller.js, app/javascript/utils/extensions_loader.js
753
+ ```
754
+
755
+ Stimulus controller and JavaScript extension loader setup.
756
+
757
+ ### E4: Styling Setup
758
+
759
+ ```css
760
+ # Reference: app/assets/stylesheets/inkpen/editor.css, sticky_toolbar.css
761
+ ```
762
+
763
+ CSS framework with variables, dark mode, and responsive design.
764
+
765
+ ### E5: Testing Setup
766
+
767
+ ```ruby
768
+ # Reference: spec/lib/inkpen/extensions/*_spec.rb
769
+ ```
770
+
771
+ RSpec tests for extensions and integration.
772
+
773
+ ### E6: Deployment
774
+
775
+ ```
776
+ # Reference: Gem publishing process and version management
777
+ ```
778
+
779
+ How to publish gem and integrate into applications.
780
+
781
+ ---
782
+
783
+ ### F1: Unit Tests
784
+
785
+ ```ruby
786
+ # Example test structure
787
+ RSpec.describe Inkpen::Extensions::CodeBlockSyntax do
788
+ describe "#to_config" do
789
+ it "converts options to JSON-safe hash"
790
+ it "includes all language options"
791
+ it "respects default language setting"
792
+ end
793
+ end
794
+ ```
795
+
796
+ ### F2: Integration Tests
797
+
798
+ ```ruby
799
+ # Example test structure
800
+ RSpec.describe "Editor Extension Loading" do
801
+ it "loads page_builder feature set"
802
+ it "includes all expected extensions"
803
+ it "serializes to valid JSON"
804
+ end
805
+ ```
806
+
807
+ ### F3: Browser Tests
808
+
809
+ ```javascript
810
+ // Example test structure using Cypress/Playwright
811
+ describe("Editor Functionality", () => {
812
+ it("allows typing in editor")
813
+ it("shows floating menu on text selection")
814
+ it("executes slash commands")
815
+ it("autosaves content")
816
+ })
817
+ ```
818
+
819
+ ---
820
+
821
+ ### G1: Changelog
822
+
823
+ ```markdown
824
+ # CHANGELOG.md format
825
+
826
+ ## [1.2.0] - 2024-01-15
827
+ ### Added
828
+ - ForcedDocument extension
829
+ - CodeBlockSyntax with 30+ languages
830
+ - Support for custom blocks
831
+
832
+ ### Changed
833
+ - Refactored extension loading system
834
+
835
+ ### Fixed
836
+ - Fixed dark mode CSS variable scoping
837
+ ```
838
+
839
+ ---
840
+
841
+ ## Summary: What You Now Have
842
+
843
+ | Component | Status | Files |
844
+ |-----------|--------|-------|
845
+ | **Gem Foundation** | Complete | engine.rb, version.rb, gemspec |
846
+ | **Extension Classes** | Complete | 6 extension classes + base |
847
+ | **Feature Sets** | Complete | Defined in editor.rb |
848
+ | **Backend Integration** | Defined | Controller, Helper, TiptapEditor |
849
+ | **Frontend Integration** | Defined | Stimulus, ExtensionsLoader |
850
+ | **Styling System** | Complete | editor.css, sticky_toolbar.css |
851
+ | **Testing Strategy** | Defined | RSpec + Playwright patterns |
852
+ | **Documentation** | Complete | This document |
853
+
854
+ ---
855
+
856
+ ## Next Actions
857
+
858
+ 1. **Review this document** - Understand the full architecture
859
+ 2. **Examine your files** - See what's already implemented
860
+ 3. **Follow implementation steps** - Phase 1 through Phase 7
861
+ 4. **Write tests** - As you implement each phase
862
+ 5. **Test in both apps** - mademysite.com and kuickr.co
863
+ 6. **Iterate on UX** - Based on real usage
864
+
865
+ ---
866
+
867
+ ## Key Files Reference Map
868
+
869
+ | Purpose | File | Type |
870
+ |---------|------|------|
871
+ | Gem entry point | lib/inkpen.rb | Ruby |
872
+ | Engine setup | lib/inkpen/engine.rb | Ruby |
873
+ | Configuration | lib/inkpen/configuration.rb | Ruby |
874
+ | Base extension | lib/inkpen/extensions/base.rb | Ruby |
875
+ | ForcedDocument | lib/inkpen/extensions/forced_document.rb | Ruby |
876
+ | CodeBlockSyntax | lib/inkpen/extensions/code_block_syntax.rb | Ruby |
877
+ | TaskList | lib/inkpen/extensions/task_list.rb | Ruby |
878
+ | Table | lib/inkpen/extensions/table.rb | Ruby |
879
+ | Mention | lib/inkpen/extensions/mention.rb | Ruby |
880
+ | SlashCommands | lib/inkpen/extensions/slash_commands.rb | Ruby |
881
+ | TiptapEditor | lib/inkpen/editor.rb | Ruby |
882
+ | Controller | app/controllers/inkpen/extensions_controller.rb | Ruby |
883
+ | Helper | app/helpers/inkpen/editor_helper.rb | Ruby |
884
+ | Stimulus Controller | app/javascript/controllers/inkpen/editor_controller.js | JavaScript |
885
+ | ExtensionsLoader | app/javascript/utils/extensions_loader.js | JavaScript |
886
+ | Editor CSS | app/assets/stylesheets/inkpen/editor.css | CSS |
887
+ | Toolbar CSS | app/assets/stylesheets/inkpen/sticky_toolbar.css | CSS |
888
+
889
+ ---
890
+
891
+ **This document is your complete reference for Inkpen gem architecture, implementation, and deployment.**