Skip to content
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

'use_preview' => true - doesn't seem to work #281

Open
robbieaverill opened this issue Apr 30, 2019 · 3 comments
Open

'use_preview' => true - doesn't seem to work #281

robbieaverill opened this issue Apr 30, 2019 · 3 comments

Comments

@robbieaverill
Copy link
Contributor

Comments 3.2.x-dev

Not sure if this was supposed to do an AJAX request to get a rendered comment preview or something, but all it does now is render an empty field on the frontend:

image

Nothing in the JS console.

@NightJar
Copy link
Contributor

    html_allowed: false # allow for sanitized HTML in comments
    html_allowed_elements:
      - a
      - img
      - i
      - b
    use_preview: false # preview formatted comment (when allowing HTML). Requires include_js=true

Indicates that HTML is disabled by default, and is required for the preview.
Arguably the use_preview setting should be ignored if html_allowed is false.

->setAttribute('style', 'display: none') // enable through JS

The above however indicates that the assumption of AJAX is correct, and https://github.com/silverstripe/silverstripe-comments/blob/3812057b0075cf37fccc5111fa35b5a754aa6031/javascript/CommentsInterface.js contains no reference to preview at all.

@NightJar
Copy link
Contributor

This functionality was commented out when the nested comments concept was introduced.

// @todo Reinstate preview-comment functionality

This code was removed for the next major version as it was all commented out.

/**
* Preview comment by fetching it from the server via ajax.
*/
/* @todo Migrate to work with nested comments
$(':submit[name=action_doPreviewComment]', form).click(function(e) {
e.preventDefault();
if(!form.validate().valid()) {
return false;
}
previewEl.show().addClass('loading').find('.middleColumn').html(' ');
form.ajaxSubmit({
success: function(response) {
var responseEl = $(response);
if(responseEl.is('form')) {
// Validation failed, renders form instead of single comment
form.find(".data-fields").replaceWith(responseEl.find(".data-fields"));
} else {
// Default behaviour
previewEl.removeClass('loading').find('.middleColumn').html(responseEl);
}
},
data: {'action_doPreviewComment': 1}
});
});
*/
/**
* Hide outdated preview on form changes
*/
/*
$(':input', form).on('change keydown', function() {
previewEl.removeClass('loading').hide();
});*/

@NightJar
Copy link
Contributor

Question time:
reinstate, or complete the removal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants