Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce insert menu and adjust select widths #51

Merged
merged 1 commit into from
May 17, 2024
Merged
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
26 changes: 22 additions & 4 deletions lib/plugins/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ function button(title, iconUrl) {
return button;
}

function select(options, editorView) {
function select(options, editorView, className) {
const select = document.createElement("select");
select.className = "govuk-select";
select.className = `govuk-select ${className}`;
options.forEach((o, index) => {
o.dom = document.createElement("option");
o.dom.text = o.text;
Expand Down Expand Up @@ -222,6 +222,23 @@ function textBlockMenuSelectOptions(schema) {
];
}

function insertMenuSelectOptions(schema) {
return [
{
text: "Insert",
command: wrapIn(schema.nodes.call_to_action), // Temporary command to get appropriate enabled/disabled behaviour
},
{
text: "Image",
command: () => {},
},
{
text: "Attachemnt",
command: () => {},
},
];
}

function undoMenuItem(schema) {
return {
command: undo,
Expand All @@ -239,13 +256,14 @@ function redoMenuItem(schema) {
function items(schema, editorView) {
return [
headingMenuItem(schema),
select(headingMenuSelectOptions(schema), editorView),
select(headingMenuSelectOptions(schema), editorView, "headingSelect"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is having camel case class names a bit weird at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, will merge in a fix

bulletListMenuItem(schema),
orderedListMenuItem(schema),
stepsMenuItem(schema),
linkMenuItem(schema),
emailLinkMenuItem(schema),
select(textBlockMenuSelectOptions(schema), editorView),
select(textBlockMenuSelectOptions(schema), editorView, "textBlockSelect"),
select(insertMenuSelectOptions(schema), editorView, "insertSelect"),
undoMenuItem(schema),
redoMenuItem(schema),
];
Expand Down
13 changes: 13 additions & 0 deletions scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,18 @@

.menubar .govuk-select {
min-width: 0;
margin: 0 10px 0 5px;
}

.menubar .headingSelect {
width: 48px;
}

.menubar .textBlockSelect {
width: 154px;
margin-right: 5px;
}

.menubar .insertSelect {
width: 82px;
}
Loading