Double-click any text to edit it!
Text.js auto saves right to your HTML file.
Just set it up on your server and you're good to go!
Get started with Text.js in two easy ways:
The fastest way to install Text.js:
git clone https://github.com/wlr-inc/textjs
Then run node text.js to start the server.
node text.js
Integrate Text.js into your own Express app:
app.post('/save', (req, res) => {
const filename = req.body.filename || 'index.html';
// Basic security: prevent directory traversal attacks
if (!filename.match(/^[a-z0-9_\-\.]+$/i)) {
return res.status(400).send('Invalid filename');
}
// Save to the 'public' directory
const filePath = path.join(__dirname, 'public', filename);
fs.writeFile(filePath, req.body.html, err => {
if (err) return res.status(500).send('Error saving file');
res.send('File saved');
});
});
Then run node text.js to start the server.
node text.js
<link src="https://textjs.tech/text.css"></link>
<script src="https://textjs.tech/text.js"></script>
This will allow you to access the editor.
Project folder structure example:
your-project/
├── public/
│ └── index.html
│ └── // other HTML files
├── node_modules/
├── text.js
└── package.json
public
folder on your server.
Add the following CDN tags to every page you want to edit:
<link src="https://textjs.tech/text.css"></link>
<script src="https://textjs.tech/text.js"></script>
POST
request to /save
with your updated HTML. Example:
{
"filename": "index.html",
"html": "<h1>Your edited HTML here</h1>"
}
Your server should handle this endpoint to save the file (see install instructions above).
Run node text.js
to start the server.
If you have questions, please email kowskiiocode@gmail.com