зеркало из https://github.com/nextcloud/text.git
Move to @nextcloud packages
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Родитель
b6a2f9c87d
Коммит
5eb7b205b3
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -23,12 +23,11 @@
|
|||
"test:coverage": "NODE_ENV=test jest --coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nextcloud/axios": "^0.5.0",
|
||||
"@nextcloud/router": "^0.1.0",
|
||||
"escape-html": "^1.0.3",
|
||||
"highlight.js": "^9.15.10",
|
||||
"markdown-it": "^8.4.2",
|
||||
"nextcloud-axios": "^0.2.1",
|
||||
"nextcloud-server": "^0.15.10",
|
||||
"nextcloud-vue": "^0.12.7",
|
||||
"prosemirror-collab": "^1.1.2",
|
||||
"prosemirror-markdown": "^1.3.1",
|
||||
|
@ -52,7 +51,6 @@
|
|||
"@babel/plugin-transform-runtime": "^7.6.2",
|
||||
"@babel/polyfill": "^7.6.0",
|
||||
"@babel/preset-env": "^7.6.3",
|
||||
"@nextcloud/axios": "^0.5.0",
|
||||
"@vue/test-utils": "^1.0.0-beta.29",
|
||||
"acorn": "^7.1.0",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
|
|
|
@ -33,7 +33,7 @@ import {
|
|||
CodeBlockHighlight,
|
||||
HorizontalRule,
|
||||
History,
|
||||
Placeholder
|
||||
Placeholder,
|
||||
} from 'tiptap-extensions'
|
||||
import { Strong, Italic, Strike } from './marks'
|
||||
import { Image, PlainTextDocument } from './nodes'
|
||||
|
@ -80,16 +80,16 @@ const createEditor = ({ content, onInit, onUpdate, extensions, enableRichEditing
|
|||
new Placeholder({
|
||||
emptyNodeClass: 'is-empty',
|
||||
emptyNodeText: 'Add notes, lists or links …',
|
||||
showOnlyWhenEditable: true
|
||||
})
|
||||
showOnlyWhenEditable: true,
|
||||
}),
|
||||
]
|
||||
} else {
|
||||
richEditingExtensions = [
|
||||
new PlainTextDocument(),
|
||||
new Text(),
|
||||
new CodeBlockHighlight({
|
||||
...languages
|
||||
})
|
||||
...languages,
|
||||
}),
|
||||
]
|
||||
}
|
||||
extensions = extensions || []
|
||||
|
@ -99,9 +99,9 @@ const createEditor = ({ content, onInit, onUpdate, extensions, enableRichEditing
|
|||
onUpdate: onUpdate,
|
||||
extensions: [
|
||||
...richEditingExtensions,
|
||||
new History()
|
||||
new History(),
|
||||
].concat(extensions),
|
||||
useBuiltInExtensions: enableRichEditing
|
||||
useBuiltInExtensions: enableRichEditing,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ const createMarkdownSerializer = (_nodes, _marks) => {
|
|||
.filter(([, node]) => node.toMarkdown)
|
||||
.reduce((items, [name, { toMarkdown }]) => ({
|
||||
...items,
|
||||
[name]: toMarkdown
|
||||
[name]: toMarkdown,
|
||||
}), {})
|
||||
|
||||
const marks = Object
|
||||
|
@ -125,7 +125,7 @@ const createMarkdownSerializer = (_nodes, _marks) => {
|
|||
.filter(([, node]) => node.toMarkdown)
|
||||
.reduce((items, [name, { toMarkdown }]) => ({
|
||||
...items,
|
||||
[name]: toMarkdown
|
||||
[name]: toMarkdown,
|
||||
}), {})
|
||||
return {
|
||||
serializer: new MarkdownSerializer(
|
||||
|
@ -135,7 +135,7 @@ const createMarkdownSerializer = (_nodes, _marks) => {
|
|||
serialize: function(content, options) {
|
||||
return this.serializer.serialize(content, { ...options, tightLists: true }).split('\\[ \\]').join('[ ]')
|
||||
.split('\\[x\\]').join('[x]')
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
name: 'CollisionResolveDialog'
|
||||
name: 'CollisionResolveDialog',
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -89,34 +89,34 @@ export default {
|
|||
ReadOnlyEditor: () => import(/* webpackChunkName: "editor" */'./ReadOnlyEditor'),
|
||||
CollisionResolveDialog: () => import(/* webpackChunkName: "editor" */'./CollisionResolveDialog'),
|
||||
GuestNameDialog: () => import(/* webpackChunkName: "editor-guest" */'./GuestNameDialog'),
|
||||
SessionList: () => import(/* webpackChunkName: "editor-collab" */'./SessionList')
|
||||
SessionList: () => import(/* webpackChunkName: "editor-collab" */'./SessionList'),
|
||||
},
|
||||
directives: {
|
||||
Tooltip
|
||||
Tooltip,
|
||||
},
|
||||
mixins: [
|
||||
isMobile
|
||||
isMobile,
|
||||
],
|
||||
props: {
|
||||
relativePath: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
fileId: {
|
||||
type: Number,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
active: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
autofocus: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
default: true,
|
||||
},
|
||||
shareToken: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
mime: {
|
||||
type: String,
|
||||
|
@ -147,7 +147,7 @@ export default {
|
|||
readOnly: true,
|
||||
forceRecreate: false,
|
||||
|
||||
saveStatusPolling: null
|
||||
saveStatusPolling: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -202,12 +202,12 @@ export default {
|
|||
},
|
||||
fileExtension() {
|
||||
return this.relativePath ? this.relativePath.split('/').pop().split('.').pop() : 'txt'
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
lastSavedStatus: function() {
|
||||
this.$refs.menubar && this.$refs.menubar.redrawMenuBar()
|
||||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
if (this.active && (this.hasDocumentParameters)) {
|
||||
|
@ -260,7 +260,7 @@ export default {
|
|||
console.debug('serialized document', { file })
|
||||
return file
|
||||
|
||||
}
|
||||
},
|
||||
})
|
||||
.on('opened', ({ document, session }) => {
|
||||
this.currentSession = session
|
||||
|
@ -304,17 +304,17 @@ export default {
|
|||
if (this.syncService) {
|
||||
this.syncService.sendSteps()
|
||||
}
|
||||
}
|
||||
},
|
||||
}),
|
||||
new Keymap({
|
||||
'Ctrl-s': () => {
|
||||
this.syncService.save()
|
||||
return true
|
||||
}
|
||||
})
|
||||
},
|
||||
}),
|
||||
],
|
||||
enableRichEditing: this.isRichEditor,
|
||||
languages
|
||||
languages,
|
||||
})
|
||||
this.syncService.state = this.tiptap.state
|
||||
})
|
||||
|
@ -324,7 +324,7 @@ export default {
|
|||
try {
|
||||
this.tiptap.extensions.options.collaboration.update({
|
||||
version: document.currentVersion,
|
||||
steps: steps
|
||||
steps: steps,
|
||||
})
|
||||
this.syncService.state = this.tiptap.state
|
||||
this.updateLastSavedStatus()
|
||||
|
@ -340,7 +340,7 @@ export default {
|
|||
this.initialLoading = true
|
||||
this.syncError = {
|
||||
type: error,
|
||||
data: data
|
||||
data: data,
|
||||
}
|
||||
}
|
||||
if (error === ERROR_TYPE.CONNECTION_FAILED && !this.hasConnectionIssue) {
|
||||
|
@ -369,7 +369,7 @@ export default {
|
|||
})
|
||||
this.syncService.open({
|
||||
fileId: this.fileId,
|
||||
filePath: this.relativePath
|
||||
filePath: this.relativePath,
|
||||
}).catch((e) => {
|
||||
this.hasConnectionIssue = true
|
||||
})
|
||||
|
@ -435,8 +435,8 @@ export default {
|
|||
event.stopPropagation()
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -32,35 +32,35 @@
|
|||
export default {
|
||||
name: 'FilesEditor',
|
||||
components: {
|
||||
EditorWrapper: () => import(/* webpackChunkName: "editor" */'./EditorWrapper')
|
||||
EditorWrapper: () => import(/* webpackChunkName: "editor" */'./EditorWrapper'),
|
||||
},
|
||||
props: {
|
||||
davPath: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
fileId: {
|
||||
type: Number,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
active: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
shareToken: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
mime: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
beforeMount() {
|
||||
// FIXME Dirty fix to avoid recreating the component on stable16
|
||||
if (typeof this.$parent.$parent !== 'undefined' && this.$parent.$parent.onResize) {
|
||||
window.removeEventListener('resize', this.$parent.$parent.onResize)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -35,21 +35,21 @@ import Avatar from 'nextcloud-vue/dist/Components/Avatar'
|
|||
export default {
|
||||
name: 'GuestNameDialog',
|
||||
components: {
|
||||
Avatar
|
||||
Avatar,
|
||||
},
|
||||
directives: {
|
||||
tooltip: Tooltip
|
||||
tooltip: Tooltip,
|
||||
},
|
||||
props: {
|
||||
syncService: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
guestName: '',
|
||||
guestNameBuffered: ''
|
||||
guestNameBuffered: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -59,10 +59,10 @@ export default {
|
|||
'/avatar/guest/{user}/{size}',
|
||||
{
|
||||
user: this.guestNameBuffered,
|
||||
size: size
|
||||
size: size,
|
||||
})
|
||||
return window.location.protocol + '//' + window.location.host + avatarUrl
|
||||
}
|
||||
},
|
||||
},
|
||||
beforeMount() {
|
||||
this.guestName = this.syncService.session.guestName
|
||||
|
@ -80,8 +80,8 @@ export default {
|
|||
},
|
||||
updateBufferedGuestName() {
|
||||
this.guestNameBuffered = this.guestName
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -88,17 +88,17 @@ export default {
|
|||
EditorMenuBar,
|
||||
ActionButton,
|
||||
PopoverMenu,
|
||||
Actions
|
||||
Actions,
|
||||
},
|
||||
directives: {
|
||||
Tooltip,
|
||||
ClickOutside
|
||||
ClickOutside,
|
||||
},
|
||||
props: {
|
||||
editor: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
isRichEditor: {
|
||||
type: Boolean,
|
||||
|
@ -115,7 +115,7 @@ export default {
|
|||
windowHeight: 0,
|
||||
forceRecompute: 0,
|
||||
submenuVisibility: {},
|
||||
icons: [...menuBarIcons]
|
||||
icons: [...menuBarIcons],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -128,7 +128,7 @@ export default {
|
|||
getIconClasses() {
|
||||
return (isActive, icon) => {
|
||||
const classes = {
|
||||
'is-active': icon.isActive(isActive)
|
||||
'is-active': icon.isActive(isActive),
|
||||
}
|
||||
classes[icon.class] = true
|
||||
return classes
|
||||
|
@ -150,7 +150,7 @@ export default {
|
|||
},
|
||||
action: (commands) => {
|
||||
this.showImagePrompt(commands.image)
|
||||
}
|
||||
},
|
||||
}]
|
||||
},
|
||||
childPopoverMenu() {
|
||||
|
@ -164,7 +164,7 @@ export default {
|
|||
icons[index].action(commands)
|
||||
this.hideChildMenu(parent)
|
||||
},
|
||||
active: icons[index].isActive(isActive)
|
||||
active: icons[index].isActive(isActive),
|
||||
})
|
||||
}
|
||||
return popoverMenuItems
|
||||
|
@ -187,7 +187,7 @@ export default {
|
|||
const menuBarWidth = this.$refs.menubar && this.$refs.menubar.clientWidth > 100 ? this.$refs.menubar.clientWidth : this.windowWidth - 200
|
||||
const iconCount = Math.max((Math.floor(menuBarWidth / 44) - 2), 0)
|
||||
return iconCount
|
||||
}
|
||||
},
|
||||
},
|
||||
beforeMount() {
|
||||
this.redrawMenuBar()
|
||||
|
@ -238,7 +238,7 @@ export default {
|
|||
const appendMeta = {
|
||||
mimetype: fileInfo.mimetype,
|
||||
hasPreview: fileInfo.hasPreview,
|
||||
fileId: fileInfo.id
|
||||
fileId: fileInfo.id,
|
||||
}
|
||||
const src = (fileInfo.hasPreview ? previewUrl : internalLink)
|
||||
+ '#'
|
||||
|
@ -246,12 +246,12 @@ export default {
|
|||
|
||||
_command({
|
||||
src: src,
|
||||
alt: fileInfo.name
|
||||
alt: fileInfo.name,
|
||||
})
|
||||
})
|
||||
}, false, [], true)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -56,22 +56,22 @@ import Tooltip from 'nextcloud-vue/dist/Directives/Tooltip'
|
|||
export default {
|
||||
name: 'MenuBubble',
|
||||
components: {
|
||||
EditorMenuBubble
|
||||
EditorMenuBubble,
|
||||
},
|
||||
directives: {
|
||||
tooltip: Tooltip
|
||||
tooltip: Tooltip,
|
||||
},
|
||||
props: {
|
||||
editor: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: null
|
||||
}
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
data: () => {
|
||||
return {
|
||||
linkUrl: null,
|
||||
linkMenuIsActive: false
|
||||
linkMenuIsActive: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -93,8 +93,8 @@ export default {
|
|||
}
|
||||
command({ href: url })
|
||||
this.hideLinkMenu()
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -37,39 +37,39 @@ export default {
|
|||
name: 'PublicFilesEditor',
|
||||
components: {
|
||||
Modal,
|
||||
EditorWrapper: () => import(/* webpackChunkName: "editor" */'./EditorWrapper')
|
||||
EditorWrapper: () => import(/* webpackChunkName: "editor" */'./EditorWrapper'),
|
||||
},
|
||||
props: {
|
||||
fileId: {
|
||||
type: Number,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
relativePath: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
active: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
shareToken: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
mimeType: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
fileName() {
|
||||
return this.relativePath.substring(this.relativePath.lastIndexOf('/') + 1)
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
close() {
|
||||
this.active = false
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -35,28 +35,28 @@ export default {
|
|||
props: {
|
||||
content: {
|
||||
type: String,
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
isRichEditor: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
data: () => {
|
||||
return {
|
||||
editor: null
|
||||
editor: null,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.editor = createEditor({
|
||||
content: this.isRichEditor ? markdownit.render(this.content) : '<pre>' + escapeHtml(this.content) + '</pre>',
|
||||
enableRichEditing: this.isRichEditor
|
||||
enableRichEditing: this.isRichEditor,
|
||||
})
|
||||
this.editor.setOptions({ editable: false })
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.editor.destroy()
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -50,21 +50,21 @@ export default {
|
|||
name: 'SessionList',
|
||||
components: {
|
||||
Avatar,
|
||||
PopoverMenu
|
||||
PopoverMenu,
|
||||
},
|
||||
directives: {
|
||||
tooltip: Tooltip
|
||||
tooltip: Tooltip,
|
||||
},
|
||||
props: {
|
||||
sessions: {
|
||||
type: Object,
|
||||
default: () => { return {} }
|
||||
}
|
||||
default: () => { return {} },
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
popoverVisible: '',
|
||||
myName: ''
|
||||
myName: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -85,7 +85,7 @@ export default {
|
|||
guest ? '/avatar/guest/{user}/{size}' : '/avatar/{user}/{size}',
|
||||
{
|
||||
user: user,
|
||||
size: size
|
||||
size: size,
|
||||
})
|
||||
return window.location.protocol + '//' + window.location.host + avatarUrl
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ export default {
|
|||
sessionStyle() {
|
||||
return (session) => {
|
||||
return {
|
||||
'opacity': session.lastContact > Date.now() / 1000 - COLLABORATOR_IDLE_TIME ? 1 : 0.5
|
||||
'opacity': session.lastContact > Date.now() / 1000 - COLLABORATOR_IDLE_TIME ? 1 : 0.5,
|
||||
// 'border-color': session.color
|
||||
}
|
||||
}
|
||||
|
@ -111,14 +111,14 @@ export default {
|
|||
return {
|
||||
href: '#',
|
||||
icon: this.avatarUrl(session),
|
||||
text: session.guestName ? session.guestName : session.displayName
|
||||
text: session.guestName ? session.guestName : session.displayName,
|
||||
}
|
||||
})
|
||||
}),
|
||||
]
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -23,5 +23,5 @@
|
|||
import Keymap from './Keymap'
|
||||
|
||||
export {
|
||||
Keymap
|
||||
Keymap,
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
id: 'text',
|
||||
mimes: [...openMimetypesMarkdown, ...openMimetypesPlainText],
|
||||
component: FilesEditor,
|
||||
group: null
|
||||
group: null,
|
||||
})
|
||||
OC.Plugins.register('OCA.Files.SidebarPreviewManager', new PreviewPlugin())
|
||||
|
||||
|
@ -55,5 +55,5 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
OC.Plugins.register('OCA.Files.FileList', FilesWorkspacePlugin)
|
||||
|
||||
OCA.Text = {
|
||||
Editor: FilesEditor
|
||||
Editor: FilesEditor,
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ export default class PreviewPlugin {
|
|||
|
||||
Promise.all([
|
||||
this.getFileContent(model.getFullPath()),
|
||||
this.init()
|
||||
this.init(),
|
||||
]).then(([{ data }]) => {
|
||||
$thumbnailContainer.addClass('text')
|
||||
const textPreview = document.createElement('div')
|
||||
|
@ -74,9 +74,9 @@ export default class PreviewPlugin {
|
|||
render: h => h(this.ReadOnlyEditor, {
|
||||
props: {
|
||||
content: data,
|
||||
isRichEditor: model.get('mimetype') === 'text/markdown'
|
||||
}
|
||||
})
|
||||
isRichEditor: model.get('mimetype') === 'text/markdown',
|
||||
},
|
||||
}),
|
||||
})
|
||||
this.view.$mount(textPreview)
|
||||
}).catch(() => {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
* @param callback
|
||||
*/
|
||||
import axios from '@nextcloud/axios'
|
||||
import { generateRemoteUrl } from 'nextcloud-server/dist/router'
|
||||
import { generateRemoteUrl } from '@nextcloud/router'
|
||||
import { openMimetypes } from './mime'
|
||||
import RichWorkspace from '../views/RichWorkspace'
|
||||
|
||||
|
@ -37,7 +37,7 @@ const fetchFileInfo = async function(user, path) {
|
|||
url: generateRemoteUrl(`dav/files/${user}${path}`),
|
||||
headers: {
|
||||
requesttoken: OC.requestToken,
|
||||
'content-Type': 'text/xml'
|
||||
'content-Type': 'text/xml',
|
||||
},
|
||||
data: `<?xml version="1.0"?>
|
||||
<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns" xmlns:ocs="http://open-collaboration-services.org/ns">
|
||||
|
@ -61,7 +61,7 @@ const fetchFileInfo = async function(user, path) {
|
|||
<oc:owner-display-name />
|
||||
<oc:share-types />
|
||||
</d:prop>
|
||||
</d:propfind>`
|
||||
</d:propfind>`,
|
||||
})
|
||||
|
||||
const files = OCA.Files.App.fileList.filesClient._client.parseMultiStatus(response.data)
|
||||
|
@ -98,9 +98,9 @@ const registerFileCreate = () => {
|
|||
OCA.Files.fileActions.triggerAction(FILE_ACTION_IDENTIFIER, fileInfoModel, fileList)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
OC.Plugins.register('OCA.Files.NewFileMenu', newFileMenuPlugin)
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ const registerFileActionFallback = () => {
|
|||
const file = window.FileList.findFile(filename)
|
||||
Promise.all([
|
||||
import('vue'),
|
||||
import(/* webpackChunkName: "files-modal" */'./../components/PublicFilesEditor')
|
||||
import(/* webpackChunkName: "files-modal" */'./../components/PublicFilesEditor'),
|
||||
]).then((imports) => {
|
||||
const path = window.FileList.getCurrentDirectory() + '/' + filename
|
||||
const Vue = imports[0].default
|
||||
|
@ -137,9 +137,9 @@ const registerFileActionFallback = () => {
|
|||
active: true,
|
||||
shareToken: sharingToken,
|
||||
relativePath: path,
|
||||
mimeType: file.mimetype
|
||||
}
|
||||
})
|
||||
mimeType: file.mimetype,
|
||||
},
|
||||
}),
|
||||
})
|
||||
vm.$mount(ViewerRoot)
|
||||
})
|
||||
|
@ -169,7 +169,7 @@ const FilesWorkspacePlugin = {
|
|||
id: 'workspace',
|
||||
el: this.el,
|
||||
render: this.render.bind(this),
|
||||
priority: 10
|
||||
priority: 10,
|
||||
})
|
||||
},
|
||||
|
||||
|
@ -184,15 +184,15 @@ const FilesWorkspacePlugin = {
|
|||
const View = Vue.extend(RichWorkspace)
|
||||
const vm = new View({
|
||||
propsData: {
|
||||
path: fileList.getCurrentDirectory()
|
||||
}
|
||||
path: fileList.getCurrentDirectory(),
|
||||
},
|
||||
}).$mount(this.el)
|
||||
|
||||
fileList.$el.on('changeDirectory', data => {
|
||||
vm.path = data.dir.toString()
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export {
|
||||
|
@ -200,5 +200,5 @@ export {
|
|||
registerFileActionFallback,
|
||||
registerFileCreate,
|
||||
FilesWorkspacePlugin,
|
||||
FILE_ACTION_IDENTIFIER
|
||||
FILE_ACTION_IDENTIFIER,
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* Callback that should be executed after the document is ready
|
||||
* @param callback
|
||||
*/
|
||||
import { generateUrl } from 'nextcloud-server/dist/router'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
|
||||
const documentReady = function(callback) {
|
||||
const fn = () => setTimeout(callback, 0)
|
||||
|
@ -51,5 +51,5 @@ const getRandomGuestName = () => {
|
|||
export {
|
||||
documentReady,
|
||||
endpointUrl,
|
||||
getRandomGuestName
|
||||
getRandomGuestName,
|
||||
}
|
||||
|
|
|
@ -88,10 +88,10 @@ const extensionHighlight = {
|
|||
rs: 'rust',
|
||||
sci: 'scilab',
|
||||
vb: 'vbnet',
|
||||
vbs: 'vbscript'
|
||||
vbs: 'vbscript',
|
||||
}
|
||||
|
||||
export default extensionHighlight
|
||||
export {
|
||||
extensionHighlight
|
||||
extensionHighlight,
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
*/
|
||||
|
||||
const openMimetypesMarkdown = [
|
||||
'text/markdown'
|
||||
'text/markdown',
|
||||
]
|
||||
|
||||
const openMimetypesPlainText = [
|
||||
|
@ -35,7 +35,7 @@ const openMimetypesPlainText = [
|
|||
'application/x-php',
|
||||
'application/x-pearl',
|
||||
'application/x-text',
|
||||
'application/yaml'
|
||||
'application/yaml',
|
||||
]
|
||||
|
||||
const openMimetypes = [...openMimetypesMarkdown, ...openMimetypesPlainText]
|
||||
|
@ -43,5 +43,5 @@ const openMimetypes = [...openMimetypesMarkdown, ...openMimetypesPlainText]
|
|||
export {
|
||||
openMimetypes,
|
||||
openMimetypesMarkdown,
|
||||
openMimetypesPlainText
|
||||
openMimetypesPlainText,
|
||||
}
|
||||
|
|
10
src/main.js
10
src/main.js
|
@ -6,7 +6,7 @@ __webpack_public_path__ = OC.linkTo('text', 'js/') // eslint-disable-line
|
|||
if (document.getElementById('maineditor')) {
|
||||
Promise.all([
|
||||
import(/* webpackChunkName: "editor" */'vue'),
|
||||
import(/* webpackChunkName: "editor" */'./components/EditorWrapper')
|
||||
import(/* webpackChunkName: "editor" */'./components/EditorWrapper'),
|
||||
]).then((imports) => {
|
||||
const Vue = imports[0].default
|
||||
Vue.prototype.t = window.t
|
||||
|
@ -16,14 +16,14 @@ if (document.getElementById('maineditor')) {
|
|||
render: h => h(Editor, {
|
||||
props: {
|
||||
relativePath: '/welcome.md',
|
||||
active: true
|
||||
}
|
||||
})
|
||||
active: true,
|
||||
},
|
||||
}),
|
||||
})
|
||||
vm.$mount(document.getElementById('preview'))
|
||||
})
|
||||
}
|
||||
|
||||
OCA.Text = {
|
||||
Editor: FilesEditor
|
||||
Editor: FilesEditor,
|
||||
}
|
||||
|
|
|
@ -49,26 +49,26 @@ class Strike extends TipTapStrike {
|
|||
return {
|
||||
parseDOM: [
|
||||
{
|
||||
tag: 's'
|
||||
tag: 's',
|
||||
},
|
||||
{
|
||||
tag: 'del'
|
||||
tag: 'del',
|
||||
},
|
||||
{
|
||||
tag: 'strike'
|
||||
tag: 'strike',
|
||||
},
|
||||
{
|
||||
style: 'text-decoration',
|
||||
getAttrs: value => value === 'line-through'
|
||||
}
|
||||
getAttrs: value => value === 'line-through',
|
||||
},
|
||||
],
|
||||
toDOM: () => ['s', 0],
|
||||
toMarkdown: {
|
||||
open: '~~',
|
||||
close: '~~',
|
||||
mixable: true,
|
||||
expelEnclosingWhitespace: true
|
||||
}
|
||||
expelEnclosingWhitespace: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,5 +79,5 @@ class Strike extends TipTapStrike {
|
|||
export {
|
||||
Strong,
|
||||
Italic,
|
||||
Strike
|
||||
Strike,
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
export default {
|
||||
data() {
|
||||
return {
|
||||
isMobile: this._isMobile()
|
||||
isMobile: this._isMobile(),
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
|
@ -40,6 +40,6 @@ export default {
|
|||
_isMobile() {
|
||||
// check if content width is under 768px
|
||||
return document.documentElement.clientWidth < 768
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -25,13 +25,13 @@ export default [
|
|||
label: t('text', 'Undo'),
|
||||
class: 'icon-undo',
|
||||
isActive: (isActive) => {},
|
||||
action: (command) => command.undo()
|
||||
action: (command) => command.undo(),
|
||||
},
|
||||
{
|
||||
label: t('text', 'Redo'),
|
||||
class: 'icon-redo',
|
||||
isActive: (isActive) => {},
|
||||
action: (command) => command.redo()
|
||||
action: (command) => command.redo(),
|
||||
},
|
||||
{
|
||||
label: t('text', 'Bold'),
|
||||
|
@ -39,7 +39,7 @@ export default [
|
|||
isActive: (isActive) => isActive.strong(),
|
||||
action: (command) => {
|
||||
return command.strong()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('text', 'Italic'),
|
||||
|
@ -47,7 +47,7 @@ export default [
|
|||
isActive: (isActive) => isActive.em(),
|
||||
action: (command) => {
|
||||
return command.em()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('text', 'Strikethrough'),
|
||||
|
@ -55,7 +55,7 @@ export default [
|
|||
isActive: (isActive) => isActive.strike(),
|
||||
action: (command) => {
|
||||
return command.strike()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('text', 'Paragraph'),
|
||||
|
@ -63,7 +63,7 @@ export default [
|
|||
isActive: (isActive) => {},
|
||||
action: (command) => {
|
||||
return command.paragraph()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('text', 'Headings'),
|
||||
|
@ -75,7 +75,7 @@ export default [
|
|||
isActive: (isActive) => isActive.heading({ level: 1 }),
|
||||
action: (command) => {
|
||||
return command.heading({ level: 1 })
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('text', 'Heading 2'),
|
||||
|
@ -83,7 +83,7 @@ export default [
|
|||
isActive: (isActive) => isActive.heading({ level: 2 }),
|
||||
action: (command) => {
|
||||
return command.heading({ level: 2 })
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('text', 'Heading 3'),
|
||||
|
@ -91,7 +91,7 @@ export default [
|
|||
isActive: (isActive) => isActive.heading({ level: 3 }),
|
||||
action: (command) => {
|
||||
return command.heading({ level: 3 })
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('text', 'Heading 4'),
|
||||
|
@ -99,7 +99,7 @@ export default [
|
|||
isActive: (isActive) => isActive.heading({ level: 4 }),
|
||||
action: (command) => {
|
||||
return command.heading({ level: 4 })
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('text', 'Heading 5'),
|
||||
|
@ -107,7 +107,7 @@ export default [
|
|||
isActive: (isActive) => isActive.heading({ level: 5 }),
|
||||
action: (command) => {
|
||||
return command.heading({ level: 5 })
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('text', 'Heading 6'),
|
||||
|
@ -115,9 +115,9 @@ export default [
|
|||
isActive: (isActive) => isActive.heading({ level: 6 }),
|
||||
action: (command) => {
|
||||
return command.heading({ level: 6 })
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: t('text', 'Unordered list'),
|
||||
|
@ -125,7 +125,7 @@ export default [
|
|||
isActive: (isActive) => isActive.bullet_list(),
|
||||
action: (command) => {
|
||||
return command.bullet_list()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('text', 'Ordered list'),
|
||||
|
@ -133,7 +133,7 @@ export default [
|
|||
isActive: (isActive) => isActive.ordered_list(),
|
||||
action: (command) => {
|
||||
return command.ordered_list()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('text', 'Blockquote'),
|
||||
|
@ -141,7 +141,7 @@ export default [
|
|||
isActive: (isActive) => isActive.blockquote(),
|
||||
action: (command) => {
|
||||
return command.blockquote()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('text', 'Code block'),
|
||||
|
@ -149,6 +149,6 @@ export default [
|
|||
isActive: (isActive) => isActive.code_block(),
|
||||
action: (command) => {
|
||||
return command.code_block()
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
|
|
@ -32,7 +32,7 @@ export default class Image extends TiptapImage {
|
|||
get schema() {
|
||||
return {
|
||||
...super.schema,
|
||||
selectable: false
|
||||
selectable: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ const imageMimes = [
|
|||
'image/gif',
|
||||
'image/x-xbitmap',
|
||||
'image/bmp',
|
||||
'image/svg+xml'
|
||||
'image/svg+xml',
|
||||
]
|
||||
|
||||
const getQueryVariable = (src, variable) => {
|
||||
|
@ -93,7 +93,7 @@ export default {
|
|||
return {
|
||||
imageLoaded: false,
|
||||
loaded: false,
|
||||
failed: false
|
||||
failed: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -101,7 +101,7 @@ export default {
|
|||
const mime = getQueryVariable(this.src, 'mimetype')
|
||||
if (mime) {
|
||||
return {
|
||||
backgroundImage: 'url(' + window.OC.MimeType.getIconUrl(mime) + ')'
|
||||
backgroundImage: 'url(' + window.OC.MimeType.getIconUrl(mime) + ')',
|
||||
}
|
||||
}
|
||||
return {}
|
||||
|
@ -123,9 +123,9 @@ export default {
|
|||
},
|
||||
set(src) {
|
||||
this.updateAttrs({
|
||||
src
|
||||
src,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
alt: {
|
||||
get() {
|
||||
|
@ -133,13 +133,13 @@ export default {
|
|||
},
|
||||
set(alt) {
|
||||
this.updateAttrs({
|
||||
alt
|
||||
alt,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
t() {
|
||||
return (a, s) => window.t(a, s)
|
||||
}
|
||||
},
|
||||
},
|
||||
beforeMount() {
|
||||
if (!this.isSupportedImage) {
|
||||
|
@ -166,8 +166,8 @@ export default {
|
|||
},
|
||||
onLoaded() {
|
||||
this.loaded = true
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ export default class PlainTextDocument extends Node {
|
|||
|
||||
get schema() {
|
||||
return {
|
||||
content: 'block'
|
||||
content: 'block',
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ export default class PlainTextDocument extends Node {
|
|||
Tab: (state) => {
|
||||
insertText('\t')(state, this.editor.view.dispatch, this.editor.view)
|
||||
return true
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,5 +25,5 @@ import PlainTextDocument from './PlainTextDocument'
|
|||
|
||||
export {
|
||||
Image,
|
||||
PlainTextDocument
|
||||
PlainTextDocument,
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import { documentReady } from './helpers'
|
|||
import {
|
||||
FilesWorkspacePlugin,
|
||||
registerFileActionFallback,
|
||||
registerFileCreate
|
||||
registerFileCreate,
|
||||
} from './helpers/files'
|
||||
import { openMimetypes } from './helpers/mime'
|
||||
|
||||
|
@ -28,7 +28,7 @@ documentReady(() => {
|
|||
if (openMimetypes.indexOf(mimetype) !== -1) {
|
||||
Promise.all([
|
||||
import(/* webpackChunkName: "vendor" */'vue'),
|
||||
import(/* webpackChunkName: "editor" */'./components/EditorWrapper')
|
||||
import(/* webpackChunkName: "editor" */'./components/EditorWrapper'),
|
||||
]).then((imports) => {
|
||||
const Vue = imports[0].default
|
||||
Vue.prototype.t = window.t
|
||||
|
@ -39,9 +39,9 @@ documentReady(() => {
|
|||
props: {
|
||||
active: true,
|
||||
shareToken: sharingToken,
|
||||
mime: mimetype
|
||||
}
|
||||
})
|
||||
mime: mimetype,
|
||||
},
|
||||
}),
|
||||
})
|
||||
vm.$mount(document.getElementById('preview'))
|
||||
})
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
import axios from 'nextcloud-axios'
|
||||
import axios from '@nextcloud/axios'
|
||||
import { endpointUrl } from '../helpers'
|
||||
import { ERROR_TYPE } from './SyncService'
|
||||
import { sendableSteps } from 'prosemirror-collab'
|
||||
|
@ -111,7 +111,7 @@ class PollingBackend {
|
|||
force: !!this._forcedSave,
|
||||
manualSave: !!this._manualSave,
|
||||
token: this._authority.options.shareToken,
|
||||
filePath: this._authority.options.filePath
|
||||
filePath: this._authority.options.filePath,
|
||||
}).then((response) => {
|
||||
this.fetchRetryCounter = 0
|
||||
|
||||
|
@ -154,7 +154,7 @@ class PollingBackend {
|
|||
// Only emit conflict event if we have synced until the latest version
|
||||
console.error('Conflict during file save, please resolve')
|
||||
this._authority.emit('error', ERROR_TYPE.SAVE_COLLISSION, {
|
||||
outsideChange: e.response.data.outsideChange
|
||||
outsideChange: e.response.data.outsideChange,
|
||||
})
|
||||
} else if (e.response.status === 403) {
|
||||
this._authority.emit('error', ERROR_TYPE.CONNECTION_FAILED, {})
|
||||
|
@ -184,7 +184,7 @@ class PollingBackend {
|
|||
steps: steps.map(s => s.toJSON ? s.toJSON() : s) || [],
|
||||
version: sendable.version,
|
||||
token: this._authority.options.shareToken,
|
||||
filePath: this._authority.options.filePath
|
||||
filePath: this._authority.options.filePath,
|
||||
}).then((response) => {
|
||||
this.carefulRetryReset()
|
||||
this.lock = false
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
import axios from 'nextcloud-axios'
|
||||
import axios from '@nextcloud/axios'
|
||||
|
||||
import PollingBackend from './PollingBackend'
|
||||
import { endpointUrl } from './../helpers'
|
||||
|
@ -28,7 +28,7 @@ import { getVersion, sendableSteps } from 'prosemirror-collab'
|
|||
const defaultOptions = {
|
||||
shareToken: null,
|
||||
forceRecreate: false,
|
||||
serialize: (document) => document
|
||||
serialize: (document) => document,
|
||||
}
|
||||
|
||||
const ERROR_TYPE = {
|
||||
|
@ -46,7 +46,7 @@ const ERROR_TYPE = {
|
|||
|
||||
CONNECTION_FAILED: 3,
|
||||
|
||||
SOURCE_NOT_FOUND: 4
|
||||
SOURCE_NOT_FOUND: 4,
|
||||
}
|
||||
|
||||
class SyncService {
|
||||
|
@ -67,7 +67,7 @@ class SyncService {
|
|||
/* Events for session and document meta data */
|
||||
change: [],
|
||||
/* Emitted after successful save */
|
||||
save: []
|
||||
save: [],
|
||||
}
|
||||
|
||||
this.backend = new PollingBackend(this)
|
||||
|
@ -88,14 +88,14 @@ class SyncService {
|
|||
return this._openDocument({ fileId, filePath }).then(() => {
|
||||
this.emit('opened', {
|
||||
document: this.document,
|
||||
session: this.session
|
||||
session: this.session,
|
||||
})
|
||||
return this._fetchDocument().then(({ data }) => {
|
||||
|
||||
this.emit('loaded', {
|
||||
document: this.document,
|
||||
session: this.session,
|
||||
documentSource: '' + data
|
||||
documentSource: '' + data,
|
||||
})
|
||||
})
|
||||
}).catch((error) => {
|
||||
|
@ -120,8 +120,8 @@ class SyncService {
|
|||
filePath,
|
||||
token: this.options.shareToken,
|
||||
guestName: this.options.guestName,
|
||||
forceRecreate: this.options.forceRecreate
|
||||
}
|
||||
forceRecreate: this.options.forceRecreate,
|
||||
},
|
||||
}).then((response) => {
|
||||
this.document = response.data.document
|
||||
this.document.readOnly = response.data.readOnly
|
||||
|
@ -138,8 +138,8 @@ class SyncService {
|
|||
documentId: this.document.id,
|
||||
sessionId: this.session.id,
|
||||
sessionToken: this.session.token,
|
||||
token: this.options.shareToken
|
||||
}
|
||||
token: this.options.shareToken,
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ class SyncService {
|
|||
sessionId: this.session.id,
|
||||
sessionToken: this.session.token,
|
||||
token: this.options.shareToken,
|
||||
guestName
|
||||
guestName,
|
||||
}
|
||||
).then(({ data }) => {
|
||||
this.session = data
|
||||
|
@ -176,7 +176,7 @@ class SyncService {
|
|||
stepsSince(version) {
|
||||
return {
|
||||
steps: this.steps.slice(version),
|
||||
clientIDs: this.stepClientIDs.slice(version)
|
||||
clientIDs: this.stepClientIDs.slice(version),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ class SyncService {
|
|||
this.steps.push(step)
|
||||
newSteps.push({
|
||||
step,
|
||||
clientID: steps[i].sessionId
|
||||
clientID: steps[i].sessionId,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -260,8 +260,8 @@ class SyncService {
|
|||
documentId: this.document.id,
|
||||
sessionId: this.session.id,
|
||||
sessionToken: this.session.token,
|
||||
token: this.options.shareToken
|
||||
}
|
||||
token: this.options.shareToken,
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -52,31 +52,31 @@ const WORKSPACE_URL = generateOcsUrl('apps/text' + (IS_PUBLIC ? '/public' : ''),
|
|||
export default {
|
||||
name: 'RichWorkspace',
|
||||
components: {
|
||||
EditorWrapper: () => import(/* webpackChunkName: "editor" */'./../components/EditorWrapper')
|
||||
EditorWrapper: () => import(/* webpackChunkName: "editor" */'./../components/EditorWrapper'),
|
||||
},
|
||||
props: {
|
||||
path: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
file: null,
|
||||
loaded: false,
|
||||
ready: false,
|
||||
autofocus: false
|
||||
autofocus: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
shareToken() {
|
||||
return document.getElementById('sharingToken') ? document.getElementById('sharingToken').value : null
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
path: function() {
|
||||
this.getFileInfo()
|
||||
}
|
||||
},
|
||||
},
|
||||
async mounted() {
|
||||
this.getFileInfo()
|
||||
|
@ -111,8 +111,8 @@ export default {
|
|||
this.autofocus = true
|
||||
this.creating = false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче