editor_sub.ts 762 B

1234567891011121314151617181920
  1. function opennamu_do_editor_preview() {
  2. const input = document.querySelector('#opennamu_edit_textarea') as HTMLInputElement | null;
  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. const preview = document.querySelector('#opennamu_preview_area') as HTMLInputElement | null;
  14. if(preview !== null) {
  15. preview.innerHTML = text.data;
  16. eval(text.js_data);
  17. }
  18. });
  19. }
  20. }