Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions ckeditor5_plugins/bootstrapAccordion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# CKEditor 5 Plugin: Bootstrap Accordion

## Model
```xml
<bootstrapAccordion
bootstrapAccordionId="..."
bootstrapAccordionStyle="regular|flush"
bootstrapAccordionItemsStayOpen="false|true">
<bootstrapAccordionItem>
<bootstrapAccordionHeader>
<bootstrapAccordionButton
bootstrapAccordionButtonCollapsed="true|false">...</bootstrapAccordionButton>
</bootstrapAccordionHeader>
<bootstrapAccordionCollapse bootstrapAccordionCollapseShow="false|true">
<bootstrapAccordionBody>
...
</bootstrapAccordionBody>
</bootstrapAccordionCollapse>
</bootstrapAccordionItem>
<bootstrapAccordionItem>
<bootstrapAccordionHeader>
<bootstrapAccordionButton
bootstrapAccordionButtonCollapsed="true|false">...</bootstrapAccordionButton>
</bootstrapAccordionHeader>
<bootstrapAccordionCollapse bootstrapAccordionCollapseShow="false|true">
<bootstrapAccordionBody>
...
</bootstrapAccordionBody>
</bootstrapAccordionCollapse>
</bootstrapAccordionItem>
...
</bootstrapAccordion>
```

## HTML
```html
<div
class="accordion accordion-flush? accordion-items-stay-open?"
data-accordion-id="...">
<div class="accordion-item">
<div class="accordion-header">
<a class="accordion-button collapsed?" href="#">...</a>
</div>
<div class="accordion-collapse collapse show?">
<div class="accordion-body">
...
</div>
</div>
</div>
<div class="accordion-item">
<div class="accordion-header">
<a class="accordion-button collapsed?" href="#">...</a>
</div>
<div class="accordion-collapse collapse show?">
<div class="accordion-body">
...
</div>
</div>
</div>
...
</div>
```
31 changes: 31 additions & 0 deletions ckeditor5_plugins/bootstrapAccordion/src/augmentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { ClipboardPipeline } from '@ckeditor/ckeditor5-clipboard';
import type { DataFilter } from '@ckeditor/ckeditor5-html-support';
import type { BootstrapAccordionConfig, ItemsStayOpen, ItemsStayOpenAttributeDefinition } from './bootstrapaccordionconfig';
import type BootstrapAccordionCollapseAllCommand from './commands/bootstrapaccordioncollapseallcommand';
import type BootstrapAccordionEvents from './bootstrapaccordionevents';
import type BootstrapAccordionFirstItemOpenCommand from './commands/bootstrapaccordionfirstitemopencommand';
import type BootstrapAccordionOpenAllCommand from './commands/bootstrapaccordionopenallcommand';
import type InsertBootstrapAccordionCommand from './commands/insertbootstrapaccordioncommand';
import type InsertBootstrapAccordionItemCommand from './commands/insertbootstrapaccordionitemcommand';
import type ModifyBootstrapAccordionCommand from './commands/modifybootstrapaccordioncommand';
import type RemoveBootstrapAccordionItemCommand from './commands/removebootstrapaccordionitemcommand';

declare module '@ckeditor/ckeditor5-core' {
interface EditorConfig {
bootstrapAccordion: BootstrapAccordionConfig;
}
interface CommandsMap {
bootstrapAccordionCollapseAll: BootstrapAccordionCollapseAllCommand;
bootstrapAccordionFirstItemOpen: BootstrapAccordionFirstItemOpenCommand;
bootstrapAccordionItemsStayOpen: ModifyBootstrapAccordionCommand<ItemsStayOpen, ItemsStayOpenAttributeDefinition>;
bootstrapAccordionOpenAll: BootstrapAccordionOpenAllCommand;
insertBootstrapAccordion: InsertBootstrapAccordionCommand;
insertBootstrapAccordionItem: InsertBootstrapAccordionItemCommand;
removeBootstrapAccordionItem: RemoveBootstrapAccordionItemCommand;
}
interface PluginsMap {
[BootstrapAccordionEvents.pluginName]: BootstrapAccordionEvents;
[ClipboardPipeline.pluginName]: ClipboardPipeline;
[DataFilter.pluginName]: DataFilter;
}
}
32 changes: 32 additions & 0 deletions ckeditor5_plugins/bootstrapAccordion/src/bootstrapaccordion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { PluginInterface } from '@ckeditor/ckeditor5-core/src/plugin';
import { Plugin } from 'ckeditor5/src/core';
import BootstrapAccordionEditing from './bootstrapaccordionediting';
import BootstrapAccordionEvents from './bootstrapaccordionevents';
import BootstrapAccordionKeyboard from './bootstrapaccordionkeyboard';
import BootstrapAccordionUI from './bootstrapaccordionui';

