1

我有一个来自 ToastUI 的编辑器(源代码:

<html>
<head>
  <title>TOAST UI</title>
  <script src="https://uicdn.toast.com/tui-editor/latest/tui-editor-Editor-full.js"></script>
  <script src="https://code.jquery.com/jquery-1.12.3.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.48.4/codemirror.min.css" />
  <link rel="stylesheet" href="https://uicdn.toast.com/editor/latest/toastui-editor.min.css" />
  </script>
</head>

<body>
  
  <div id="editorSection">
  </div>
    <button id = "but">Hello</button>
 
<script>
  var editor = new tui.Editor({
    el: document.querySelector('#editorSection'),
    previewStyle: 'vertical',
    height: '300px',
    initialEditType: 'markdown'
  });
  document.querySelector("#but").addEventListener("click", function() {
    //I want such html to make the markdown text, but this doesn't work.
     console.log(document.querySelector('#editorSection').textContent)
     
  })
</script>
</body>

</html>

它可以工作,但我想通过单击按钮将降价文本保存到数据库中。这个怎么做?

4

2 回答 2

0
document.querySelector("#but").addEventListener("click", function() {
    //I want such html to make the markdown text, but this doesn't work.
     console.log(document.querySelector('#editorSection').textContent)
     
  })
于 2020-09-07T16:31:45.587 回答
0
editor = new tui.Editor({
    el: document.querySelector('#editorSection'),
    previewStyle: 'vertical',
    height: '300px',
    initialEditType: 'markdown'
  }); 

editor.getHtml();
editor.getMarkdown();

这两种选择都是可能的。

希望能帮到你。

于 2020-09-07T16:35:53.837 回答