Skip to content

Commit

Permalink
fix: editor unable to load in django admin inline
Browse files Browse the repository at this point in the history
  • Loading branch information
Agus Makmun committed Mar 30, 2024
1 parent 6e31c71 commit 796ed98
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 47 deletions.
4 changes: 2 additions & 2 deletions martor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

__VERSION__ = "1.6.41"
__RELEASE_DATE__ = "29-Mar-2024"
__VERSION__ = "1.6.42"
__RELEASE_DATE__ = "30-Mar-2024"
__AUTHOR__ = "Agus Makmun (Summon Agus)"
__AUTHOR_EMAIL__ = "summon.agus@gmail.com"
4 changes: 2 additions & 2 deletions martor/static/martor/css/martor-admin.min.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Name : Martor v1.6.41
* Name : Martor v1.6.42
* Created by : Agus Makmun (Summon Agus)
* Release date : 29-Mar-2024
* Release date : 30-Mar-2024
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
**/
Expand Down
4 changes: 2 additions & 2 deletions martor/static/martor/css/martor.bootstrap.min.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Name : Martor v1.6.41
* Name : Martor v1.6.42
* Created by : Agus Makmun (Summon Agus)
* Release date : 29-Mar-2024
* Release date : 30-Mar-2024
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
**/
Expand Down
4 changes: 2 additions & 2 deletions martor/static/martor/css/martor.semantic.min.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Name : Martor v1.6.41
* Name : Martor v1.6.42
* Created by : Agus Makmun (Summon Agus)
* Release date : 29-Mar-2024
* Release date : 30-Mar-2024
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
**/
Expand Down
40 changes: 21 additions & 19 deletions martor/static/martor/js/martor.bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* Name : Martor v1.6.41
* Name : Martor v1.6.42
* Created by : Agus Makmun (Summon Agus)
* Release date : 29-Mar-2024
* Release date : 30-Mar-2024
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
* JS Minifier : https://jscompress.com
**/

(function ($) {
Expand Down Expand Up @@ -147,14 +148,14 @@
var currentTab = $('.tab-pane#nav-preview-' + field_name);
var editorTabButton = $('.nav-link#nav-editor-tab-' + field_name);
var previewTabButton = $('.nav-link#nav-preview-tab-' + field_name);
var toolbarButtons = $(this).closest('.tab-martor-menu').find('.martor-toolbar')
var toolbarButtons = $(this).closest('.tab-martor-menu').find('.martor-toolbar');

editorTabButton.click(function () {
// show the `.martor-toolbar` for this current editor if under preview.
$(this).closest('.tab-martor-menu').find('.martor-toolbar').show();
toolbarButtons.show();
});
previewTabButton.click(function () {
$(this).closest('.tab-martor-menu').find('.martor-toolbar').hide();
toolbarButtons.hide();
});

var refreshPreview = function () {
Expand Down Expand Up @@ -207,7 +208,7 @@
if (editorConfig.living !== 'true') {
previewTabButton.click(function () {
// hide the `.martor-toolbar` for this current editor if under preview.
$(this).closest('.tab-martor-menu').find('.martor-toolbar').hide();
toolbarButtons.hide();
refreshPreview();
});
} else {
Expand Down Expand Up @@ -858,9 +859,7 @@
});

// Set initial value if has the content before.
if (textareaId.val() != '') {
editor.setValue(textareaId.val(), -1);
}
editor.setValue(textareaId.val(), -1);
});// end each `mainMartor`
};

Expand All @@ -870,15 +869,18 @@

if ('django' in window && 'jQuery' in window.django)
django.jQuery(document).on('formset:added', function (event) {
var row = $(event.target);
row.find('.main-martor').each(function () {
var id = row.attr('id');
id = id.substr(id.lastIndexOf('-') + 1);
// Notice here we are using our jQuery instead of Django's.
// This is because plugins are only loaded for ours.
var fixed = $(this.outerHTML.replace(/__prefix__/g, id));
$(this).replaceWith(fixed);
fixed.martor();
});
// add delay for formset to load
setTimeout(function(){
var row = $(event.target);
row.find('.main-martor').each(function () {
var id = row.attr('id');
id = id.substr(id.lastIndexOf('-') + 1);
// Notice here we are using our jQuery instead of Django's.
// This is because plugins are only loaded for ours.
var fixed = $(this.outerHTML.replace(/__prefix__/g, id));
$(this).replaceWith(fixed);
fixed.martor();
});
}, 1000);
});
})(jQuery);
7 changes: 4 additions & 3 deletions martor/static/martor/js/martor.bootstrap.min.js

Large diffs are not rendered by default.

30 changes: 16 additions & 14 deletions martor/static/martor/js/martor.semantic.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* Name : Martor v1.6.41
* Name : Martor v1.6.42
* Created by : Agus Makmun (Summon Agus)
* Release date : 29-Mar-2024
* Release date : 30-Mar-2024
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
* JS Minifier : https://jscompress.com
**/

(function ($) {
Expand Down Expand Up @@ -855,9 +856,7 @@
});

// Set initial value if has the content before.
if (textareaId.val() != '') {
editor.setValue(textareaId.val(), -1);
}
editor.setValue(textareaId.val(), -1);
});// end each `mainMartor`
};

Expand All @@ -867,14 +866,17 @@

if ('django' in window && 'jQuery' in window.django)
django.jQuery(document).on('formset:added', function (event, $row) {
$row.find('.main-martor').each(function () {
var id = $row.attr('id');
id = id.substr(id.lastIndexOf('-') + 1);
// Notice here we are using our jQuery instead of Django's.
// This is because plugins are only loaded for ours.
var fixed = $(this.outerHTML.replace(/__prefix__/g, id));
$(this).replaceWith(fixed);
fixed.martor();
});
// add delay for formset to load
setTimeout(function(){
$row.find('.main-martor').each(function () {
var id = $row.attr('id');
id = id.substr(id.lastIndexOf('-') + 1);
// Notice here we are using our jQuery instead of Django's.
// This is because plugins are only loaded for ours.
var fixed = $(this.outerHTML.replace(/__prefix__/g, id));
$(this).replaceWith(fixed);
fixed.martor();
});
}, 1000);
});
})(jQuery);
Loading

0 comments on commit 796ed98

Please sign in to comment.