Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
lexoyo committed Jul 27, 2023
1 parent cd8ef9e commit 950c9c4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
46 changes: 23 additions & 23 deletions src/ts/client/grapesjs/breadcrumbs.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { onFooter } from "./footer";
import { onFooter } from './footer'

export default function (editor, options) {
let breadcrumbsContainer
onFooter(footer => {
// Initialize the breadcrumbs container
breadcrumbsContainer = document.createElement('div');
breadcrumbsContainer.id = 'breadcrumbs-container';
footer.prepend(breadcrumbsContainer);
breadcrumbsContainer = document.createElement('div')
breadcrumbsContainer.id = 'breadcrumbs-container'
footer.prepend(breadcrumbsContainer)
// Add breadcrumbs styles
const breadcrumbsStyles = document.createElement('style');
const breadcrumbsStyles = document.createElement('style')
breadcrumbsStyles.innerHTML = `
#breadcrumbs-container {
display: flex;
Expand Down Expand Up @@ -38,42 +38,42 @@ export default function (editor, options) {
#breadcrumbs-container .breadcrumb:last-child::after {
content: "";
}
`;
footer.prepend(breadcrumbsStyles);
renderBreadcrumbs();
`
footer.prepend(breadcrumbsStyles)
renderBreadcrumbs()
})
// Append the breadcrumbs container to the editor's container

editor.on('component:selected style', () => renderBreadcrumbs());
editor.on('component:selected style', () => renderBreadcrumbs())
function renderBreadcrumbs() {
let component = editor.getSelected() ?? editor.Pages.getSelected().getMainComponent()

if(!breadcrumbsContainer) return

// Clear the breadcrumbs container
breadcrumbsContainer.innerHTML = '';
breadcrumbsContainer.innerHTML = ''

// Traverse up the tree of components, prepending each to the breadcrumbs
while (component) {
const breadcrumb = createBreadcrumb(component);
breadcrumbsContainer.prepend(breadcrumb);
console.log(component, component.tagName);
component = component.parent();
const breadcrumb = createBreadcrumb(component)
breadcrumbsContainer.prepend(breadcrumb)
console.log(component, component.tagName)
component = component.parent()
}

// Label
const label = document.createElement('span');
label.innerHTML = '<h3>Selection:&nbsp;</h3>';
breadcrumbsContainer.prepend(label);
const label = document.createElement('span')
label.innerHTML = '<h3>Selection:&nbsp;</h3>'
breadcrumbsContainer.prepend(label)
}
function createBreadcrumb(component) {
const breadcrumb = document.createElement('span');
const model = component.model;
const breadcrumb = document.createElement('span')
const model = component.model
breadcrumb.onclick = () => {
editor.select(component);
};
breadcrumb.classList.add('breadcrumb');
breadcrumb.innerHTML = `<span>${component.get('tagName')}${component.getClasses().length ? `.${component.getClasses().join('.')}` : ''}</span>`;
editor.select(component)
}
breadcrumb.classList.add('breadcrumb')
breadcrumb.innerHTML = `<span>${component.get('tagName')}${component.getClasses().length ? `.${component.getClasses().join('.')}` : ''}</span>`
return breadcrumb
}
}
8 changes: 4 additions & 4 deletions src/ts/client/grapesjs/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ export const settingsDialog = grapesjs.plugins.add(pluginName, (editor, opts) =>
content: '',
attributes: { class: 'settings-dialog' },
})
.onceClose(() => {
sender.set('active', 0) // Deactivate the button to make it ready to be clicked again
editor.stopCommand(cmdOpenSettings) // apparently this is needed to be able to run the command several times
})
.onceClose(() => {
sender.set('active', 0) // Deactivate the button to make it ready to be clicked again
editor.stopCommand(cmdOpenSettings) // apparently this is needed to be able to run the command several times
})
displaySettings(editor, opts, page)
modal.setContent(el)
const form = el.querySelector('form')
Expand Down

0 comments on commit 950c9c4

Please sign in to comment.