@dcloudio/uni-h5 2.0.0 → 2.0.1-32920211122002
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automator.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.umd.min.js +1 -1
- package/lib/apis.js +14 -4
- package/lib/h5/uni.automator.js +1 -1
- package/lib/modules.json +4 -1
- package/manifest.json +49 -0
- package/package.json +2 -3
- package/src/core/helpers/api.js +1 -1
- package/src/core/helpers/constants.js +1 -0
- package/src/core/helpers/i18n/en.json +4 -2
- package/src/core/helpers/i18n/es.json +4 -1
- package/src/core/helpers/i18n/fr.json +4 -1
- package/src/core/helpers/i18n/index.js +155 -4
- package/src/core/helpers/i18n/zh-Hans.json +4 -1
- package/src/core/helpers/i18n/zh-Hant.json +4 -1
- package/src/core/helpers/index.js +1 -1
- package/src/core/helpers/interceptor.js +19 -15
- package/src/core/helpers/promise.js +1 -1
- package/src/core/helpers/protocol/device/set-clipboard-data.js +11 -2
- package/src/core/helpers/protocol/network/request.js +14 -1
- package/src/core/helpers/protocol/network/upload-file.js +1 -1
- package/src/core/helpers/protocol/ui/popup.js +2 -2
- package/src/core/runtime/base.js +2 -0
- package/src/core/runtime/locale.js +37 -0
- package/src/core/runtime/web-view/index.js +4 -0
- package/src/core/runtime/wrapper/create-subpackage-app.js +7 -6
- package/src/core/runtime/wrapper/util.js +6 -1
- package/src/core/service/api/base/interceptor.js +1 -1
- package/src/core/service/api/context/canvas.js +3 -2
- package/src/core/service/api/context/create-map-context.js +8 -1
- package/src/core/service/api/ui/locale.js +50 -0
- package/src/core/service/plugins/app/create-app.js +8 -3
- package/src/core/service/plugins/app/index.js +2 -2
- package/src/core/service/plugins/index.js +8 -2
- package/src/core/view/bridge/subscribe/api/request-component-observer.js +16 -1
- package/src/core/view/components/canvas/index.vue +3 -1
- package/src/core/view/components/editor/formats/image.js +3 -1
- package/src/core/view/components/editor/formats/index.js +3 -1
- package/src/core/view/components/editor/formats/link.js +9 -0
- package/src/core/view/components/editor/index.vue +33 -3
- package/src/core/view/components/image/index.vue +4 -5
- package/src/core/view/components/input/index.vue +53 -25
- package/src/core/view/components/picker-view-column/index.vue +1 -0
- package/src/core/view/components/progress/index.vue +20 -13
- package/src/core/view/components/rich-text/index.vue +13 -1
- package/src/core/view/components/rich-text/nodes-parser.js +23 -4
- package/src/core/view/components/scroll-view/index.vue +253 -122
- package/src/core/view/components/slider/index.vue +1 -1
- package/src/core/view/components/swiper/index.vue +3 -0
- package/src/core/view/components/textarea/index.vue +7 -3
- package/src/core/view/index.css +4 -0
- package/src/core/view/mixins/field.js +27 -9
- package/src/core/view/mixins/interact.js +13 -11
- package/src/core/view/mixins/keyboard.js +42 -26
- package/src/core/view/mixins/touchtrack.js +2 -2
- package/src/core/view/plugins/index.js +1 -1
- package/src/platforms/app-plus/constants.js +1 -0
- package/src/platforms/app-plus/helpers/get-real-path.js +7 -4
- package/src/platforms/app-plus/helpers/uuid.js +1 -1
- package/src/platforms/app-plus/service/api/ad/ad-base.js +159 -0
- package/src/platforms/app-plus/service/api/ad/ad.js +4 -8
- package/src/platforms/app-plus/service/api/ad/full-screen-video-ad.js +5 -98
- package/src/platforms/app-plus/service/api/ad/interactive-ad.js +257 -0
- package/src/platforms/app-plus/service/api/ad/interstitial-ad.js +15 -0
- package/src/platforms/app-plus/service/api/ad/rewarded-video-ad.js +15 -2
- package/src/platforms/app-plus/service/api/device/system.js +3 -2
- package/src/platforms/app-plus/service/api/file/open-document.js +7 -15
- package/src/platforms/app-plus/service/api/index.js +2 -0
- package/src/platforms/app-plus/service/api/location/get-location.js +8 -7
- package/src/platforms/app-plus/service/api/media/choose-image.js +22 -51
- package/src/platforms/app-plus/service/api/media/choose-video.js +19 -36
- package/src/platforms/app-plus/service/api/media/compress-video.js +2 -2
- package/src/platforms/app-plus/service/api/media/get-video-info.js +5 -2
- package/src/platforms/app-plus/service/api/network/request.js +27 -1
- package/src/platforms/app-plus/service/api/network/upload-file.js +1 -1
- package/src/platforms/app-plus/service/api/plugin/oauth.js +140 -8
- package/src/platforms/app-plus/service/api/storage/storage.js +1 -1
- package/src/platforms/app-plus/service/api/ui/popup.js +21 -11
- package/src/platforms/app-plus/service/api/ui/tab-bar.js +3 -2
- package/src/platforms/app-plus/service/api/util.js +5 -1
- package/src/platforms/app-plus/service/framework/app.js +21 -5
- package/src/platforms/app-plus/service/framework/config.js +1 -0
- package/src/platforms/app-plus/service/framework/plugins/index.js +8 -2
- package/src/platforms/app-plus/service/framework/plugins/lifecycle.js +2 -2
- package/src/platforms/app-plus/service/framework/subscribe-handlers/index.js +1 -1
- package/src/platforms/app-plus/service/framework/tab-bar.js +12 -2
- package/src/platforms/app-plus/service/framework/webview/index.js +2 -2
- package/src/platforms/app-plus/service/framework/webview/parser/title-nview-parser.js +73 -30
- package/src/platforms/app-plus/service/framework/webview/parser/webview-style-parser.js +16 -16
- package/src/platforms/app-plus/service/index.js +10 -3
- package/src/platforms/app-plus/service/publish-handler.js +3 -0
- package/src/platforms/app-plus/view/bridge/subscribe/index.js +5 -3
- package/src/platforms/app-plus/view/components/ad/index.vue +53 -44
- package/src/platforms/app-plus/view/components/cover-view/index.vue +13 -7
- package/src/platforms/app-plus/view/components/map/index.vue +29 -27
- package/src/platforms/app-plus/view/components/video/index.vue +40 -24
- package/src/platforms/app-plus/view/framework/plugins/gesture.js +17 -0
- package/src/platforms/app-plus/view/framework/plugins/index.js +3 -1
- package/src/platforms/app-plus/view/index.css +4 -0
- package/src/platforms/app-plus/view/mixins/cover.js +10 -15
- package/src/platforms/app-plus/view/mixins/native.js +45 -3
- package/src/platforms/app-plus-nvue/service/api/context/operate-map-player.js +3 -0
- package/src/platforms/h5/components/app/observable.js +3 -2
- package/src/platforms/h5/components/app/popup/mixins/modal.js +3 -3
- package/src/platforms/h5/components/app/popup/modal.vue +38 -2
- package/src/platforms/h5/components/app/popup/toast.vue +9 -1
- package/src/platforms/h5/components/app/tabBar.vue +39 -17
- package/src/platforms/h5/components/page/index.vue +5 -3
- package/src/platforms/h5/components/page/pageHead.vue +94 -75
- package/src/platforms/h5/components/system-routes/choose-location/index.vue +127 -66
- package/src/platforms/h5/components/system-routes/open-location/index.vue +193 -38
- package/src/platforms/h5/helpers/location.js +26 -0
- package/src/platforms/h5/helpers/todo-api.js +2 -2
- package/src/platforms/h5/service/api/device/clipboard.js +41 -0
- package/src/platforms/h5/service/api/device/get-system-info.js +75 -0
- package/src/platforms/h5/service/api/location/get-location.js +47 -18
- package/src/platforms/h5/service/api/media/MIMEType.js +53 -0
- package/src/platforms/h5/service/api/media/choose-file.js +9 -1
- package/src/platforms/h5/service/api/media/choose-image.js +9 -2
- package/src/platforms/h5/service/api/media/choose-video.js +9 -1
- package/src/platforms/h5/service/api/media/create_input.js +12 -3
- package/src/platforms/h5/service/api/ui/popup.js +3 -5
- package/src/platforms/h5/service/api/ui/tab-bar.js +1 -1
- package/src/platforms/h5/service/index.js +5 -0
- package/src/platforms/h5/view/bridge/subscribe/index.js +3 -2
- package/src/platforms/h5/view/components/ad/index.vue +112 -69
- package/src/platforms/h5/view/components/map/index.vue +96 -349
- package/src/platforms/h5/view/components/map/map-marker.js +287 -0
- package/src/platforms/h5/view/components/map/maps/callout.js +117 -0
- package/src/platforms/h5/view/components/map/maps/index.js +55 -0
- package/src/platforms/h5/view/components/video/index.vue +1 -1
- package/src/platforms/h5/view/index.css +4 -0
- package/src/platforms/mp-alipay/runtime/api/protocols.js +30 -3
- package/src/platforms/mp-baidu/runtime/api/protocols.js +5 -0
- package/src/platforms/mp-baidu/runtime/wrapper/component-parser.js +20 -18
- package/src/platforms/mp-baidu/runtime/wrapper/util.js +2 -1
- package/src/platforms/mp-kuaishou/runtime/api/protocols.js +3 -1
- package/src/platforms/mp-kuaishou/runtime/wrapper/component-parser.js +21 -1
- package/src/platforms/mp-lark/runtime/api/index.js +0 -0
- package/src/platforms/mp-lark/runtime/api/protocols.js +68 -0
- package/src/platforms/mp-lark/runtime/api/providers.js +6 -0
- package/src/platforms/mp-lark/runtime/index.js +1 -0
- package/src/platforms/mp-lark/runtime/web-view.js +11 -0
- package/src/platforms/mp-lark/runtime/wrapper/app-parser.js +33 -0
- package/src/platforms/mp-lark/runtime/wrapper/component-parser.js +50 -0
- package/src/platforms/mp-lark/runtime/wrapper/page-parser.js +39 -0
- package/src/platforms/mp-lark/runtime/wrapper/util.js +64 -0
- package/src/platforms/mp-qq/runtime/api/protocols.js +3 -1
- package/src/platforms/mp-toutiao/runtime/api/protocols.js +2 -0
- package/src/platforms/mp-toutiao/runtime/wrapper/component-parser.js +35 -19
- package/src/platforms/mp-weixin/helpers/get-user-profile.js +6 -0
- package/src/platforms/mp-weixin/runtime/index.js +6 -7
- package/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js +197 -126
- package/src/platforms/mp-weixin/runtime/wrapper/fix-set-data.js +37 -0
- package/src/shared/uni-id-mixin.js +77 -0
- package/src/shared/util.js +2 -0
|
@@ -29,6 +29,9 @@ import {
|
|
|
29
29
|
import {
|
|
30
30
|
initWebviewApi as initKuaishouWebviewApi
|
|
31
31
|
} from 'uni-platforms/mp-kuaishou/runtime/web-view'
|
|
32
|
+
import {
|
|
33
|
+
initWebviewApi as initLarkWebviewApi
|
|
34
|
+
} from 'uni-platforms/mp-lark/runtime/web-view'
|
|
32
35
|
|
|
33
36
|
const UniAppJSBridgeReady = function () {
|
|
34
37
|
window.UniAppJSBridge = true
|
|
@@ -47,6 +50,7 @@ const initWebviewApis = [
|
|
|
47
50
|
initToutiaoWebviewApi,
|
|
48
51
|
initQuickappWebviewApi,
|
|
49
52
|
initKuaishouWebviewApi,
|
|
53
|
+
initLarkWebviewApi,
|
|
50
54
|
initH5WebviewApi
|
|
51
55
|
]
|
|
52
56
|
|
|
@@ -12,6 +12,7 @@ export default function createSubpackageApp (vm) {
|
|
|
12
12
|
const app = getApp({
|
|
13
13
|
allowDefault: true
|
|
14
14
|
})
|
|
15
|
+
vm.$scope = app
|
|
15
16
|
const globalData = app.globalData
|
|
16
17
|
if (globalData) {
|
|
17
18
|
Object.keys(appOptions.globalData).forEach(name => {
|
|
@@ -26,18 +27,18 @@ export default function createSubpackageApp (vm) {
|
|
|
26
27
|
}
|
|
27
28
|
})
|
|
28
29
|
if (isFn(appOptions.onShow) && __GLOBAL__.onAppShow) {
|
|
29
|
-
__GLOBAL__.onAppShow((...args) => {
|
|
30
|
-
|
|
30
|
+
__GLOBAL__.onAppShow((...args) => {
|
|
31
|
+
vm.__call_hook('onShow', args)
|
|
31
32
|
})
|
|
32
33
|
}
|
|
33
34
|
if (isFn(appOptions.onHide) && __GLOBAL__.onAppHide) {
|
|
34
|
-
__GLOBAL__.onAppHide((...args) => {
|
|
35
|
-
|
|
35
|
+
__GLOBAL__.onAppHide((...args) => {
|
|
36
|
+
vm.__call_hook('onHide', args)
|
|
36
37
|
})
|
|
37
38
|
}
|
|
38
39
|
if (isFn(appOptions.onLaunch)) {
|
|
39
40
|
const args = __GLOBAL__.getLaunchOptionsSync && __GLOBAL__.getLaunchOptionsSync()
|
|
40
|
-
|
|
41
|
+
vm.__call_hook('onLaunch', args)
|
|
41
42
|
}
|
|
42
43
|
return vm
|
|
43
|
-
}
|
|
44
|
+
}
|
|
@@ -237,6 +237,11 @@ export function initProperties (props, isBehavior = false, file = '') {
|
|
|
237
237
|
type: Object,
|
|
238
238
|
value: null
|
|
239
239
|
}
|
|
240
|
+
// scopedSlotsCompiler auto
|
|
241
|
+
properties.scopedSlotsCompiler = {
|
|
242
|
+
type: String,
|
|
243
|
+
value: ''
|
|
244
|
+
}
|
|
240
245
|
properties.vueSlots = { // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
|
|
241
246
|
type: null,
|
|
242
247
|
value: [],
|
|
@@ -572,4 +577,4 @@ export function handleEvent (event) {
|
|
|
572
577
|
) {
|
|
573
578
|
return ret[0]
|
|
574
579
|
}
|
|
575
|
-
}
|
|
580
|
+
}
|
|
@@ -231,8 +231,9 @@ function checkColor (e) {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
function Pattern (image, repetition) {
|
|
234
|
-
this.
|
|
235
|
-
this.
|
|
234
|
+
this.type = 'pattern'
|
|
235
|
+
this.data = image
|
|
236
|
+
this.colorStop = repetition
|
|
236
237
|
}
|
|
237
238
|
|
|
238
239
|
class CanvasGradient {
|
|
@@ -39,6 +39,13 @@ export class MapContext {
|
|
|
39
39
|
constructor (id, pageVm) {
|
|
40
40
|
this.id = id
|
|
41
41
|
this.pageVm = pageVm
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
on (name, callback) {
|
|
45
|
+
operateMapPlayer(this.id, this.pageVm, 'on', {
|
|
46
|
+
name,
|
|
47
|
+
callback
|
|
48
|
+
})
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
51
|
|
|
@@ -46,7 +53,7 @@ MapContext.prototype.$getAppMap = function () {
|
|
|
46
53
|
if (__PLATFORM__ === 'app-plus') {
|
|
47
54
|
return plus.maps.getMapById(this.pageVm.$page.id + '-map-' + this.id)
|
|
48
55
|
}
|
|
49
|
-
}
|
|
56
|
+
}
|
|
50
57
|
|
|
51
58
|
methods.forEach(function (method) {
|
|
52
59
|
MapContext.prototype[method] = callback.warp(function (options, callbackId) {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
invoke
|
|
3
|
+
} from 'uni-core/service/bridge'
|
|
4
|
+
import {
|
|
5
|
+
i18n
|
|
6
|
+
} from 'uni-helpers/i18n'
|
|
7
|
+
import {
|
|
8
|
+
DC_LOCALE
|
|
9
|
+
} from 'uni-helpers/constants'
|
|
10
|
+
|
|
11
|
+
export function getLocale () {
|
|
12
|
+
// 优先使用 $locale
|
|
13
|
+
const app = getApp({
|
|
14
|
+
allowDefault: true
|
|
15
|
+
})
|
|
16
|
+
if (app && app.$vm) {
|
|
17
|
+
return app.$vm.$locale
|
|
18
|
+
}
|
|
19
|
+
return i18n.getLocale()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function setLocale (locale) {
|
|
23
|
+
const oldLocale = getApp().$vm.$locale
|
|
24
|
+
if (oldLocale !== locale) {
|
|
25
|
+
getApp().$vm.$locale = locale
|
|
26
|
+
if (__PLATFORM__ === 'app-plus') {
|
|
27
|
+
const pages = getCurrentPages()
|
|
28
|
+
pages.forEach((page) => {
|
|
29
|
+
UniServiceJSBridge.publishHandler(
|
|
30
|
+
'setLocale',
|
|
31
|
+
locale,
|
|
32
|
+
page.$page.id
|
|
33
|
+
)
|
|
34
|
+
})
|
|
35
|
+
weex.requireModule('plus').setLanguage(locale)
|
|
36
|
+
}
|
|
37
|
+
if (__PLATFORM__ === 'h5') {
|
|
38
|
+
window.localStorage && (localStorage[DC_LOCALE] = locale)
|
|
39
|
+
}
|
|
40
|
+
callbacks.forEach(callbackId => {
|
|
41
|
+
invoke(callbackId, { locale })
|
|
42
|
+
})
|
|
43
|
+
return true
|
|
44
|
+
}
|
|
45
|
+
return false
|
|
46
|
+
}
|
|
47
|
+
const callbacks = []
|
|
48
|
+
export function onLocaleChange (callbackId) {
|
|
49
|
+
callbacks.push(callbackId)
|
|
50
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
initAppLocale
|
|
3
|
+
} from 'uni-helpers/i18n'
|
|
4
|
+
|
|
1
5
|
import initRouterGuard from './router-guard'
|
|
2
6
|
|
|
3
7
|
let appVm = false
|
|
@@ -23,7 +27,8 @@ export function getCurrentPages (isAll = false, ignoreError = false) {
|
|
|
23
27
|
childrenVm = layoutVm
|
|
24
28
|
}
|
|
25
29
|
childrenVm.$children.forEach(vm => {
|
|
26
|
-
if (tabBarVm !== vm && vm.$children.length && vm.$children[0].$options.name === 'Page' && vm.$children[0]
|
|
30
|
+
if (tabBarVm !== vm && vm.$children.length && vm.$children[0].$options.name === 'Page' && vm.$children[0]
|
|
31
|
+
.$slots
|
|
27
32
|
.page) {
|
|
28
33
|
// vm.$children[0]=Page->PageBody->RealPage
|
|
29
34
|
const pageBody = vm.$children[0].$children.find(vm => vm.$options.name === 'PageBody')
|
|
@@ -63,11 +68,11 @@ export function getCurrentPages (isAll = false, ignoreError = false) {
|
|
|
63
68
|
return pages
|
|
64
69
|
}
|
|
65
70
|
|
|
66
|
-
export default function createApp (vm, routes) {
|
|
71
|
+
export default function createApp (Vue, vm, routes) {
|
|
67
72
|
appVm = vm
|
|
68
73
|
appVm.$vm = vm
|
|
69
74
|
appVm.globalData = appVm.$options.globalData || {}
|
|
70
|
-
|
|
75
|
+
initAppLocale(Vue, appVm)
|
|
71
76
|
// initEvents(appVm)
|
|
72
77
|
initRouterGuard(appVm, routes)
|
|
73
78
|
}
|
|
@@ -10,10 +10,10 @@ export {
|
|
|
10
10
|
}
|
|
11
11
|
from './create-app'
|
|
12
12
|
|
|
13
|
-
export function createAppMixin (routes, entryRoute) {
|
|
13
|
+
export function createAppMixin (Vue, routes, entryRoute) {
|
|
14
14
|
return {
|
|
15
15
|
created: function AppCreated () {
|
|
16
|
-
createApp(this, routes)
|
|
16
|
+
createApp(Vue, this, routes)
|
|
17
17
|
// TODO
|
|
18
18
|
if (!entryRoute.meta.name) { // PageNotFound
|
|
19
19
|
UniServiceJSBridge.emit('onPageNotFound', {
|
|
@@ -24,6 +24,10 @@ import {
|
|
|
24
24
|
getTabBarScrollPosition
|
|
25
25
|
} from './app/router-guard'
|
|
26
26
|
|
|
27
|
+
import {
|
|
28
|
+
uniIdMixin
|
|
29
|
+
} from 'uni-shared'
|
|
30
|
+
|
|
27
31
|
function getMinId (routes) {
|
|
28
32
|
let minId = 0
|
|
29
33
|
routes.forEach(route => {
|
|
@@ -74,6 +78,8 @@ export default {
|
|
|
74
78
|
|
|
75
79
|
lifecycleMixin(Vue)
|
|
76
80
|
|
|
81
|
+
uniIdMixin(Vue)
|
|
82
|
+
|
|
77
83
|
/* eslint-disable no-undef */
|
|
78
84
|
if (typeof __UNI_ROUTER_BASE__ !== 'undefined') {
|
|
79
85
|
__uniConfig.router.base = __UNI_ROUTER_BASE__
|
|
@@ -141,7 +147,7 @@ export default {
|
|
|
141
147
|
keepAliveInclude
|
|
142
148
|
}
|
|
143
149
|
}
|
|
144
|
-
const appMixin = createAppMixin(routes, entryRoute)
|
|
150
|
+
const appMixin = createAppMixin(Vue, routes, entryRoute)
|
|
145
151
|
// mixin app hooks
|
|
146
152
|
Object.keys(appMixin).forEach(hook => {
|
|
147
153
|
options[hook] = options[hook] ? [].concat(appMixin[hook], options[hook]) : [
|
|
@@ -201,4 +207,4 @@ export default {
|
|
|
201
207
|
Vue.use(VueRouter)
|
|
202
208
|
}
|
|
203
209
|
|
|
204
|
-
}
|
|
210
|
+
}
|
|
@@ -19,6 +19,21 @@ function getRect (rect) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
// 在相交比很小的情况下,Chrome会返回相交为0
|
|
23
|
+
function rectifyIntersectionRatio (entrie) {
|
|
24
|
+
const {
|
|
25
|
+
intersectionRatio,
|
|
26
|
+
boundingClientRect: { height: overAllHeight, width: overAllWidth },
|
|
27
|
+
intersectionRect: { height: intersectionHeight, width: intersectionWidth }
|
|
28
|
+
} = entrie
|
|
29
|
+
|
|
30
|
+
if (intersectionRatio !== 0) return intersectionRatio
|
|
31
|
+
|
|
32
|
+
return intersectionHeight === overAllHeight
|
|
33
|
+
? intersectionWidth / overAllWidth
|
|
34
|
+
: intersectionHeight / overAllHeight
|
|
35
|
+
}
|
|
36
|
+
|
|
22
37
|
const intersectionObservers = {}
|
|
23
38
|
|
|
24
39
|
export function requestComponentObserver ({
|
|
@@ -44,7 +59,7 @@ export function requestComponentObserver ({
|
|
|
44
59
|
UniViewJSBridge.publishHandler('onRequestComponentObserver', {
|
|
45
60
|
reqId,
|
|
46
61
|
res: {
|
|
47
|
-
intersectionRatio: entrie
|
|
62
|
+
intersectionRatio: rectifyIntersectionRatio(entrie),
|
|
48
63
|
intersectionRect: getRect(entrie.intersectionRect),
|
|
49
64
|
boundingClientRect: getRect(entrie.boundingClientRect),
|
|
50
65
|
relativeRect: getRect(entrie.rootBounds),
|
|
@@ -133,8 +133,10 @@ export default {
|
|
|
133
133
|
method(data)
|
|
134
134
|
}
|
|
135
135
|
},
|
|
136
|
-
_resize () {
|
|
136
|
+
_resize (size) {
|
|
137
137
|
var canvas = this.$refs.canvas
|
|
138
|
+
var hasChanged = !size || (canvas.width !== Math.floor(size.width * pixelRatio) || canvas.height !== Math.floor(size.height * pixelRatio))
|
|
139
|
+
if (!hasChanged) return
|
|
138
140
|
if (canvas.width > 0 && canvas.height > 0) {
|
|
139
141
|
var context = canvas.getContext('2d')
|
|
140
142
|
var imageData = context.getImageData(0, 0, canvas.width, canvas.height)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import getRealPath from 'uni-platform/helpers/get-real-path'
|
|
2
|
+
|
|
1
3
|
export default function (Quill) {
|
|
2
4
|
const Image = Quill.import('formats/image')
|
|
3
5
|
const ATTRIBUTES = [
|
|
@@ -8,7 +10,7 @@ export default function (Quill) {
|
|
|
8
10
|
'class',
|
|
9
11
|
'data-local'
|
|
10
12
|
]
|
|
11
|
-
Image.sanitize = url => url
|
|
13
|
+
Image.sanitize = url => url ? getRealPath(url) : url
|
|
12
14
|
Image.formats = function formats (domNode) {
|
|
13
15
|
return ATTRIBUTES.reduce(function (formats, attribute) {
|
|
14
16
|
if (domNode.hasAttribute(attribute)) {
|
|
@@ -8,6 +8,7 @@ import box from './box'
|
|
|
8
8
|
import font from './font'
|
|
9
9
|
import text from './text'
|
|
10
10
|
import image from './image'
|
|
11
|
+
import link from './link'
|
|
11
12
|
|
|
12
13
|
export function register (Quill) {
|
|
13
14
|
const formats = {
|
|
@@ -20,7 +21,8 @@ export function register (Quill) {
|
|
|
20
21
|
box,
|
|
21
22
|
font,
|
|
22
23
|
text,
|
|
23
|
-
image
|
|
24
|
+
image,
|
|
25
|
+
link
|
|
24
26
|
}
|
|
25
27
|
const options = {}
|
|
26
28
|
Object.values(formats).forEach(value => Object.assign(options, value(Quill)))
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default function (Quill) {
|
|
2
|
+
const Link = Quill.import('formats/link')
|
|
3
|
+
Link.sanitize = url => {
|
|
4
|
+
const anchor = document.createElement('a')
|
|
5
|
+
anchor.href = url
|
|
6
|
+
const protocol = anchor.href.slice(0, anchor.href.indexOf(':'))
|
|
7
|
+
return Link.PROTOCOL_WHITELIST.concat('file').indexOf(protocol) > -1 ? url : Link.SANITIZED_URL
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -16,6 +16,20 @@ import HTMLParser from 'uni-helpers/html-parser'
|
|
|
16
16
|
import * as formats from './formats'
|
|
17
17
|
import loadScript from './load-script'
|
|
18
18
|
|
|
19
|
+
function isiOS () {
|
|
20
|
+
if (__PLATFORM__ === 'app-plus') {
|
|
21
|
+
return plus.os.name.toLowerCase() === 'ios'
|
|
22
|
+
} else if (__PLATFORM__ === 'h5') {
|
|
23
|
+
const ua = navigator.userAgent
|
|
24
|
+
const isIOS = /iphone|ipad|ipod/i.test(ua)
|
|
25
|
+
const isMac = /Macintosh|Mac/i.test(ua)
|
|
26
|
+
const isIPadOS = isMac && navigator.maxTouchPoints > 0
|
|
27
|
+
return isIOS || isIPadOS
|
|
28
|
+
}
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let textChanging = false
|
|
19
33
|
export default {
|
|
20
34
|
name: 'Editor',
|
|
21
35
|
mixins: [subscriber, emitter, keyboard],
|
|
@@ -64,7 +78,7 @@ export default {
|
|
|
64
78
|
},
|
|
65
79
|
placeholder (value) {
|
|
66
80
|
if (this.quillReady) {
|
|
67
|
-
this.
|
|
81
|
+
this.setPlaceHolder(value)
|
|
68
82
|
}
|
|
69
83
|
}
|
|
70
84
|
},
|
|
@@ -149,11 +163,14 @@ export default {
|
|
|
149
163
|
const path = this.$getRealPath(src)
|
|
150
164
|
quill.insertEmbed(range.index, 'image', path, Quill.sources.USER)
|
|
151
165
|
const local = /^(file|blob):/.test(path) ? path : false
|
|
166
|
+
// 防止 formatText 多次触发 Quill.events.TEXT_CHANGE 事件
|
|
167
|
+
textChanging = true
|
|
152
168
|
quill.formatText(range.index, 1, 'data-local', local)
|
|
153
169
|
quill.formatText(range.index, 1, 'alt', alt)
|
|
154
170
|
quill.formatText(range.index, 1, 'width', width)
|
|
155
171
|
quill.formatText(range.index, 1, 'height', height)
|
|
156
172
|
quill.formatText(range.index, 1, 'class', extClass)
|
|
173
|
+
textChanging = false
|
|
157
174
|
quill.formatText(range.index, 1, 'data-custom', Object.keys(data).map(key => `${key}=${data[key]}`).join('&'))
|
|
158
175
|
quill.setSelection(range.index + 1, Quill.sources.SILENT)
|
|
159
176
|
}
|
|
@@ -234,6 +251,11 @@ export default {
|
|
|
234
251
|
}, this.$page.id)
|
|
235
252
|
}
|
|
236
253
|
},
|
|
254
|
+
setPlaceHolder (value) {
|
|
255
|
+
const placeHolderAttrName = 'data-placeholder'
|
|
256
|
+
const QuillRoot = this.quill.root
|
|
257
|
+
QuillRoot.getAttribute(placeHolderAttrName) !== value && QuillRoot.setAttribute(placeHolderAttrName, value)
|
|
258
|
+
},
|
|
237
259
|
initQuill (imageResizeModules) {
|
|
238
260
|
const Quill = window.Quill
|
|
239
261
|
formats.register(Quill)
|
|
@@ -254,15 +276,23 @@ export default {
|
|
|
254
276
|
const events = ['focus', 'blur', 'input']
|
|
255
277
|
events.forEach(name => {
|
|
256
278
|
$el.addEventListener(name, ($event) => {
|
|
279
|
+
const contents = this.getContents()
|
|
257
280
|
if (name === 'input') {
|
|
281
|
+
if (isiOS()) {
|
|
282
|
+
const regExpContent = (contents.html.match(/<span [\s\S]*>([\s\S]*)<\/span>/) || [])[1]
|
|
283
|
+
const placeholder = regExpContent && regExpContent.replace(/\s/g, '') ? '' : this.placeholder
|
|
284
|
+
this.setPlaceHolder(placeholder)
|
|
285
|
+
}
|
|
258
286
|
$event.stopPropagation()
|
|
259
287
|
} else {
|
|
260
|
-
this.$trigger(name, $event,
|
|
288
|
+
this.$trigger(name, $event, contents)
|
|
261
289
|
}
|
|
262
290
|
})
|
|
263
291
|
})
|
|
264
292
|
quill.on(Quill.events.TEXT_CHANGE, () => {
|
|
265
|
-
|
|
293
|
+
if (!textChanging) {
|
|
294
|
+
this.$trigger('input', {}, this.getContents())
|
|
295
|
+
}
|
|
266
296
|
})
|
|
267
297
|
quill.on(Quill.events.SELECTION_CHANGE, this.updateStatus.bind(this))
|
|
268
298
|
quill.on(Quill.events.SCROLL_OPTIMIZE, () => {
|
|
@@ -142,14 +142,13 @@ export default {
|
|
|
142
142
|
_fixSize () {
|
|
143
143
|
if (this.ratio) {
|
|
144
144
|
const $el = this.$el
|
|
145
|
-
const rect = $el.getBoundingClientRect()
|
|
146
145
|
if (this.mode === 'widthFix') {
|
|
147
|
-
const width =
|
|
146
|
+
const width = $el.offsetWidth
|
|
148
147
|
if (width) {
|
|
149
148
|
$el.style.height = fixNumber(width / this.ratio) + 'px'
|
|
150
149
|
}
|
|
151
150
|
} else if (this.mode === 'heightFix') {
|
|
152
|
-
const height =
|
|
151
|
+
const height = $el.offsetHeight
|
|
153
152
|
if (height) {
|
|
154
153
|
$el.style.width = fixNumber(height * this.ratio) + 'px'
|
|
155
154
|
}
|
|
@@ -196,9 +195,9 @@ export default {
|
|
|
196
195
|
img.src = realImagePath
|
|
197
196
|
} else {
|
|
198
197
|
this._clearImage()
|
|
198
|
+
this._resetData()
|
|
199
199
|
// 与微信小程序保持一致,保留之前样式
|
|
200
|
-
// this.
|
|
201
|
-
this._resetSize()
|
|
200
|
+
// this._resetSize()
|
|
202
201
|
}
|
|
203
202
|
},
|
|
204
203
|
_clearImage () {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
class="uni-input-wrapper"
|
|
6
6
|
>
|
|
7
7
|
<div
|
|
8
|
-
v-show="!(composing || valueSync.length ||
|
|
8
|
+
v-show="!(composing || valueSync.length || cachedValue === '-')"
|
|
9
9
|
ref="placeholder"
|
|
10
10
|
:style="placeholderStyle"
|
|
11
11
|
:class="placeholderClass"
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
:maxlength="maxlength"
|
|
24
24
|
:step="step"
|
|
25
25
|
:enterkeyhint="confirmType"
|
|
26
|
+
:pattern="type === 'number' ? '[0-9]*' : null"
|
|
26
27
|
class="uni-input-input"
|
|
27
|
-
autocomplete="
|
|
28
|
+
:autocomplete="autocomplete"
|
|
28
29
|
@change.stop
|
|
29
30
|
@focus="_onFocus"
|
|
30
31
|
@blur="_onBlur"
|
|
@@ -53,8 +54,10 @@
|
|
|
53
54
|
import {
|
|
54
55
|
field
|
|
55
56
|
} from 'uni-mixins'
|
|
56
|
-
|
|
57
|
+
import { kebabCase } from 'uni-shared'
|
|
58
|
+
const INPUT_TYPES = ['text', 'number', 'idcard', 'digit', 'password', 'tel']
|
|
57
59
|
const NUMBER_TYPES = ['number', 'digit']
|
|
60
|
+
const AUTOCOMPLETES = ['off', 'one-time-code']
|
|
58
61
|
export default {
|
|
59
62
|
name: 'Input',
|
|
60
63
|
mixins: [field],
|
|
@@ -94,11 +97,14 @@ export default {
|
|
|
94
97
|
confirmType: {
|
|
95
98
|
type: String,
|
|
96
99
|
default: 'done'
|
|
100
|
+
},
|
|
101
|
+
textContentType: {
|
|
102
|
+
type: String,
|
|
103
|
+
default: ''
|
|
97
104
|
}
|
|
98
105
|
},
|
|
99
106
|
data () {
|
|
100
107
|
return {
|
|
101
|
-
valid: true,
|
|
102
108
|
wrapperHeight: 0,
|
|
103
109
|
cachedValue: ''
|
|
104
110
|
}
|
|
@@ -126,6 +132,16 @@ export default {
|
|
|
126
132
|
step () {
|
|
127
133
|
// 处理部分设备中无法输入小数点的问题
|
|
128
134
|
return ~NUMBER_TYPES.indexOf(this.type) ? '0.000000000000000001' : ''
|
|
135
|
+
},
|
|
136
|
+
autocomplete () {
|
|
137
|
+
const camelizeIndex = AUTOCOMPLETES.indexOf(this.textContentType)
|
|
138
|
+
const kebabCaseIndex = AUTOCOMPLETES.indexOf(kebabCase(this.textContentType))
|
|
139
|
+
const index = camelizeIndex !== -1
|
|
140
|
+
? camelizeIndex
|
|
141
|
+
: kebabCaseIndex !== -1
|
|
142
|
+
? kebabCaseIndex
|
|
143
|
+
: 0
|
|
144
|
+
return AUTOCOMPLETES[index]
|
|
129
145
|
}
|
|
130
146
|
},
|
|
131
147
|
watch: {
|
|
@@ -174,37 +190,48 @@ export default {
|
|
|
174
190
|
})
|
|
175
191
|
},
|
|
176
192
|
_onInput ($event, force) {
|
|
193
|
+
let outOfMaxlength = false
|
|
194
|
+
|
|
177
195
|
if (this.composing) {
|
|
178
196
|
return
|
|
179
197
|
}
|
|
180
198
|
|
|
181
|
-
if (
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
|
|
199
|
+
if (this.inputType === 'number') {
|
|
200
|
+
// type="number" 不支持 maxlength 属性,因此需要主动限制长度。
|
|
201
|
+
const maxlength = parseInt(this.maxlength, 10)
|
|
202
|
+
if (maxlength > 0 && $event.target.value.length > maxlength) {
|
|
203
|
+
// 输入前字符长度超出范围,则不触发input,且将值还原
|
|
204
|
+
// 否则截取一定长度且触发input
|
|
205
|
+
if (this.cachedValue.length === maxlength) {
|
|
206
|
+
this.valueSync = this.cachedValue
|
|
207
|
+
outOfMaxlength = true
|
|
208
|
+
} else {
|
|
209
|
+
$event.target.value = $event.target.value.slice(0, maxlength)
|
|
210
|
+
this.valueSync = $event.target.value
|
|
211
|
+
}
|
|
212
|
+
}
|
|
185
213
|
|
|
186
|
-
//
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
$event.
|
|
190
|
-
|
|
214
|
+
// 数字类型输入错误时无法获取具体的值,自定义校验和纠正。
|
|
215
|
+
this.__clearCachedValue && $event.target.removeEventListener('blur', this.__clearCachedValue)
|
|
216
|
+
if ($event.target.validity && !$event.target.validity.valid) {
|
|
217
|
+
if ((!this.cachedValue && $event.data === '-') || (this.cachedValue[0] === '-' && $event.inputType === 'deleteContentBackward')) {
|
|
218
|
+
this.cachedValue = '-'
|
|
219
|
+
const clearCachedValue = this.__clearCachedValue = () => {
|
|
220
|
+
this.cachedValue = ''
|
|
221
|
+
}
|
|
222
|
+
$event.target.addEventListener('blur', clearCachedValue)
|
|
223
|
+
return
|
|
224
|
+
}
|
|
225
|
+
this.cachedValue = this.valueSync = $event.target.value = this.cachedValue === '-' ? '' : this.cachedValue
|
|
191
226
|
// 输入非法字符不触发 input 事件
|
|
192
227
|
return
|
|
193
228
|
} else {
|
|
194
229
|
this.cachedValue = this.valueSync
|
|
195
|
-
} */
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// type="number" 不支持 maxlength 属性,因此需要主动限制长度。
|
|
199
|
-
if (this.inputType === 'number') {
|
|
200
|
-
const maxlength = parseInt(this.maxlength, 10)
|
|
201
|
-
if (maxlength > 0 && $event.target.value.length > maxlength) {
|
|
202
|
-
$event.target.value = $event.target.value.slice(0, maxlength)
|
|
203
|
-
this.valueSync = $event.target.value
|
|
204
|
-
// 字符长度超出范围不触发 input 事件
|
|
205
|
-
return
|
|
206
230
|
}
|
|
207
231
|
}
|
|
232
|
+
|
|
233
|
+
if (outOfMaxlength) return
|
|
234
|
+
|
|
208
235
|
this.$triggerInput($event, {
|
|
209
236
|
value: this.valueSync
|
|
210
237
|
}, force)
|
|
@@ -299,7 +326,8 @@ uni-input[hidden] {
|
|
|
299
326
|
text-shadow: inherit;
|
|
300
327
|
}
|
|
301
328
|
|
|
302
|
-
.uni-input-input[type="search"]::-webkit-search-cancel-button
|
|
329
|
+
.uni-input-input[type="search"]::-webkit-search-cancel-button,
|
|
330
|
+
.uni-input-input[type="search"]::-webkit-search-decoration {
|
|
303
331
|
display: none;
|
|
304
332
|
}
|
|
305
333
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<uni-progress
|
|
3
|
-
class="uni-progress"
|
|
4
|
-
v-on="$listeners"
|
|
2
|
+
<uni-progress
|
|
3
|
+
class="uni-progress"
|
|
4
|
+
v-on="$listeners"
|
|
5
5
|
>
|
|
6
|
-
<div
|
|
7
|
-
:style="outerBarStyle"
|
|
8
|
-
class="uni-progress-bar"
|
|
6
|
+
<div
|
|
7
|
+
:style="outerBarStyle"
|
|
8
|
+
class="uni-progress-bar"
|
|
9
9
|
>
|
|
10
|
-
<div
|
|
11
|
-
:style="innerBarStyle"
|
|
12
|
-
class="uni-progress-inner-bar"
|
|
10
|
+
<div
|
|
11
|
+
:style="innerBarStyle"
|
|
12
|
+
class="uni-progress-inner-bar"
|
|
13
13
|
/>
|
|
14
14
|
</div>
|
|
15
15
|
<template v-if="showInfo">
|
|
16
|
-
<p class="uni-progress-info">
|
|
17
|
-
{{ currentPercent }}%
|
|
16
|
+
<p class="uni-progress-info">
|
|
17
|
+
{{ currentPercent }}%
|
|
18
18
|
</p>
|
|
19
19
|
</template>
|
|
20
20
|
</uni-progress>
|
|
@@ -65,6 +65,13 @@ export default {
|
|
|
65
65
|
activeMode: {
|
|
66
66
|
type: String,
|
|
67
67
|
default: VALUES.activeMode
|
|
68
|
+
},
|
|
69
|
+
duration: {
|
|
70
|
+
type: [Number, String],
|
|
71
|
+
default: 30,
|
|
72
|
+
validator (value) {
|
|
73
|
+
return !isNaN(parseFloat(value, 10))
|
|
74
|
+
}
|
|
68
75
|
}
|
|
69
76
|
},
|
|
70
77
|
data () {
|
|
@@ -117,7 +124,7 @@ export default {
|
|
|
117
124
|
} else {
|
|
118
125
|
this.currentPercent += 1
|
|
119
126
|
}
|
|
120
|
-
},
|
|
127
|
+
}, parseFloat(this.duration))
|
|
121
128
|
} else {
|
|
122
129
|
this.currentPercent = this.realPercent
|
|
123
130
|
}
|
|
@@ -154,4 +161,4 @@ export default {
|
|
|
154
161
|
margin-left: 15px;
|
|
155
162
|
font-size: 16px;
|
|
156
163
|
}
|
|
157
|
-
</style>
|
|
164
|
+
</style>
|