editor_sub.js 706 B

1234567891011121314151617181920
  1. function opennamu_do_editor_preview() {
  2. var input = document.querySelector('#opennamu_edit_textarea');
  3. if (input !== null) {
  4. fetch("/api/w/test/doc_tool/preview", {
  5. method: 'POST',
  6. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  7. body: new URLSearchParams({
  8. 'data': input.value,
  9. })
  10. }).then(function (res) {
  11. return res.json();
  12. }).then(function (text) {
  13. var preview = document.querySelector('#opennamu_preview_area');
  14. if (preview !== null) {
  15. preview.innerHTML = text.data;
  16. eval(text.js_data);
  17. }
  18. });
  19. }
  20. }