Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2019-10-05 10:35:43 +02:00
Родитель 69b3157dd9
Коммит 7805c98a4b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4C614C6ED2CDE6DF
10 изменённых файлов: 80 добавлений и 45 удалений

Просмотреть файл

@ -24,6 +24,7 @@
}, },
"dependencies": { "dependencies": {
"@nextcloud/axios": "^0.4.1", "@nextcloud/axios": "^0.4.1",
"escape-html": "^1.0.3",
"highlight.js": "^9.15.10", "highlight.js": "^9.15.10",
"markdown-it": "^10.0.0", "markdown-it": "^10.0.0",
"nextcloud-axios": "^0.2.1", "nextcloud-axios": "^0.2.1",

Просмотреть файл

@ -32,30 +32,34 @@
</div> </div>
<div v-if="currentSession && active" id="editor-wrapper" :class="{'has-conflicts': hasSyncCollission, 'icon-loading': !initialLoading, 'richEditor': isRichEditor}"> <div v-if="currentSession && active" id="editor-wrapper" :class="{'has-conflicts': hasSyncCollission, 'icon-loading': !initialLoading, 'richEditor': isRichEditor}">
<div id="editor"> <div id="editor">
<menu-bar v-if="!syncError && !readOnly" ref="menubar" :editor="tiptap" <MenuBar v-if="!syncError && !readOnly"
ref="menubar"
:editor="tiptap"
:is-rich-editor="isRichEditor"> :is-rich-editor="isRichEditor">
<div v-if="currentSession && active" id="editor-session-list"> <div v-if="currentSession && active" id="editor-session-list">
<div v-tooltip="lastSavedStatusTooltip" class="save-status" :class="lastSavedStatusClass"> <div v-tooltip="lastSavedStatusTooltip" class="save-status" :class="lastSavedStatusClass">
{{ lastSavedStatus }} {{ lastSavedStatus }}
</div> </div>
<session-list :sessions="filteredSessions"> <SessionList :sessions="filteredSessions">
<guest-name-dialog v-if="isPublic && currentSession.guestName" :sync-service="syncService" /> <GuestNameDialog v-if="isPublic && currentSession.guestName" :sync-service="syncService" />
</session-list> </SessionList>
</div> </div>
</menu-bar> </MenuBar>
<menu-bubble v-if="!readOnly && isRichEditor" :editor="tiptap" /> <MenuBubble v-if="!readOnly && isRichEditor" :editor="tiptap" />
<editor-content v-show="initialLoading" class="editor__content" :editor="tiptap" /> <EditorContent v-show="initialLoading" class="editor__content" :editor="tiptap" />
</div> </div>
<read-only-editor v-if="hasSyncCollission" :content="syncError.data.outsideChange" <ReadOnlyEditor v-if="hasSyncCollission"
:content="syncError.data.outsideChange"
:is-rich-editor="isRichEditor" /> :is-rich-editor="isRichEditor" />
</div> </div>
<collision-resolve-dialog v-if="hasSyncCollission && !readOnly" @resolveUseThisVersion="resolveUseThisVersion" @resolveUseServerVersion="resolveUseServerVersion" /> <CollisionResolveDialog v-if="hasSyncCollission && !readOnly" @resolveUseThisVersion="resolveUseThisVersion" @resolveUseServerVersion="resolveUseServerVersion" />
</div> </div>
</template> </template>
<script> <script>
import Vue from 'vue' import Vue from 'vue'
import escapeHtml from 'escape-html'
import { SyncService, ERROR_TYPE } from './../services/SyncService' import { SyncService, ERROR_TYPE } from './../services/SyncService'
import { endpointUrl, getRandomGuestName } from './../helpers' import { endpointUrl, getRandomGuestName } from './../helpers'
@ -264,7 +268,7 @@ export default {
this.hasConnectionIssue = false this.hasConnectionIssue = false
loadSyntaxHighlight(extensionHighlight[this.fileExtension] ? extensionHighlight[this.fileExtension] : this.fileExtension).then((languages) => { loadSyntaxHighlight(extensionHighlight[this.fileExtension] ? extensionHighlight[this.fileExtension] : this.fileExtension).then((languages) => {
this.tiptap = createEditor({ this.tiptap = createEditor({
content: this.isRichEditor ? markdownit.render(documentSource) : '<pre>' + window.escapeHTML(documentSource) + '</pre>', content: this.isRichEditor ? markdownit.render(documentSource) : '<pre>' + escapeHtml(documentSource) + '</pre>',
onInit: ({ state }) => { onInit: ({ state }) => {
this.syncService.state = state this.syncService.state = state
this.syncService.startSync() this.syncService.startSync()

Просмотреть файл

@ -21,8 +21,11 @@
--> -->
<template> <template>
<editor-wrapper :file-id="fileId" :relative-path="davPath" :active="active" <EditorWrapper :file-id="fileId"
:share-token="shareToken" :mime="mime" /> :relative-path="davPath"
:active="active"
:share-token="shareToken"
:mime="mime" />
</template> </template>
<script> <script>

Просмотреть файл

@ -22,7 +22,7 @@
<template> <template>
<form v-tooltip="t('text', 'Enter your name so other users can see who is editing')" class="guest-name-dialog" @submit.prevent="setGuestName()"> <form v-tooltip="t('text', 'Enter your name so other users can see who is editing')" class="guest-name-dialog" @submit.prevent="setGuestName()">
<label><avatar :url="avatarUrl" :disable-tooltip="true" :size="32" /></label> <label><Avatar :url="avatarUrl" :disable-tooltip="true" :size="32" /></label>
<input v-model="guestName" type="text" :aria-label="t('text', 'Edit guest name')"> <input v-model="guestName" type="text" :aria-label="t('text', 'Edit guest name')">
<input type="submit" class="icon-confirm" :aria-label="t('text', 'Save guest name')"> <input type="submit" class="icon-confirm" :aria-label="t('text', 'Save guest name')">
</form> </form>

Просмотреть файл

@ -21,46 +21,54 @@
--> -->
<template> <template>
<editor-menu-bar v-slot="{ commands, isActive }" :editor="editor"> <EditorMenuBar v-slot="{ commands, isActive }" :editor="editor">
<div class="menubar"> <div class="menubar">
<div v-if="isRichEditor" ref="menubar" class="menubar-icons"> <div v-if="isRichEditor" ref="menubar" class="menubar-icons">
<template v-for="(icon, $index) in allIcons"> <template v-for="(icon, $index) in allIcons">
<button v-if="icon.class" v-show="$index < iconCount" :key="icon.label" <button v-if="icon.class"
v-show="$index < iconCount"
:key="icon.label"
:title="icon.label" :title="icon.label"
:class="getIconClasses(isActive, icon)" @click="clickIcon(commands, icon)" /> :class="getIconClasses(isActive, icon)"
@click="clickIcon(commands, icon)" />
<template v-else> <template v-else>
<div v-show="$index < iconCount" :key="icon.label" v-click-outside="() => hideChildMenu(icon)" <div v-show="$index < iconCount"
:key="icon.label"
v-click-outside="() => hideChildMenu(icon)"
class="submenu"> class="submenu">
<button :class="childIconClass(isActive, icon.children, )" <button :class="childIconClass(isActive, icon.children, )"
:title="icon.label" :title="icon.label"
@click.prevent="toggleChildMenu(icon)" /> @click.prevent="toggleChildMenu(icon)" />
<div :class="{open: isChildMenuVisible(icon)}" class="popovermenu menu-center"> <div :class="{open: isChildMenuVisible(icon)}" class="popovermenu menu-center">
<popover-menu :menu="childPopoverMenu(isActive, commands, icon.children, icon)" /> <PopoverMenu :menu="childPopoverMenu(isActive, commands, icon.children, icon)" />
</div> </div>
</div> </div>
</template> </template>
</template> </template>
<actions> <Actions>
<template v-for="(icon, $index) in allIcons"> <template v-for="(icon, $index) in allIcons">
<action-button v-if="icon.class && isHiddenInMenu($index)" :key="icon.class" <ActionButton v-if="icon.class && isHiddenInMenu($index)"
:icon="icon.class" @click="clickIcon(commands, icon)"> :key="icon.class"
:icon="icon.class"
@click="clickIcon(commands, icon)">
{{ icon.label }} {{ icon.label }}
</action-button> </ActionButton>
<template v-else-if="!icon.class && isHiddenInMenu($index)"> <template v-else-if="!icon.class && isHiddenInMenu($index)">
<action-button v-for="childIcon in icon.children" :key="childIcon.class" <ActionButton v-for="childIcon in icon.children"
:key="childIcon.class"
:icon="childIcon.class" :icon="childIcon.class"
@click="clickIcon(commands, childIcon)"> @click="clickIcon(commands, childIcon)">
{{ childIcon.label }} {{ childIcon.label }}
</action-button> </ActionButton>
</template> </template>
</template> </template>
</actions> </Actions>
</div> </div>
<slot> <slot>
Left side Left side
</slot> </slot>
</div> </div>
</editor-menu-bar> </EditorMenuBar>
</template> </template>
<script> <script>

Просмотреть файл

@ -21,12 +21,18 @@
--> -->
<template> <template>
<editor-menu-bubble v-slot="{ commands, isActive, getMarkAttrs, menu }" class="menububble" <EditorMenuBubble v-slot="{ commands, isActive, getMarkAttrs, menu }"
:editor="editor" @hide="hideLinkMenu"> class="menububble"
:editor="editor"
@hide="hideLinkMenu">
<div class="menububble" :class="{ 'is-active': menu.isActive }" :style="`left: ${menu.left}px; bottom: ${menu.bottom}px;`"> <div class="menububble" :class="{ 'is-active': menu.isActive }" :style="`left: ${menu.left}px; bottom: ${menu.bottom}px;`">
<form v-if="linkMenuIsActive" class="menububble__form" @submit.prevent="setLinkUrl(commands.link, linkUrl)"> <form v-if="linkMenuIsActive" class="menububble__form" @submit.prevent="setLinkUrl(commands.link, linkUrl)">
<input ref="linkInput" v-model="linkUrl" class="menububble__input" <input ref="linkInput"
type="text" placeholder="https://" @keydown.esc="hideLinkMenu"> v-model="linkUrl"
class="menububble__input"
type="text"
placeholder="https://"
@keydown.esc="hideLinkMenu">
<button class="menububble__button icon-confirm" type="button" @click="setLinkUrl(commands.link, linkUrl)" /> <button class="menububble__button icon-confirm" type="button" @click="setLinkUrl(commands.link, linkUrl)" />
</form> </form>
@ -40,7 +46,7 @@
</button> </button>
</template> </template>
</div> </div>
</editor-menu-bubble> </EditorMenuBubble>
</template> </template>
<script> <script>

Просмотреть файл

@ -21,17 +21,20 @@
--> -->
<template> <template>
<modal v-if="active" :title="fileName" @close="close"> <Modal v-if="active" :title="fileName" @close="close">
<editor-wrapper :file-id="fileId" :relative-path="relativePath" :active="active" <EditorWrapper :file-id="fileId"
:share-token="shareToken" :mime="mimeType" /> :relative-path="relativePath"
</modal> :active="active"
:share-token="shareToken"
:mime="mimeType" />
</Modal>
</template> </template>
<script> <script>
import Modal from 'nextcloud-vue/dist/Components/Modal' import Modal from 'nextcloud-vue/dist/Components/Modal'
export default { export default {
name: 'FilesEditor', name: 'PublicFilesEditor',
components: { components: {
Modal, Modal,
EditorWrapper: () => import(/* webpackChunkName: "editor" */'./EditorWrapper') EditorWrapper: () => import(/* webpackChunkName: "editor" */'./EditorWrapper')

Просмотреть файл

@ -21,11 +21,12 @@
--> -->
<template> <template>
<editor-content v-if="editor" id="read-only-editor" :editor="editor" /> <EditorContent v-if="editor" id="read-only-editor" :editor="editor" />
</template> </template>
<script> <script>
import { EditorContent } from 'tiptap' import { EditorContent } from 'tiptap'
import escapeHtml from 'escape-html'
import { createEditor, markdownit } from '../EditorFactory' import { createEditor, markdownit } from '../EditorFactory'
export default { export default {
@ -48,7 +49,7 @@ export default {
}, },
mounted() { mounted() {
this.editor = createEditor({ this.editor = createEditor({
content: this.isRichEditor ? markdownit.render(this.content) : '<pre>' + window.escapeHTML(this.content) + '</pre>', content: this.isRichEditor ? markdownit.render(this.content) : '<pre>' + escapeHtml(this.content) + '</pre>',
enableRichEditing: this.isRichEditor enableRichEditing: this.isRichEditor
}) })
this.editor.setOptions({ editable: false }) this.editor.setOptions({ editable: false })

Просмотреть файл

@ -24,12 +24,15 @@
<div class="session-list"> <div class="session-list">
<div v-tooltip.left="editorsTooltip" class="avatar-list" @click="popoverVisible=!popoverVisible"> <div v-tooltip.left="editorsTooltip" class="avatar-list" @click="popoverVisible=!popoverVisible">
<div v-if="sessionsPopover.length > 0" class="avatardiv icon-more" /> <div v-if="sessionsPopover.length > 0" class="avatardiv icon-more" />
<avatar v-for="session in sessionsVisible" :key="session.id" <Avatar v-for="session in sessionsVisible"
:url="avatarUrl(session)" :disable-tooltip="true" :style="sessionStyle(session)" :key="session.id"
:url="avatarUrl(session)"
:disable-tooltip="true"
:style="sessionStyle(session)"
:size="32" /> :size="32" />
</div> </div>
<div v-show="popoverVisible" class="popovermenu menu-right"> <div v-show="popoverVisible" class="popovermenu menu-right">
<popover-menu :menu="sessionsPopover" /> <PopoverMenu :menu="sessionsPopover" />
<slot /> <slot />
</div> </div>
</div> </div>

Просмотреть файл

@ -24,12 +24,16 @@
<div class="image" :class="{'icon-loading': !loaded}" :data-src="src"> <div class="image" :class="{'icon-loading': !loaded}" :data-src="src">
<div v-if="imageLoaded && isSupportedImage"> <div v-if="imageLoaded && isSupportedImage">
<transition name="fade"> <transition name="fade">
<img v-show="loaded" :src="src" <img v-show="loaded"
class="image__main" @load="onLoaded"> :src="src"
class="image__main"
@load="onLoaded">
</transition> </transition>
<transition name="fade"> <transition name="fade">
<div v-show="loaded" class="image__caption"> <div v-show="loaded" class="image__caption">
<input ref="altInput" type="text" :value="alt" <input ref="altInput"
type="text"
:value="alt"
@keyup.enter="updateAlt()"> @keyup.enter="updateAlt()">
</div> </div>
</transition> </transition>
@ -44,7 +48,9 @@
</div> </div>
</transition><transition name="fade"> </transition><transition name="fade">
<div v-show="loaded" class="image__caption"> <div v-show="loaded" class="image__caption">
<input ref="altInput" type="text" :value="alt" <input ref="altInput"
type="text"
:value="alt"
@keyup.enter="updateAlt()"> @keyup.enter="updateAlt()">
</div> </div>
</transition> </transition>