Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/ListItem.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import TaskList from './../../../src/nodes/TaskList.js'
import TaskItem from './../../../src/nodes/TaskItem.js'
import BulletList from './../../../src/nodes/BulletList.js'
import Markdown, { createMarkdownSerializer } from './../../../src/extensions/Markdown.js'
import { findChildren } from 'prosemirror-utils'
import { findChildren } from './../../../src/helpers/prosemirrorUtils.js'
import { createCustomEditor } from './../../support/components.js'
import testData from '../../fixtures/ListItem.md'
import markdownit from './../../../src/markdownit/index.js'
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/nodes/Table.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { findChildren } from 'prosemirror-utils'
import { findChildren } from './../../../src/helpers/prosemirrorUtils.js'
import { initUserAndFiles, randUser } from '../../utils/index.js'
import { createCustomEditor } from './../../support/components.js'

Expand Down
4 changes: 2 additions & 2 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-editors.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-editors.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-text.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/vendors.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/vendors.js.map

Large diffs are not rendered by default.

16 changes: 0 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nextcloud/text",
"description": "Collaborative document editing",
"version": "26.0.0-alpha.6",
"version": "26.0.0-alpha.7",
"authors": [
{
"name": "Julius Härtl",
Expand Down Expand Up @@ -96,7 +96,6 @@
"markdown-it-image-figures": "^2.1.1",
"mitt": "^3.0.0",
"path-normalize": "^6.0.10",
"prosemirror-utils": "^1.0.0-0",
"proxy-polyfill": "^0.3.2",
"slug": "^8.2.2",
"tippy.js": "^6.3.7",
Expand Down
2 changes: 1 addition & 1 deletion src/components/RichTextReader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<script>
import BaseReader from './BaseReader.vue'
import RichText from './../extensions/RichText.js'
import { RichText } from './../extensions/index.js'
import markdownit from './../markdownit/index.js'

export default {
Expand Down
54 changes: 54 additions & 0 deletions src/helpers/prosemirrorUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copied from https://github.com/atlassian/prosemirror-utils/tree/1b97ff08f1bbaea781f205744588a3dfd228b0d1/src

// Iterates over parent nodes starting from the given `$pos`, returning the closest node and its start position `predicate` returns truthy for. `start` points to the start position of the node, `pos` points directly before the node.
//
// ```javascript
// const predicate = node => node.type === schema.nodes.blockquote;
// const parent = findParentNodeClosestToPos(state.doc.resolve(5), predicate);
// ```
export const findParentNodeClosestToPos = ($pos, predicate) => {
for (let i = $pos.depth; i > 0; i--) {
const node = $pos.node(i)
if (predicate(node)) {
return {
pos: i > 0 ? $pos.before(i) : 0,
start: $pos.start(i),
depth: i,
node,
}
}
}
}

// Flattens descendants of a given `node`. It doesn't descend into a node when descend argument is `false` (defaults to `true`).
//
// ```javascript
// const children = flatten(node);
// ```
export const flatten = (node, descend = true) => {
if (!node) {
throw new Error('Invalid "node" parameter')
}
const result = []
node.descendants((child, pos) => {
result.push({ node: child, pos })
if (!descend) {
return false
}
})
return result
}

// Iterates over descendants of a given `node`, returning child nodes predicate returns truthy for. It doesn't descend into a node when descend argument is `false` (defaults to `true`).
//
// ```javascript
// const textNodes = findChildren(node, child => child.isText, false);
// ```
export const findChildren = (node, predicate, descend) => {
if (!node) {
throw new Error('Invalid "node" parameter')
} else if (!predicate) {
throw new Error('Invalid "predicate" parameter')
}
return flatten(node, descend).filter(child => predicate(child.node))
}
2 changes: 1 addition & 1 deletion src/nodes/TaskItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import TipTapTaskItem from '@tiptap/extension-task-item'
import { wrappingInputRule, mergeAttributes } from '@tiptap/core'
import { Plugin } from '@tiptap/pm/state'
import { findParentNodeClosestToPos } from 'prosemirror-utils'
import { findParentNodeClosestToPos } from './../helpers/prosemirrorUtils.js'

const TaskItem = TipTapTaskItem.extend({

Expand Down
8 changes: 7 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ export default defineConfig({
formats: ['es'],
},
rollupOptions: {
external: Object.keys(dependencies),
external: [
...Object.keys(dependencies),
/lib0\/.*/,
/markdown-it\/.*/,
/@tiptap\/pm\/.*/,
/vue-material-design-icons\/.*/,
],
output: {
globals: { vue: 'Vue' },
},
Expand Down