We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Uncaught ReferenceError: require is not defined
` const MenuBar = require( "menubar" ).menubar;
let browserWindow = null;
const menubar = MenuBar( { index: file://${__dirname}/index.html, webPreferences: { nodeIntegration: true, contextIsolation: false } } );
file://${__dirname}/index.html
menubar.on( "ready", () => { console.log( "Application is ready" ); } );
menubar.on( "after-create-window", () => { menubar.window.webContents.openDevTools(); } ); `
console.log( "in renderer" );
const { clipboard } = require( "electron" );
const clippingsList = document.getElementById( "clippings-list" ); const copyFromClipboardButton = document.getElementById( "copy-from-clipboard" );
clippingsList.addEventListener( "click", event => { const hasClass = className => { event.target.classList.contains( className );
const clippingListItem = getButtonParent( event ); if ( hasClass( "remove-clipping" ) ) removeClipping( clippingListItem ); if ( hasClass( "copy-clipping" ) ) writeToClipboard( getClippingText( clippingListItem ) ); if ( hasClass( "publish-clipping" ) ) console.log( "Publish clipping", getClippingText() );
} } );
const addClippingToList = () => { const clippingText = clipboard.readText(); const clippingElement = createClippingElement( clippingText ); clippingsList.prepend( clippingElement ); };
const getButtonParent = ( target ) => { return target.parentNode.parentNode; };
const getClippingText = ( clippingListItem ) => { return clippingListItem.querySelector( ".clipping-text" ).innerText; };
const removeClipping = target => { target.remove(); };
const writeToClipboard = ( clippingText ) => { clipboard.writeText( clippingText ); };
const createClippingElement = ( clippingText ) => { const clippingElement = document.createElement( "article" );
clippingElement.classList.add( "clippings-list-item" );
clippingElement.innerHTML = <div class='clipping-text' disabled='true'></div> <div class="clipping-controls"> <button class="copy-clipping">→ Clipboard</button> <button class="publish-clipping">Publish</button> <button class="remove-clipping">Remove</button> </div>;
<div class='clipping-text' disabled='true'></div> <div class="clipping-controls"> <button class="copy-clipping">→ Clipboard</button> <button class="publish-clipping">Publish</button> <button class="remove-clipping">Remove</button> </div>
clippingElement.querySelector( ".clipping-text" ).innerText = clippingText;
return clippingElement; }
copyFromClipboardButton.addEventListener( "click", addClippingToList );
##Anyone who can help please?
The text was updated successfully, but these errors were encountered:
Use https://github.com/linonetwo/electron-ipc-cat
Remote is deprecated.
Sorry, something went wrong.
see this issue's solution: #334
No branches or pull requests
Error
Actual Behaviour
Uncaught ReferenceError: require is not defined
Specifications
Source Code
Main process
`
const MenuBar = require( "menubar" ).menubar;
let browserWindow = null;
const menubar = MenuBar( {
index:
file://${__dirname}/index.html
,webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
} );
menubar.on( "ready", () => {
console.log( "Application is ready" );
} );
menubar.on( "after-create-window", () => {
menubar.window.webContents.openDevTools();
} );
`
Renderer process
console.log( "in renderer" );
const { clipboard } = require( "electron" );
const clippingsList = document.getElementById( "clippings-list" );
const copyFromClipboardButton = document.getElementById( "copy-from-clipboard" );
clippingsList.addEventListener( "click", event => {
const hasClass = className => {
event.target.classList.contains( className );
}
} );
const addClippingToList = () => {
const clippingText = clipboard.readText();
const clippingElement = createClippingElement( clippingText );
clippingsList.prepend( clippingElement );
};
const getButtonParent = ( target ) => {
return target.parentNode.parentNode;
};
const getClippingText = ( clippingListItem ) => {
return clippingListItem.querySelector( ".clipping-text" ).innerText;
};
const removeClipping = target => {
target.remove();
};
const writeToClipboard = ( clippingText ) => {
clipboard.writeText( clippingText );
};
const createClippingElement = ( clippingText ) => {
const clippingElement = document.createElement( "article" );
clippingElement.classList.add( "clippings-list-item" );
clippingElement.innerHTML =
<div class='clipping-text' disabled='true'></div> <div class="clipping-controls"> <button class="copy-clipping">→ Clipboard</button> <button class="publish-clipping">Publish</button> <button class="remove-clipping">Remove</button> </div>
;clippingElement.querySelector( ".clipping-text" ).innerText = clippingText;
return clippingElement;
}
copyFromClipboardButton.addEventListener( "click", addClippingToList );
##Anyone who can help please?
The text was updated successfully, but these errors were encountered: