@kerebron/editor-kits 0.4.7 → 0.4.9
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/esm/AdvancedEditorKit.d.ts.map +1 -0
- package/esm/{editor-kits/src/AdvancedEditorKit.js → AdvancedEditorKit.js} +3 -13
- package/esm/CodeEditorKit.d.ts.map +1 -0
- package/esm/{editor-kits/src/CodeEditorKit.js → CodeEditorKit.js} +3 -13
- package/esm/DevAdvancedEditorKit.d.ts.map +1 -0
- package/esm/{editor-kits/src/DevAdvancedEditorKit.js → DevAdvancedEditorKit.js} +3 -13
- package/esm/LspEditorKit.d.ts.map +1 -0
- package/esm/{editor-kits/src/LspEditorKit.js → LspEditorKit.js} +3 -18
- package/esm/YjsEditorKit.d.ts.map +1 -0
- package/esm/{editor-kits/src/YjsEditorKit.js → YjsEditorKit.js} +4 -18
- package/esm/mod.d.ts +1 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +1 -0
- package/package.json +20 -24
- package/esm/editor/src/commands/mod.d.ts +0 -7
- package/esm/editor/src/commands/mod.d.ts.map +0 -1
- package/esm/editor/src/commands/mod.js +0 -76
- package/esm/editor/src/commands/types.d.ts +0 -18
- package/esm/editor/src/commands/types.d.ts.map +0 -1
- package/esm/editor/src/commands/types.js +0 -1
- package/esm/editor/src/plugins/keymap/keymap.d.ts +0 -11
- package/esm/editor/src/plugins/keymap/keymap.d.ts.map +0 -1
- package/esm/editor/src/plugins/keymap/keymap.js +0 -125
- package/esm/editor/src/plugins/keymap/mod.d.ts +0 -2
- package/esm/editor/src/plugins/keymap/mod.d.ts.map +0 -1
- package/esm/editor/src/plugins/keymap/mod.js +0 -1
- package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts +0 -4
- package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts.map +0 -1
- package/esm/editor/src/plugins/keymap/w3c-keyname.js +0 -124
- package/esm/editor-kits/src/AdvancedEditorKit.d.ts.map +0 -1
- package/esm/editor-kits/src/CodeEditorKit.d.ts.map +0 -1
- package/esm/editor-kits/src/DevAdvancedEditorKit.d.ts.map +0 -1
- package/esm/editor-kits/src/LspEditorKit.d.ts.map +0 -1
- package/esm/editor-kits/src/YjsEditorKit.d.ts.map +0 -1
- package/esm/editor-kits/src/mod.d.ts +0 -5
- package/esm/editor-kits/src/mod.d.ts.map +0 -1
- package/esm/editor-kits/src/mod.js +0 -4
- package/esm/extension-basic-editor/src/ExtensionBaseKeymap.d.ts +0 -7
- package/esm/extension-basic-editor/src/ExtensionBaseKeymap.d.ts.map +0 -1
- package/esm/extension-basic-editor/src/ExtensionBaseKeymap.js +0 -63
- package/esm/extension-basic-editor/src/ExtensionBasicCodeEditor.d.ts +0 -11
- package/esm/extension-basic-editor/src/ExtensionBasicCodeEditor.d.ts.map +0 -1
- package/esm/extension-basic-editor/src/ExtensionBasicCodeEditor.js +0 -71
- package/esm/extension-basic-editor/src/ExtensionDropcursor.d.ts +0 -19
- package/esm/extension-basic-editor/src/ExtensionDropcursor.d.ts.map +0 -1
- package/esm/extension-basic-editor/src/ExtensionDropcursor.js +0 -238
- package/esm/extension-basic-editor/src/ExtensionGapcursor.d.ts +0 -32
- package/esm/extension-basic-editor/src/ExtensionGapcursor.d.ts.map +0 -1
- package/esm/extension-basic-editor/src/ExtensionGapcursor.js +0 -266
- package/esm/extension-basic-editor/src/ExtensionHtml.d.ts +0 -15
- package/esm/extension-basic-editor/src/ExtensionHtml.d.ts.map +0 -1
- package/esm/extension-basic-editor/src/ExtensionHtml.js +0 -108
- package/esm/extension-basic-editor/src/ExtensionSelection.d.ts +0 -11
- package/esm/extension-basic-editor/src/ExtensionSelection.d.ts.map +0 -1
- package/esm/extension-basic-editor/src/ExtensionSelection.js +0 -237
- package/esm/extension-basic-editor/src/NodeDocumentCode.d.ts +0 -7
- package/esm/extension-basic-editor/src/NodeDocumentCode.d.ts.map +0 -1
- package/esm/extension-basic-editor/src/NodeDocumentCode.js +0 -37
- package/esm/extension-basic-editor/src/NodeText.d.ts +0 -7
- package/esm/extension-basic-editor/src/NodeText.d.ts.map +0 -1
- package/esm/extension-basic-editor/src/NodeText.js +0 -17
- package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts +0 -24
- package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts.map +0 -1
- package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.js +0 -35
- package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts +0 -25
- package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts.map +0 -1
- package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.js +0 -96
- /package/esm/{editor-kits/src/AdvancedEditorKit.d.ts → AdvancedEditorKit.d.ts} +0 -0
- /package/esm/{editor-kits/src/CodeEditorKit.d.ts → CodeEditorKit.d.ts} +0 -0
- /package/esm/{editor-kits/src/DevAdvancedEditorKit.d.ts → DevAdvancedEditorKit.d.ts} +0 -0
- /package/esm/{editor-kits/src/LspEditorKit.d.ts → LspEditorKit.d.ts} +0 -0
- /package/esm/{editor-kits/src/YjsEditorKit.d.ts → YjsEditorKit.d.ts} +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Node } from '@kerebron/editor';
|
|
2
|
-
export class NodeDocumentCode extends Node {
|
|
3
|
-
constructor() {
|
|
4
|
-
super(...arguments);
|
|
5
|
-
Object.defineProperty(this, "name", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
configurable: true,
|
|
8
|
-
writable: true,
|
|
9
|
-
value: 'doc_code'
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
getNodeSpec() {
|
|
13
|
-
return {
|
|
14
|
-
content: 'code_block',
|
|
15
|
-
defaultAttrs: {
|
|
16
|
-
'lang': this.config.lang || null,
|
|
17
|
-
},
|
|
18
|
-
EMPTY_DOC: {
|
|
19
|
-
'type': this.name,
|
|
20
|
-
'content': [
|
|
21
|
-
{
|
|
22
|
-
'type': 'code_block',
|
|
23
|
-
'attrs': {
|
|
24
|
-
'lang': this.config.lang || null,
|
|
25
|
-
},
|
|
26
|
-
'content': [
|
|
27
|
-
// {
|
|
28
|
-
// "type": "text",
|
|
29
|
-
// "text": ""
|
|
30
|
-
// }
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeText.d.ts","sourceRoot":"","sources":["../../../src/extension-basic-editor/src/NodeText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,qBAAa,QAAS,SAAQ,IAAI;IACvB,IAAI,SAAU;IAEd,WAAW,IAAI,QAAQ;CAKjC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Node } from '@kerebron/editor';
|
|
2
|
-
export class NodeText extends Node {
|
|
3
|
-
constructor() {
|
|
4
|
-
super(...arguments);
|
|
5
|
-
Object.defineProperty(this, "name", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
configurable: true,
|
|
8
|
-
writable: true,
|
|
9
|
-
value: 'text'
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
getNodeSpec() {
|
|
13
|
-
return {
|
|
14
|
-
group: 'inline',
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Plugin } from 'prosemirror-state';
|
|
2
|
-
import { Extension } from '@kerebron/editor';
|
|
3
|
-
type Color = string;
|
|
4
|
-
export interface SelectionState {
|
|
5
|
-
clientId: number;
|
|
6
|
-
user: {
|
|
7
|
-
name: string;
|
|
8
|
-
color: Color;
|
|
9
|
-
colorLight: Color;
|
|
10
|
-
};
|
|
11
|
-
cursor?: {
|
|
12
|
-
anchor: number;
|
|
13
|
-
head: number;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export { remoteSelectionPluginKey } from './remoteSelectionPlugin.js';
|
|
17
|
-
export declare class ExtensionRemoteSelection extends Extension {
|
|
18
|
-
name: string;
|
|
19
|
-
private remoteStates;
|
|
20
|
-
getProseMirrorPlugins(): Plugin[];
|
|
21
|
-
getRemoteStates(): SelectionState[];
|
|
22
|
-
setRemoteStates(states: SelectionState[]): void;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=ExtensionRemoteSelection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionRemoteSelection.d.ts","sourceRoot":"","sources":["../../../../src/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAmB,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI9D,KAAK,KAAK,GAAG,MAAM,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,KAAK,CAAC;QACb,UAAU,EAAE,KAAK,CAAC;KACnB,CAAC;IACF,MAAM,CAAC,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,qBAAa,wBAAyB,SAAQ,SAAS;IAC5C,IAAI,SAAsB;IAEnC,OAAO,CAAC,YAAY,CAAwB;IAEnC,qBAAqB,IAAI,MAAM,EAAE;IAM1C,eAAe,IAAI,cAAc,EAAE;IAInC,eAAe,CAAC,MAAM,EAAE,cAAc,EAAE;CAOzC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@kerebron/editor';
|
|
2
|
-
import { remoteSelectionPlugin } from './remoteSelectionPlugin.js';
|
|
3
|
-
export { remoteSelectionPluginKey } from './remoteSelectionPlugin.js';
|
|
4
|
-
export class ExtensionRemoteSelection extends Extension {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(...arguments);
|
|
7
|
-
Object.defineProperty(this, "name", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true,
|
|
11
|
-
value: 'remote-selection'
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(this, "remoteStates", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: []
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
getProseMirrorPlugins() {
|
|
21
|
-
return [
|
|
22
|
-
remoteSelectionPlugin(this, this.editor),
|
|
23
|
-
];
|
|
24
|
-
}
|
|
25
|
-
getRemoteStates() {
|
|
26
|
-
return this.remoteStates;
|
|
27
|
-
}
|
|
28
|
-
setRemoteStates(states) {
|
|
29
|
-
this.remoteStates = states;
|
|
30
|
-
const event = new CustomEvent('remoteSelectionChange', {
|
|
31
|
-
detail: {},
|
|
32
|
-
});
|
|
33
|
-
this.editor.dispatchEvent(event);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
|
-
import { type DecorationAttrs } from 'prosemirror-view';
|
|
3
|
-
import type { CoreEditor } from '@kerebron/editor';
|
|
4
|
-
import type { ExtensionRemoteSelection } from './ExtensionRemoteSelection.js';
|
|
5
|
-
export declare const remoteSelectionPluginKey: PluginKey<any>;
|
|
6
|
-
/**
|
|
7
|
-
* Default generator for a cursor element
|
|
8
|
-
*/
|
|
9
|
-
export declare const defaultCursorBuilder: (user: any) => HTMLElement;
|
|
10
|
-
/**
|
|
11
|
-
* Default generator for the selection attributes
|
|
12
|
-
*/
|
|
13
|
-
export declare const defaultSelectionBuilder: (user: any) => DecorationAttrs;
|
|
14
|
-
export declare const createDecorations: (state: any, extension: ExtensionRemoteSelection, createCursor: (user: {
|
|
15
|
-
name: string;
|
|
16
|
-
color: string;
|
|
17
|
-
}, clientId: number) => Element, createSelection: (user: {
|
|
18
|
-
name: string;
|
|
19
|
-
color: string;
|
|
20
|
-
}, clientId: number) => DecorationAttrs) => any;
|
|
21
|
-
export declare const remoteSelectionPlugin: (extension: ExtensionRemoteSelection, editor: CoreEditor, { cursorBuilder, selectionBuilder, }?: {
|
|
22
|
-
cursorBuilder?: (user: any, clientId: number) => HTMLElement;
|
|
23
|
-
selectionBuilder?: (user: any, clientId: number) => DecorationAttrs;
|
|
24
|
-
}) => Plugin<any>;
|
|
25
|
-
//# sourceMappingURL=remoteSelectionPlugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remoteSelectionPlugin.d.ts","sourceRoot":"","sources":["../../../../src/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAE9E,eAAO,MAAM,wBAAwB,gBAAoC,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM,GAAG,KAAG,WAahD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,MAAM,GAAG,KAAG,eAKnD,CAAC;AAIF,eAAO,MAAM,iBAAiB,GAC5B,OAAO,GAAG,EACV,WAAW,wBAAwB,EACnC,cAAc,CACZ,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EACrC,QAAQ,EAAE,MAAM,KACb,OAAO,EACZ,iBAAiB,CACf,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EACrC,QAAQ,EAAE,MAAM,KACb,eAAe,KACnB,GAwDF,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,WAAW,wBAAwB,EACnC,QAAQ,UAAU,EAClB,uCAGG;IACD,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,KAAK,WAAW,CAAC;IAC7D,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,KAAK,eAAe,CAAC;CAChE,gBAsCP,CAAC"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
2
|
-
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
3
|
-
export const remoteSelectionPluginKey = new PluginKey('remote-selection');
|
|
4
|
-
/**
|
|
5
|
-
* Default generator for a cursor element
|
|
6
|
-
*/
|
|
7
|
-
export const defaultCursorBuilder = (user) => {
|
|
8
|
-
const cursor = document.createElement('span');
|
|
9
|
-
cursor.classList.add('kb-yjs__cursor');
|
|
10
|
-
cursor.setAttribute('style', `border-color: ${user.color};`);
|
|
11
|
-
const userDiv = document.createElement('div');
|
|
12
|
-
userDiv.setAttribute('style', `background-color: ${user.color}`);
|
|
13
|
-
userDiv.insertBefore(document.createTextNode(user.name), null);
|
|
14
|
-
const nonbreakingSpace1 = document.createTextNode('\u2060');
|
|
15
|
-
const nonbreakingSpace2 = document.createTextNode('\u2060');
|
|
16
|
-
cursor.insertBefore(nonbreakingSpace1, null);
|
|
17
|
-
cursor.insertBefore(userDiv, null);
|
|
18
|
-
cursor.insertBefore(nonbreakingSpace2, null);
|
|
19
|
-
return cursor;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Default generator for the selection attributes
|
|
23
|
-
*/
|
|
24
|
-
export const defaultSelectionBuilder = (user) => {
|
|
25
|
-
return {
|
|
26
|
-
style: `background-color: ${user.color}70`,
|
|
27
|
-
class: 'kb-yjs__selection',
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
const rxValidColor = /^#[0-9a-fA-F]{6}$/;
|
|
31
|
-
export const createDecorations = (state, extension, createCursor, createSelection) => {
|
|
32
|
-
const decorations = [];
|
|
33
|
-
const remoteStates = extension.getRemoteStates();
|
|
34
|
-
if (remoteStates.length === 0) {
|
|
35
|
-
return DecorationSet.create(state.doc, []);
|
|
36
|
-
}
|
|
37
|
-
for (const remoteState of remoteStates) {
|
|
38
|
-
if (remoteState.cursor != null) {
|
|
39
|
-
const user = remoteState.user || {};
|
|
40
|
-
if (user.color == null) {
|
|
41
|
-
user.color = '#ffa500';
|
|
42
|
-
}
|
|
43
|
-
else if (!rxValidColor.test(user.color)) {
|
|
44
|
-
// We only support 6-digit RGB colors in y-prosemirror
|
|
45
|
-
console.warn('A user uses an unsupported color format', user);
|
|
46
|
-
}
|
|
47
|
-
if (user.name == null) {
|
|
48
|
-
user.name = `User: ${remoteState.clientId}`;
|
|
49
|
-
}
|
|
50
|
-
const cursor = remoteState.cursor;
|
|
51
|
-
let anchor = cursor.anchor || null;
|
|
52
|
-
let head = cursor.head || null;
|
|
53
|
-
if (anchor !== null && head !== null) {
|
|
54
|
-
const maxsize = Math.max(state.doc.content.size - 1, 0);
|
|
55
|
-
anchor = Math.min(anchor, maxsize);
|
|
56
|
-
head = Math.min(head, maxsize);
|
|
57
|
-
decorations.push(Decoration.widget(head, () => createCursor(user, remoteState.clientId), {
|
|
58
|
-
key: remoteState.clientId + '',
|
|
59
|
-
side: 10,
|
|
60
|
-
}));
|
|
61
|
-
const from = Math.min(anchor, head);
|
|
62
|
-
const to = Math.max(anchor, head);
|
|
63
|
-
decorations.push(Decoration.inline(from, to, createSelection(user, remoteState.clientId), {
|
|
64
|
-
inclusiveEnd: true,
|
|
65
|
-
inclusiveStart: false,
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return DecorationSet.create(state.doc, decorations);
|
|
71
|
-
};
|
|
72
|
-
export const remoteSelectionPlugin = (extension, editor, { cursorBuilder = defaultCursorBuilder, selectionBuilder = defaultSelectionBuilder, } = {}) => {
|
|
73
|
-
return new Plugin({
|
|
74
|
-
key: remoteSelectionPluginKey,
|
|
75
|
-
state: {
|
|
76
|
-
init(_, state) {
|
|
77
|
-
return createDecorations(state, extension, cursorBuilder, selectionBuilder);
|
|
78
|
-
},
|
|
79
|
-
apply(tr, prevState, _oldState, newState) {
|
|
80
|
-
const remoteCursorState = tr.getMeta(remoteSelectionPluginKey);
|
|
81
|
-
// TODO validate: isChangeOrigin
|
|
82
|
-
// const state = remoteSelectionPluginKey.getState(newState);
|
|
83
|
-
if ((remoteCursorState?.isChangeOrigin) ||
|
|
84
|
-
(remoteCursorState?.remotePositionUpdated)) {
|
|
85
|
-
return createDecorations(newState, extension, cursorBuilder, selectionBuilder);
|
|
86
|
-
}
|
|
87
|
-
return prevState.map(tr.mapping, tr.doc);
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
props: {
|
|
91
|
-
decorations: (state) => {
|
|
92
|
-
return remoteSelectionPluginKey.getState(state);
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|