Architecture and development¶
The module defines no hooks or plugin types for others to implement. This page describes how it fits together for people who want to debug it or send patches.
Rendering flow¶
flowchart LR
A[Text with <drupal-view> or token] --> B[Filter InsertView::process]
B --> C[Placeholder with encoded filter settings]
C --> D[InsertView::build]
D --> E{Allowed and accessible?}
E -- no --> F[Empty or raw token]
E -- yes --> G[Views executes display with arguments]
G --> H[Render array replaces the placeholder]
InsertView::build() is a lazy builder callback. It takes only scalar arguments, which is why the filter configuration is passed as a JSON string.
Components¶
| File | Role |
|---|---|
src/Plugin/Filter/InsertView.php |
The insert_view_adv filter: token and element parsing, placeholders, settings form, filter tips. |
src/Form/InsertViewDialog.php |
The dialog form. Builds the argument elements, including autocomplete and multi-value handling. |
src/Controller/AdvancedInsertViewController.php |
Live preview endpoint, insert_view_adv.editor_preview. |
src/Plugin/CKEditor5Plugin/InsertView.php |
CKEditor 5 plugin configuration, including the live preview option. |
src/Plugin/CKEditorPlugin/InsertView.php |
CKEditor 4 plugin (Drupal 10 only). |
src/Plugin/EntityUsage/Track/InsertViewArguments.php |
Entity Usage tracker for entities used as view arguments. |
src/Hook/InsertViewAdvHooks.php |
Help, library alter, views pre/post hooks, exposed form alter. |
modules/bueditor |
BUEditor button. |
Routes¶
| Route | Path | Access |
|---|---|---|
insert_view_adv.editor_dialog |
/insert-view-wysiwyg/dialog/{filter_format} |
filter_format.use |
insert_view_adv.editor_preview |
/insert-view-adv/preview/{filter_format} |
filter_format.use |
Entity Usage¶
When the Entity Usage module is installed, enable the Insert view arguments tracking method in the Entity Usage settings. It parses <drupal-view> elements in text, text_long and text_with_summary fields and records the entities used as taxonomy term, content, user or entity reference arguments.
Building the CKEditor 5 assets¶
The plugin source is in js/ckeditor5_plugins/insert_view_adv/src. The compiled files in js/build are committed. Rebuild only after changing the source. Node.js and Yarn are required.
yarn install
yarn build
Use yarn watch while developing. Two bundles are built because Drupal 12 changed how CKEditor 5 is provided (change record):
| File | Drupal | CKEditor 5 delivery |
|---|---|---|
js/build/insert_view.js |
10 and 11 | DLL build (window.CKEditor5.dll), built with DllReferencePlugin. |
js/build/insert_view.umd.js |
12 and later | UMD build (window.CKEDITOR), imports treated as externals. |
InsertViewAdvHooks::libraryInfoAlter() selects the file from the Drupal major version. Commit both files after rebuilding. Do not import CKEditor 5 internals by deep path (for example @ckeditor/ckeditor5-*/src/...) in the plugin source; those imports work in only one of the two builds.
Tests¶
Kernel and FunctionalJavascript tests live in tests/src, with a test module and test views in tests/modules/insert_view_adv_test. The GitLab CI pipeline runs them through the drupal.org templates.