Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: slimkit/plus-editor
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.2.6
Choose a base ref
...
head repository: slimkit/plus-editor
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.2
Choose a head ref
  • 14 commits
  • 11 files changed
  • 3 contributors

Commits on Dec 2, 2019

  1. chore: 更新文档

    xiewme committed Dec 2, 2019
    Copy the full SHA
    b11aea2 View commit details
  2. fix: 修复正则错误

    xiewme committed Dec 2, 2019
    Copy the full SHA
    0ed352c View commit details
  3. release v1.2.7

    xiewme committed Dec 2, 2019
    Copy the full SHA
    dd7aa00 View commit details

Commits on Dec 4, 2019

  1. feat: 兼容旧的服务端

    xiewme committed Dec 4, 2019
    Copy the full SHA
    d1be391 View commit details

Commits on May 22, 2020

  1. chore: 增加黑暗模式

    boxshadow committed May 22, 2020
    Copy the full SHA
    6add210 View commit details
  2. chore: 调整暗黑模式

    boxshadow committed May 22, 2020
    Copy the full SHA
    d068d4c View commit details
  3. chore: 修复

    boxshadow committed May 22, 2020
    Copy the full SHA
    44458e3 View commit details
  4. chore: 优化

    boxshadow committed May 22, 2020
    Copy the full SHA
    a1527e2 View commit details

Commits on Sep 8, 2020

  1. chore: 加入黑暗模式

    boxshadow committed Sep 8, 2020
    Copy the full SHA
    0844908 View commit details
  2. Copy the full SHA
    6e6a94d View commit details
  3. chore: 优化

    boxshadow committed Sep 8, 2020
    Copy the full SHA
    21e4088 View commit details

Commits on Nov 30, 2020

  1. 修改一个逻辑

    boxshadow committed Nov 30, 2020
    Copy the full SHA
    8e4fb60 View commit details
  2. 测试

    boxshadow committed Nov 30, 2020
    Copy the full SHA
    c5f2fa3 View commit details
  3. 图片高宽

    boxshadow committed Nov 30, 2020
    Copy the full SHA
    e0856d9 View commit details
Showing with 228 additions and 11 deletions.
  1. +93 −4 .gitignore
  2. +2 −2 README.md
  3. +37 −0 dist/index.css
  4. +1 −1 dist/index.js
  5. +19 −0 dist/preview.css
  6. +1 −1 dist/preview.js
  7. +1 −1 package.json
  8. +18 −0 src/index.styl
  9. +21 −0 src/preview.styl
  10. +11 −1 src/preview.ts
  11. +24 −1 src/uploader.ts
97 changes: 93 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,93 @@
node_modules
cypress/build
cypress/videos
*.log

# Created by https://www.gitignore.io/api/webstorm+all
# Edit at https://www.gitignore.io/?templates=webstorm+all

### WebStorm+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### WebStorm+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360

.idea/

# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

*.iml
modules.xml
.idea/misc.xml
*.ipr

# Sonarlint plugin
.idea/sonarlint

# End of https://www.gitignore.io/api/webstorm+all
node_modules/
package-lock.json
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -49,11 +49,11 @@

4. 待视频上传完毕后, 将视频网络地址连同刚才的唯一标识(id)再次发送给 webview

调用 webview 的以下方法传递上传后的视频, 编辑器会在提交时进行替换
调用 webview 的以下方法传递上传后的视频, 编辑器会在提交时进行替换, node 为可选

```js
window.videoUrlReceiver(
'{ "id": "unique-id", "url": "newwork-file-url", "poster": "newwork-file-url" }',
'{ "id": "unique-id", "url": "newwork-file-url", "urlNode": "xxx", "poster": "newwork-file-url", "posterNode": "xxx" }',
)
```

37 changes: 37 additions & 0 deletions dist/index.css
Original file line number Diff line number Diff line change
@@ -938,6 +938,24 @@
border: 1px solid #ccc;
}

