mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-12 17:26:17 +00:00
Create turndown service & use gfm turndown plugin
This commit is contained in:
@@ -21,7 +21,7 @@ const { ipcRenderer, remote, clipboard } = require('electron')
|
||||
import normalizeEditorFontFamily from 'browser/lib/normalizeEditorFontFamily'
|
||||
const spellcheck = require('browser/lib/spellcheck')
|
||||
const buildEditorContextMenu = require('browser/lib/contextMenuBuilder')
|
||||
import TurndownService from 'turndown'
|
||||
import { createTurndownService } from '../lib/turndown'
|
||||
import {languageMaps} from '../lib/CMLanguageList'
|
||||
import snippetManager from '../lib/SnippetManager'
|
||||
import {generateInEditor, tocExistsInEditor} from 'browser/lib/markdown-toc-generator'
|
||||
@@ -102,7 +102,7 @@ export default class CodeEditor extends React.Component {
|
||||
|
||||
this.editorActivityHandler = () => this.handleEditorActivity()
|
||||
|
||||
this.turndownService = new TurndownService()
|
||||
this.turndownService = createTurndownService()
|
||||
}
|
||||
|
||||
handleSearch (msg) {
|
||||
|
||||
8
browser/lib/turndown.js
Normal file
8
browser/lib/turndown.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const TurndownService = require('turndown')
|
||||
const { gfm } = require('turndown-plugin-gfm')
|
||||
|
||||
export const createTurndownService = function () {
|
||||
const turndown = new TurndownService()
|
||||
turndown.use(gfm)
|
||||
return turndown
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
const http = require('http')
|
||||
const https = require('https')
|
||||
const TurndownService = require('turndown')
|
||||
const { createTurndownService } = require('../../../lib/turndown')
|
||||
const createNote = require('./createNote')
|
||||
|
||||
import { push } from 'connected-react-router'
|
||||
@@ -16,7 +16,7 @@ function validateUrl (str) {
|
||||
|
||||
function createNoteFromUrl (url, storage, folder, dispatch = null, location = null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const td = new TurndownService()
|
||||
const td = createTurndownService()
|
||||
|
||||
if (!validateUrl(url)) {
|
||||
reject({result: false, error: 'Please check your URL is in correct format. (Example, https://www.google.com)'})
|
||||
|
||||
Reference in New Issue
Block a user