-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add HTML2MD conversion to abstract and comment fields (#10896)
* Add HTML2MD conversion to abstract and comment fields Co-authored-by: Carl Christian Snethlage <[email protected]> Co-authored-by: Amanda Anderson <[email protected]> Co-authored-by: Paisley Lewis <[email protected]> Co-authored-by: Luca Bolzonello <[email protected]> Co-authored-by: Ashwin2397 <[email protected]> * Add ClipBoardManager bridge --------- Co-authored-by: Carl Christian Snethlage <[email protected]> Co-authored-by: Amanda Anderson <[email protected]> Co-authored-by: Paisley Lewis <[email protected]> Co-authored-by: Luca Bolzonello <[email protected]> Co-authored-by: Ashwin2397 <[email protected]> Co-authored-by: Christoph <[email protected]>
- Loading branch information
1 parent
9e5e5a1
commit f570a2d
Showing
11 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/org/jabref/gui/fieldeditors/MarkdownEditor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.jabref.gui.fieldeditors; | ||
|
||
import javax.swing.undo.UndoManager; | ||
|
||
import javafx.scene.control.TextInputControl; | ||
|
||
import org.jabref.gui.ClipBoardManager; | ||
import org.jabref.gui.autocompleter.SuggestionProvider; | ||
import org.jabref.logic.integrity.FieldCheckers; | ||
import org.jabref.model.entry.field.Field; | ||
import org.jabref.preferences.PreferencesService; | ||
|
||
import com.vladsch.flexmark.html2md.converter.FlexmarkHtmlConverter; | ||
|
||
public class MarkdownEditor extends SimpleEditor { | ||
|
||
private final FlexmarkHtmlConverter flexmarkHtmlConverter = FlexmarkHtmlConverter.builder().build(); | ||
|
||
public MarkdownEditor(Field field, SuggestionProvider<?> suggestionProvider, FieldCheckers fieldCheckers, PreferencesService preferences, UndoManager undoManager) { | ||
super(field, suggestionProvider, fieldCheckers, preferences, true, undoManager); | ||
} | ||
|
||
@Override | ||
protected TextInputControl createTextInputControl() { | ||
return new EditorTextArea() { | ||
@Override | ||
public void paste() { | ||
if (ClipBoardManager.hasHtml()) { | ||
String htmlText = ClipBoardManager.getHtmlContents(); | ||
String mdText = flexmarkHtmlConverter.convert(htmlText); | ||
super.replaceSelection(mdText); | ||
} else { | ||
super.paste(); | ||
} | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters