-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Potential Fix for #7152 (Slate crashing) #7153
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
Conversation
This is a nice find @DavidWells! We also have a similar crash with Lists integration but that one seems a lot harder to reproduce consistently. If you also have any ideas there, that would be so great! Here is an issue #7047 but I find it easiest to reproduce by adding a ton of list items and then manically selecting and deleting chunks of them. There is one slight issue after your fix - the editor seems loses focus after backspace. I will look into handling this in the keyDown event of the inline "plugins" and commit into this PR if you don't mind. Might also solve the cypress test not passing. |
Could do something like this to fix selection, unless we figure out why this happens in the first place..
Not sure yet where to put it though, currently I put it in the handleChange function and it makes it work. If you're in a hurry we can update the cypress tests and push this through and I will work on fixing the selection in another PR or even wait until we potentially move to Plate. |
Not in a rush. I have a silly lil postinstall script to patch the package right now. Haven't seen the crash since I did this. It could possibly still happen on elements with no const path = require('path')
const fs = require('fs').promises
/**
* Asynchronously finds and replaces text in a file.
* @param {string} filePath - The path to the file.
* @param {RegExp} searchString - The regular expression to search for.
* @param {string} replacementString - The string to replace the matches.
* @returns {Promise<void>} A promise that resolves once the replacement is complete.
*/
async function findAndReplace(filePath, searchString, replacementString) {
console.log(`Patching CMS file:`, filePath)
try {
// Read file content
let data = await fs.readFile(filePath, 'utf8')
// Perform replacement
data = data.replace(searchString, replacementString)
// Write updated content back to the file
await fs.writeFile(filePath, data, 'utf8')
console.log('Patching CMS complete')
} catch (err) {
console.error('Error:', err)
}
}
// File path and strings to search and replace
const depPath = path.resolve(__dirname, '../node_modules/decap-cms-app/dist/decap-cms-app.js')
const searchString = /function\s+G\(e\){return\(0,i\.jsx\)\("br",e\.attributes\)\}/g
const replacementString = 'function G(e){return(0,i.jsx)("div",e.attributes,e.children)}'
findAndReplace(depPath, searchString, replacementString) |
Fixed the e2e tests. |
released as [email protected] |
* Potential Fix for #7152 * fix: update e2e tests for soft breaks --------- Co-authored-by: Anze Demsar <[email protected]>
Potential fix for #7152