islco / django-trix Goto Github PK
View Code? Open in Web Editor NEWBasecamp's Trix rich text editor widget for Django
License: MIT License
Basecamp's Trix rich text editor widget for Django
License: MIT License
The editor doesn't work with new inlines in the admin that are created with javascript. If you press the "Add a new row" button, the editor shows up, but it doesn't update the hidden textarea. This happens, because the html is not updated correctly. The javascript produces something like this:
</div></trix-toolbar><trix-editor input="id_aboutintrotext_set-__prefix__-text" class="trix-content" contenteditable="" trix-id="2" toolbar="trix-toolbar-2"><div><!--block-->fdssadfdsafdssassa</div></trix-editor></p>
Notice the "__prefix__
" is still there.
I was able to work around this by making my own copy of static/admin/js/inlines.js
and adding a few lines:
var updateElementIndex = function(el, prefix, ndx) {
var id_regex = new RegExp("(" + prefix + "-(\\d+|__prefix__))");
var replacement = prefix + "-" + ndx;
if ($(el).prop("for")) {
$(el).prop("for", $(el).prop("for").replace(id_regex, replacement));
}
if (el.id) {
el.id = el.id.replace(id_regex, replacement);
}
if (el.name) {
el.name = el.name.replace(id_regex, replacement);
}
// @HACK(richard) needed for django trix
if ($(el).attr('input')) {
$(el).attr('input', $(el).attr('input').replace(id_regex, replacement));
}
};
I wonder if there's a way to modify the way this is implemented so it works with django's built-in javascript. If the "for" property is used instead of "input", that could make it work.
Added trix to admin using instructions provided. Accessing the admin form with the trix field throws the following:
TypeError: render() got an unexpected keyword argument 'renderer'
Was wondering the status of this project, there are a few pull requests that have been sitting for awhile and I'm currently working on attachment upload:
https://github.com/chrisgrande/django-trix/
I made some design decisions, the big one around not using a model for the uploaded files. The other around uploaded file name randomization.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.