Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
710b350
refactor(links): move linkBubble plugin to plugins/links
max-nextcloud Mar 15, 2024
e6049b0
refactor(links): pass editor via options to LinkBubblePluginView
max-nextcloud Mar 15, 2024
d871277
refactor(links): untangle LinkBubblePluginView from editor
max-nextcloud Mar 15, 2024
e4340f8
refactor(links): use prosemirror tr and state to track clicks
max-nextcloud Mar 17, 2024
90b99be
refactor(links): move click handling into link bubble plugin
max-nextcloud Mar 17, 2024
356509b
refactor(links): only hand link mark to updateTooltip
max-nextcloud Mar 17, 2024
e30c78c
refactor(links): introduce setActiveLink function
max-nextcloud Mar 18, 2024
d956fdd
fix(links): also update if active was unset
max-nextcloud Mar 18, 2024
e02c5ad
refactor(links): operate on state with `linkNodeFromSelection`
max-nextcloud Mar 18, 2024
c1e4bd8
refactor(links): move linkNodeFromSelection into helper
max-nextcloud Mar 18, 2024
96097aa
refactor(links): handle selection changes in plugin
max-nextcloud Mar 18, 2024
4a3165b
refactor(links): use hideLinkBubble command for esc
max-nextcloud Mar 19, 2024
ed923f4
fix(links): simplify updateTooltip and handle active null
max-nextcloud Mar 19, 2024
4bc7586
fix(links): remove special handling for clicked and focus
max-nextcloud Mar 19, 2024
7fe10f9
fix(links): handle esc in DOMEvents rather than prop
max-nextcloud Mar 19, 2024
d79b67c
fix(links) handle linkNodeFromSelection returning false
max-nextcloud Mar 19, 2024
4f5277e
enh(links): close link bubble when opening preview toggle
max-nextcloud Mar 19, 2024
d582f38
fix(lint): add missing jsdoc comments to new files
max-nextcloud Mar 19, 2024
322a752
docs(preview): improve jsdocs for markdownit preview plugin
max-nextcloud Mar 19, 2024
8e78cb7
refactor(links): only get mark from selection
max-nextcloud Mar 20, 2024
385b246
refactor(links): get active link from selection
max-nextcloud Mar 20, 2024
c2fd1e5
fix(links): show bubble with cursor on the end of the link
max-nextcloud Mar 20, 2024
fb0a8ce
tests(links): ignore link bubble when reading link text
max-nextcloud Mar 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/e2e/nodes/Links.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe('test link marks', function() {
cy.getSubmenuEntry('insert-link', 'insert-link-website').click()
cy.getActionSubEntry('insert-link-input').find('input[type="text"]').type(`${url}{enter}`)
cy.getContent()
.get(`a[href*="${url}"]`)
.find(`a[href*="${url}"]`)
.should('have.text', text) // ensure correct text used
.click({ force: true })
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Editor/PreviewOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
-
-->
<template>
<NcActions data-text-preview-options="select">
<NcActions data-text-preview-options="select"
@open="$emit('open')">
<template #icon>
<DotsVerticalIcon :size="20" />
</template>
Expand Down
18 changes: 8 additions & 10 deletions src/extensions/LinkBubble.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import { Extension } from '@tiptap/core'
import { Plugin, PluginKey } from '@tiptap/pm/state'
import LinkBubblePluginView from './LinkBubblePluginView.js'
import { linkBubble, hideLinkBubble } from '../plugins/links.js'

const LinkBubble = Extension.create({
name: 'linkViewBubble',

addOptions() {
addCommands() {
return {
pluginKey: 'linkViewBubble',
hideLinkBubble: () => ({ state, dispatch }) => {
return hideLinkBubble(state, dispatch)
},
}
},

addProseMirrorPlugins() {
return [
new Plugin({
key: new PluginKey(this.options.pluginKey),
view: (view) => new LinkBubblePluginView({
editor: this.editor,
view,
}),
linkBubble({
editor: this.editor,
parent: this.editor.contentComponent,
}),
]
},
Expand Down
232 changes: 0 additions & 232 deletions src/extensions/LinkBubblePluginView.js

This file was deleted.

21 changes: 9 additions & 12 deletions src/markdownit/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
*/

/**
*
* @param tokens
* @param i
* Check if the given tokens represent a preview in a paragraph
* @param {Array} tokens - tokens to check
* @param {number} i - offset into the tokens
*/
function isPreviewLinkInParagraph(tokens, i) {
const [prev, cur, next] = tokens.slice(i - 1, i + 2)
Expand All @@ -38,15 +38,11 @@ function isPreviewLinkInParagraph(tokens, i) {
&& next.type === 'paragraph_close'
}

/* Remove wrapping tokens
*
* @param {array} tokens - the token stream to modify
* @param {Number} i - index of the token to unwrap
*/
/**
* Remove wrapping tokens
*
* @param tokens
* @param i
* @param {Array} tokens - the token stream to modify
* @param {number} i - index of the token to unwrap
*/
function unwrapToken(tokens, i) {
// Start from the end so indexes stay the same.
Expand All @@ -60,9 +56,10 @@ function unwrapToken(tokens, i) {
export default (md) => {

/**
* Markdownit plugin to unwrap previews from a paragraph
*
* @param root0
* @param root0.tokens
* @param {object} state handed to the plugin
* @param {Array} state.tokens current token stream
*/
function linkPreviews({ tokens }) {
// do not process first and last token
Expand Down
1 change: 1 addition & 0 deletions src/nodes/ParagraphView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<NodeViewWrapper class="vue-component" as="p">
<PreviewOptions v-if="editor.isEditable && href"
:value.sync="value"
@open="editor.commands.hideLinkBubble()"
@update:value="convertToPreview" />
<NodeViewContent class="paragraph-content" />
</NodeViewWrapper>
Expand Down
Loading