Comments (4)
Right, so you want to reinitialise MarkdownX then.
Here's the code that initialises the process when DOM has loaded.
My understanding is that you want to reinitialise this, which means you want to run this part again:
docReady(() => {
const ELEMENTS = document.getElementsByClassName('markdownx');
return Object.keys(ELEMENTS).map(key => {
let element = ELEMENTS[key],
editor = element.querySelector('.markdownx-editor'),
preview = element.querySelector('.markdownx-preview');
// Only add the new MarkdownX instance to fields that have no MarkdownX instance yet.
if (!editor.hasAttribute('data-markdownx-init'))
return new MarkdownX(element, editor, preview)
});
});
from django-markdownx.
I'd also like to do this. When I've tried to replicate something similar to the above I've struggled because MarkdownX
isn't available globally when I import static('markdownx/js/markdownx.js')
- I think this is due to the way the exports are compiled from typescript.
I've tried everything I can think of to import MarkdownX
from markdownx.js into another file and can't get it to work.
One option could be to set See next comment"module": "es2015"
or similar in the tsconfig.json but not sure if this would have knock on effects elsewhere.
from django-markdownx.
Just done some playing around on a fork of the repository. What worked for me to be able to import MarkdownX
was to add -o markdownx
to the browserify flags as part of the npm run build:js
command. This adds the ability to import as markdownx
, with globals.markdownx
added if no other import option is available.
I found I could then include static('markdownx/js/markdownx.min.js')
and use return new markdownx.MarkdownX(element, editor, preview)
to initialise a markdownx field after the DOM had loaded.
I'll do a pull request for the change to the build step - but not sure if this is the right approach.
from django-markdownx.
Thanks @xenatisch that approach makes sense 👍
from django-markdownx.
Related Issues (20)
- Can't type `[` or `]` using a french keyboard on Windows
- MARKDOWNX_EDITOR_RESIZABLE does not appear to work in v4
- Can't add multiline code block HOT 1
- Release for Django 4.0 HOT 2
- getCookie() bug? HOT 1
- Simple optimization inside views.py HOT 1
- AttributeError on markdownify HOT 1
- A recent Upload and markdownify path errors
- How to customize the textarea cols HOT 2
- Cross-Site Scripting (XSS) Vulnerability in Markdown Library HOT 1
- AttributeError when using pillow >=10.0
- Css for dark theme in admin page
- Contact email to report a vulnerability does not exists HOT 1
- Allow overriding the default storage class for images and such
- Load HTML in iframe?
- Editor height grows on inputs HOT 17
- Ability to set a media path per MarkdownxField
- just now fix! severity found HOT 1
- Is it possible to use extended markdown syntax? HOT 1
- Handle images with wrong exceptions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-markdownx.