/**
* Defines the base Bootstrap Accordion plugin.
*/
export default class BootstrapAccordion extends Plugin implements PluginInterface {

/**
* The plugin's name in the PluginCollection.
*/
static get pluginName(): 'BootstrapAccordion' {
return 'BootstrapAccordion' as const;
}

/**
* The plugin's dependencies.
*/
static get requires() {
return [
BootstrapAccordionEditing,
BootstrapAccordionEvents,
BootstrapAccordionKeyboard,
BootstrapAccordionUI
] as const;
}

}
134 changes: 134 additions & 0 deletions ckeditor5_plugins/bootstrapAccordion/src/bootstrapaccordionconfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/**
* @file Contains configuration for Bootstrap Accordion.
*/

import type { ToolbarConfigItem } from '@ckeditor/ckeditor5-core';
import type { ModelAttributeDefinition, SelectableOption } from './bootstrapaccordiontypes';

/**
* The options available in `editor.config.get('bootstrapAccordion')`.
*/
export interface BootstrapAccordionConfig {
toolbarItems: ToolbarConfigItem[];
};

/**
* The allowed model attributes for an accordion.
*/
export type AccordionModelAttribute = 'bootstrapAccordionId' | 'bootstrapAccordionStyle' | 'bootstrapAccordionItemsStayOpen';

/**
* The allowed model attributes for an accordion header.
*/
export type AccordionButtonModelAttribute = 'bootstrapAccordionButtonCollapsed';

/**
* The allowed model attributes for an accordion collapse.
*/
export type AccordionCollapseModelAttribute = 'bootstrapAccordionCollapseShow';

/**
* Defines the allowed values for the `bootstrapAccordionStyle` attribute.
*/
export type Style = 'regular' | 'flush';

/**
* Defines the attribute definition for the `bootstrapAccordionStyle`
* attribute.
*/
export type StyleAttributeDefinition = ModelAttributeDefinition<Style, 'bootstrapAccordionStyle'>;

/**
* Defines the attribute value to class name conversion for the
* `bootstrapAccordionStyle` attribute.
*/
export const styleOptions: { [key in Style]: SelectableOption; } = {
regular: {
label: 'Regular'
},
flush: {
label: 'Flush',
className: 'accordion-flush'
}
};

/**
* Defines the default value for the `bootstrapAccordionStyle` attribute.
*/
export const styleDefault: Style = 'regular';

/**
* Defines the allowed values for the `bootstrapAccordionItemsStayOpen`
* attribute.
*/
export type ItemsStayOpen = 'true' | 'false';

/**
* Defines the attribute definition for the `bootstrapAccordionItemsStayOpen`
* attribute.
*/
export type ItemsStayOpenAttributeDefinition = ModelAttributeDefinition<ItemsStayOpen, 'bootstrapAccordionItemsStayOpen'>;

/**
* Defines the attribute value to class name conversion for the
* `bootstrapAccordionItemsStayOpen` attribute.
*/
export const itemsStayOpenOptions: { [key in ItemsStayOpen]: SelectableOption; } = {
true: {
className: 'accordion-items-stay-open'
},
false: {}
};

/**
* Defines the default value for the `bootstrapAccordionItemsStayOpen`
* attribute.
*/
export const itemsStayOpenDefault: ItemsStayOpen = 'false';

/**
* Defines the allowed values for the `bootstrapAccordionButtonCollapsed`
* attribute.
*/
export type ButtonCollapsed = 'true' | 'false';

/**
* Defines the attribute definition for the `bootstrapAccordionButtonCollapsed`
* attribute.
*/
export type ButtonCollapsedAttributeDefinition = ModelAttributeDefinition<ItemsStayOpen, 'bootstrapAccordionButtonCollapsed'>;

/**
* Defines the attribute value to class name conversion for the
* `bootstrapAccordionButtonCollapsed` attribute.
*/
export const buttonCollapsedOptions: { [key in ItemsStayOpen]: SelectableOption; } = {
true: {
className: 'collapsed'
},
false: {}
};

/**
* Defines the allowed values for the `bootstrapAccordionCollapseShow`
* attribute.
*/
export type CollapseShow = 'true' | 'false';

/**
* Defines the attribute definition for the `bootstrapAccordionCollapseShow`
* attribute.
*/
export type CollapseShowAttributeDefinition = ModelAttributeDefinition<ItemsStayOpen, 'bootstrapAccordionCollapseShow'>;

/**
* Defines the attribute value to class name conversion for the
* `bootstrapAccordionCollapseShow` attribute.
*/
export const collapseShowOptions: { [key in ItemsStayOpen]: SelectableOption; } = {
true: {
className: 'show'
},
false: {}
};

Loading