Skip to content

Conversation

@abdosaeedelhassan
Copy link

  1. Shortcodes Feature (New)
    Added ->shortcodes([...]) method to define shortcode array
    Added ->shortcodesLabel('Label') for toolbar button text
    Shortcodes appear as visual tags (purple gradient badges)
    Converts {code} or {{ code }} → visual tag → {{ code }} on save
  2. Inline Plugin Registration
    Shortcodes plugin registered inline in setup callback (not external file)
    Fixes timing issue where external plugins can't access TinyMCE init config
  3. Performance Optimizations
    Changed default provider to vendor (local files instead of CDN)
    CSS injection via content_style instead of JS DOM manipulation
  4. Shortcode Format Support
    Regex matches both single {code} and double {{ code }} braces
    Backwards compatible with existing templates
  5. Configuration
    Profiles remain generic (default, simple, minimal, full)
    Project-specific profiles should go in published config
    Usage:
TinyEditor::make('body')
    ->profile('notification')
    ->shortcodes([
        ['text' => 'Student name', 'value' => 'student_name'],
    ])
    ->shortcodesLabel(__('Shortcodes'))

abdosaeedelhassan and others added 10 commits January 7, 2026 06:36
- Added shortcodes() method to accept array of shortcodes
- Added getShortcodesJson() method to serialize shortcodes for JS
- Modified getToolbar() to prepend shortcodes button when shortcodes exist
- Modified getExternalPlugins() to include shortcodes plugin
- Added shortcodes.js TinyMCE plugin that reads from global variable
- Updated blade view to pass shortcodes JSON to JS component
- Updated tinymce.js to store shortcodes in window.tinyMceShortcodes
- Added publish rule for shortcodes.js

Usage: TinyEditor::make('body')->shortcodes([
    ['text' => 'Label', 'value' => 'shortcode_name'],
])

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
The setup function was causing state corruption by duplicating the
state sync logic that's already handled by Alpine.js entangle in
tinymce.js. Removed the redundant callback to prevent conflicts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Removed trailing comma after the last property in x-data object
to prevent JavaScript syntax error.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…x error

The x-init with semicolon-separated statements was causing
'Unexpected token ;' errors in Livewire/Alpine evaluation.
Simplified the template by removing the unnecessary wrapper div.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Changed from {!! $getShortcodesJson() !!} to @js($getShortcodes())
to properly escape double quotes for use within HTML attributes.
The raw JSON was breaking the x-data attribute because double quotes
in the JSON content terminated the attribute prematurely.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Changed shortcodes.js to use editor.getParam() instead of editor.options.get()
- This allows reading config values without prior registration
- Fixes timing issue where plugin loaded before setup callback ran
- Fixed image_class_list warning by conditionally rendering

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
External plugins cannot access TinyMCE init config at load time,
so the shortcodes plugin is now registered inline in the setup
callback where it has direct access to the shortcodes array
and label from the Alpine.js component scope.

- Removed external shortcodes.js loading from getExternalPlugins()
- Added inline shortcodes plugin registration in tinymce.js setup
- Removed unused shortcodes_data and shortcodes_label from init config
- Cleaned up debug console.log

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Switch default provider from 'cloud' to 'vendor' (local files faster)
- Add 'notification' profile with minimal plugins for faster loading
- Use content_style for shortcodes CSS instead of JS injection
- Removed editor.on('init') CSS injection callback

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Updated BeforeSetContent regex to match {code} and {{ code }} formats
- Removed notification profile from default config (project-specific)
- Keep plugin config generic for reusability

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant