diff --git a/src/editor/contentState/pasteCtrl.js b/src/editor/contentState/pasteCtrl.js
index 1f4fb7dc..83db6eaa 100644
--- a/src/editor/contentState/pasteCtrl.js
+++ b/src/editor/contentState/pasteCtrl.js
@@ -1,4 +1,7 @@
-import { PARAGRAPH_TYPES } from '../config'
+import cheerio from 'cheerio'
+import { sanitize } from '../utils'
+import { PARAGRAPH_TYPES, PREVIEW_DOMPURIFY_CONFIG } from '../config'
+
const LIST_REG = /ul|ol/
const LINE_BREAKS_REG = /\n/
@@ -37,6 +40,33 @@ const pasteCtrl = ContentState => {
return type
}
+ ContentState.prototype.standardizeHTML = function (html) {
+ const $ = cheerio.load(sanitize(html, PREVIEW_DOMPURIFY_CONFIG))
+ // convert un-standard table to standard table which can be identified by turndown.
+ // These un-standard table mainly copy from Number app.
+ const tables = $('table')
+ if (tables.length > 0) {
+ tables.each((i, t) => {
+ const table = $(t)
+ table.find('tr').each((i, tr) => {
+ if (i === 0 && $(tr).children().first().tagName !== 'th') {
+ $(tr).children().each((i, td) => {
+ const html = $(td).html()
+ $(td).replaceWith($(`
${html} | `))
+ })
+ }
+ })
+
+ table.find('p').each((i, p) => {
+ const html = $(p).html()
+ $(p).replaceWith($(`${html}`))
+ })
+ })
+ }
+
+ return $('body').html()
+ }
+
// handle `normal` and `pasteAsPlainText` paste
ContentState.prototype.pasteHandler = function (event, type) {
if (this.checkInCodeBlock()) {
@@ -44,7 +74,8 @@ const pasteCtrl = ContentState => {
}
event.preventDefault()
const text = event.clipboardData.getData('text/plain')
- const html = event.clipboardData.getData('text/html')
+ let html = event.clipboardData.getData('text/html')
+ html = this.standardizeHTML(html)
// console.log(text)
// console.log(html)
const copyType = this.checkCopyType(html, text)
@@ -66,7 +97,6 @@ const pasteCtrl = ContentState => {
end: { key, offset }
}
}
-
// handle copyAsHtml
if (copyType === 'copyAsHtml') {
switch (type) {
diff --git a/src/editor/index.css b/src/editor/index.css
index 4abd49de..beca8b55 100644
--- a/src/editor/index.css
+++ b/src/editor/index.css
@@ -15,6 +15,11 @@
--extraLightBorder: #F2F6FC;
}
+html {
+ -webkit-font-smoothing: antialiased;
+}
+
+
@keyframes highlight {
from {
transform: scale(1);
diff --git a/src/main/actions/theme.js b/src/main/actions/theme.js
index 64103f9b..f1f58e81 100644
--- a/src/main/actions/theme.js
+++ b/src/main/actions/theme.js
@@ -5,7 +5,7 @@ import appWindow from '../window'
export const selectTheme = (theme, themeCSS) => {
userPreference.setItem('theme', theme)
.then(() => {
- for (const win of appWindow.windows.values()) {
+ for (const { win } of appWindow.windows.values()) {
win.webContents.send('AGANI::user-preference', { theme })
}
})
diff --git a/static/themes/dark.css b/static/themes/dark.css
index 3d994d17..b1c6cfb4 100755
--- a/static/themes/dark.css
+++ b/static/themes/dark.css
@@ -5,6 +5,34 @@
@include-when-export url(https://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,700,400&subset=latin,latin-ext);
+@font-face {
+ font-family: 'Open Sans';
+ font-style: normal;
+ font-weight: normal;
+ src: local('Open Sans Regular'),url('./github/400.woff') format('woff')
+}
+
+@font-face {
+ font-family: 'Open Sans';
+ font-style: italic;
+ font-weight: normal;
+ src: local('Open Sans Italic'),url('./github/400i.woff') format('woff')
+}
+
+@font-face {
+ font-family: 'Open Sans';
+ font-style: normal;
+ font-weight: bold;
+ src: local('Open Sans Bold'),url('./github/700.woff') format('woff')
+}
+
+@font-face {
+ font-family: 'Open Sans';
+ font-style: italic;
+ font-weight: bold;
+ src: local('Open Sans Bold Italic'),url('./github/700i.woff') format('woff')
+}
+
html, body {
font-size: 16px;
}
diff --git a/static/themes/light.css b/static/themes/light.css
index 13ee3b2a..d07e96a8 100644
--- a/static/themes/light.css
+++ b/static/themes/light.css
@@ -5,6 +5,34 @@
@include-when-export url(https://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,700,400&subset=latin,latin-ext);
+@font-face {
+ font-family: 'Open Sans';
+ font-style: normal;
+ font-weight: normal;
+ src: local('Open Sans Regular'),url('./github/400.woff') format('woff')
+}
+
+@font-face {
+ font-family: 'Open Sans';
+ font-style: italic;
+ font-weight: normal;
+ src: local('Open Sans Italic'),url('./github/400i.woff') format('woff')
+}
+
+@font-face {
+ font-family: 'Open Sans';
+ font-style: normal;
+ font-weight: bold;
+ src: local('Open Sans Bold'),url('./github/700.woff') format('woff')
+}
+
+@font-face {
+ font-family: 'Open Sans';
+ font-style: italic;
+ font-weight: bold;
+ src: local('Open Sans Bold Italic'),url('./github/700i.woff') format('woff')
+}
+
html, body {
font-size: 16px;
background: rgb(252, 252, 252);