Как я могу установить поведение новой строки для htmleditorkit - PullRequest
0 голосов
/ 20 ноября 2018

У меня есть JEditorPane, настроенный для редактирования ввода html, и я хотел бы изменить поведение новой строки так, чтобы при переходе на новую строку он вставлял <\br> вместо окружения текста в <p></p>.На данный момент у меня есть следующее.

newSignatureScrollPane = new javax.swing.JScrollPane();
newSignatureEditorPane = new javax.swing.JEditorPane();
newSignatureEditorPane.setContentType("text/html"); // NOI18N
newSignatureEditorPane.setDocument(new HTMLDocument());
newSignatureEditorPane.setEditorKit(new HTMLEditorKit());
newSignatureScrollPane.setViewportView(newSignatureEditorPane);

Это приводит к следующему, когда я делаю newSignatureEditorPane.getText() в моем saveChangesButtonAction:

<html>
<head>
</head>
<body>
<p style="margin-top: 0">
  Line 1
</p>
<p style="margin-top: 0">
  Line 2
</p>
</body>
</html>
...