:root {
color-scheme: light dark;
--background: transparent;
--content-color: #15171a;
}
@media (prefers-color-scheme: dark) {
:root {
--background-color: #222;
--content-color: #dfdfdf;
}
.ql-toolbar {
background-color: #868686 !important;
border-top-color: #000 !important;
}
.ql-editor {
color: #868686 !important;
}
}
html,
body {
margin: 0;
@@ -1156,6 +1174,24 @@ body {
content: '移除';
}

:root {
color-scheme: light dark;
--background-color: #fff;
--content-color: #15171a;
}
@media (prefers-color-scheme: dark) {
:root {
--background-color: #222;
--content-color: #dfdfdf;
}
.ql-editor {
color: #fff !important;
}
}
.ql-editor {
background: var(--background-color);
color: var(--content-color);
}
html,
body {
margin: 0;
@@ -1179,6 +1215,7 @@ body {
margin: auto;
display: block;
max-width: 100%;
height: auto !important;
}
.ql-editor video {
margin: auto;
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions dist/preview.css
Original file line number Diff line number Diff line change
@@ -938,6 +938,24 @@
border: 1px solid #ccc;
}

:root {
color-scheme: light dark;
--background-color: #fff;
--content-color: #15171a;
}
@media (prefers-color-scheme: dark) {
:root {
--background-color: #222;
--content-color: #dfdfdf;
}
.ql-editor {
color: #fff !important;
}
}
.ql-editor {
background: var(--background-color);
color: var(--content-color);
}
html,
body {
margin: 0;
@@ -961,6 +979,7 @@ body {
margin: auto;
display: block;
max-width: 100%;
height: auto !important;
}
.ql-editor video {
margin: auto;
2 changes: 1 addition & 1 deletion dist/preview.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slimkit/plus-editor",
"version": "1.2.6",
"version": "1.2.8",
"description": "rich-text editor for plus",
"main": "dist/main.bundle.js",
"repository": "git@github.com:mutoe/plus-editor.git",
18 changes: 18 additions & 0 deletions src/index.styl
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
:root {
color-scheme: light dark;
--background: transparent;
--content-color: #15171a;
}
@media (prefers-color-scheme: dark) {
:root {
--background-color: #222;
--content-color: #dfdfdf;
}
.ql-toolbar {
background-color: #868686!important;
border-top-color: #000!important;
}
.ql-editor {
color: #868686 !important;
}
}
html
body {
margin: 0;
21 changes: 21 additions & 0 deletions src/preview.styl
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
// 这里的样式也会影响到移动端的展示, 谨慎修改
:root {
color-scheme: light dark;
--background-color: #FFFFFF;
--content-color: #15171A;
}

@media (prefers-color-scheme: dark) {
:root {
--background-color: #222;
--content-color: #dfdfdf;
}
.ql-editor {
color: #fff!important;
}
}

.ql-editor {
background: var(--background-color);
color: var(--content-color);
}
html, body {
margin: 0;
}
@@ -24,6 +44,7 @@ html, body {
margin: auto;
display: block;
max-width: 100%;
height: auto!important;
}

video {
12 changes: 11 additions & 1 deletion src/preview.ts
Original file line number Diff line number Diff line change
@@ -48,6 +48,16 @@ const onReady = () => {
height: Number(img.dataset.height) || 0,
})

const imgWidth = Number(img.dataset.width) || 0
const imgHeight = Number(img.dataset.height) || 0

if (imgWidth && imgHeight) {
if (imgWidth > document.body.offsetWidth) {
img.style.width = `${document.body.offsetWidth}px`
img.style.height = `${imgHeight * (document.body.offsetWidth / imgWidth)}px`
}
}

img.addEventListener('click', () => {
callMethod('clickImage', { src: img.src, arr: images, index })
})
@@ -67,7 +77,7 @@ const onReady = () => {
})
}

if (document.readyState === 'loading') {
if (document.readyState !== 'complete') {
document.addEventListener('DOMContentLoaded', onReady)
} else {
onReady()
25 changes: 24 additions & 1 deletion src/uploader.ts
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import Spark from 'spark-md5'
let userToken: string = ''
let apiV2BaseUrl: string = ''
let storage = { channel: 'public' }
let crawlerUrl: string = ''

try {
const sp = new URL(window.location.href).searchParams
@@ -23,6 +24,7 @@ window.setUploaderOptions = options => {
options = JSON.parse(options)
}

crawlerUrl = ''
userToken = options.userToken || ''
apiV2BaseUrl = options.apiV2BaseUrl || ''

@@ -282,6 +284,26 @@ async function getMediaInfo(file: File) {
return mf
}

let crawlerUrlPromise: Promise<string> | null
async function getCrawlerUrl() {
if (!crawlerUrl) {
if (!crawlerUrlPromise) {
const url = `${apiV2BaseUrl.replace(/\/+$/, '')}/crawl`
crawlerUrlPromise = axios
.head(url)
.then(() => (crawlerUrl = url))
.catch(() => (crawlerUrl = 'https://thinksns.zhibocloud.cn/api/v2/crawl'))
.finally(() => {
crawlerUrlPromise = null
})
}

return await crawlerUrlPromise
}

return crawlerUrl
}

async function uploadRemoteImage(params: {
src: string
remoteId: string
@@ -301,6 +323,7 @@ async function uploadRemoteImage(params: {
try {
const contentType = 'image/png'
const filename = `${Date.now()}.png`
const crawlerUrl = await getCrawlerUrl()
const { blob, file, buff } = await new Promise((resolve, reject) => {
const img = document.createElement('img')
img.addEventListener('load', () => {
@@ -327,7 +350,7 @@ async function uploadRemoteImage(params: {
})
img.addEventListener('error', () => reject())
img.crossOrigin = 'anonymous'
img.src = `${apiV2BaseUrl.replace(/\/+/, '')}/crawl?url=${encodeURIComponent(params.src)}`
img.src = `${crawlerUrl}?url=${encodeURIComponent(params.src)}`
})

const spark = new Spark.ArrayBuffer()