/** * GitHub Code Viewer Block Variations * Provides pre-configured block patterns for common use cases */ (function(blocks, domReady) { 'use strict'; domReady(function() { // Register block variations blocks.registerBlockVariation('maple-code-blocks/code-block', { name: 'react-component', title: 'Maple: React Component', description: 'Display a React component from GitHub', icon: 'editor-code', attributes: { repository: 'facebook/react', theme: 'dark', height: '500px', showLineNumbers: true, initialFile: 'packages/react/src/React.js' }, scope: ['inserter'] }); blocks.registerBlockVariation('maple-code-blocks/code-block', { name: 'documentation-viewer', title: 'Maple: Documentation Viewer', description: 'Display README or documentation files', icon: 'media-document', attributes: { repository: '', theme: 'light', height: '400px', showLineNumbers: false, initialFile: 'README.md' }, scope: ['inserter'] }); blocks.registerBlockVariation('maple-code-blocks/code-block', { name: 'full-repository', title: 'Maple: Full Repository Browser', description: 'Browse entire repository with file tree', icon: 'category', attributes: { repository: '', theme: 'dark', height: '700px', showLineNumbers: true, initialFile: '' }, scope: ['inserter'] }); blocks.registerBlockVariation('maple-code-blocks/code-block', { name: 'code-snippet', title: 'Maple: Code Snippet', description: 'Display a specific code file', icon: 'editor-code', attributes: { repository: '', theme: 'monokai', height: '300px', showLineNumbers: true, initialFile: '' }, scope: ['inserter'] }); blocks.registerBlockVariation('maple-code-blocks/code-block', { name: 'tutorial-code', title: 'Maple: Tutorial Code', description: 'Perfect for coding tutorials and education', icon: 'welcome-learn-more', attributes: { repository: '', theme: 'solarized', height: '450px', showLineNumbers: true, title: 'Example Code' }, scope: ['inserter'] }); // Register block styles (additional styling options) blocks.registerBlockStyle('maple-code-blocks/code-block', { name: 'default', label: 'Default', isDefault: true }); blocks.registerBlockStyle('maple-code-blocks/code-block', { name: 'minimal', label: 'Minimal', className: 'is-style-minimal' }); blocks.registerBlockStyle('maple-code-blocks/code-block', { name: 'rounded', label: 'Rounded', className: 'is-style-rounded' }); blocks.registerBlockStyle('maple-code-blocks/code-block', { name: 'shadowed', label: 'Shadowed', className: 'is-style-shadowed' }); // Register block patterns for complete layouts if (wp.blockEditor && wp.blockEditor.registerBlockPattern) { // Code Comparison Pattern wp.blockEditor.registerBlockPattern('maple-code-blocks/code-comparison', { title: 'Maple: Code Comparison', description: 'Compare code from two different repositories', categories: ['maple-code-blocks'], content: `
Here's an example of how to implement this feature:
Now let's add some advanced functionality:
This library provides a simple interface for working with the API.
npm install example-library
A brief description of your amazing project