@prosekit/lit 0.0.23 → 0.1.0
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/dist/_tsup-dts-rollup.d.ts +6 -47
- package/dist/prosekit-lit-autocomplete-popover.js +1 -1
- package/dist/prosekit-lit-combo-box-input.d.ts +1 -1
- package/dist/prosekit-lit-combo-box-item.d.ts +1 -1
- package/dist/prosekit-lit-combo-box-list.d.ts +1 -1
- package/dist/prosekit-lit-combo-box.d.ts +1 -1
- package/dist/prosekit-lit-combo-box.js +4 -4
- package/dist/prosekit-lit-inline-popover.d.ts +1 -1
- package/dist/prosekit-lit-inline-popover.js +2 -2
- package/dist/prosekit-lit-popover.d.ts +1 -1
- package/package.json +5 -13
- package/dist/prosekit-lit-code-block-popover.d.ts +0 -3
- package/dist/prosekit-lit-code-block-popover.js +0 -140
@@ -1,16 +1,12 @@
|
|
1
1
|
import { AutoUpdateOptions } from '@floating-ui/dom';
|
2
|
-
import { CommandArgs } from '@prosekit/core';
|
3
2
|
import { ComputePositionConfig } from '@floating-ui/dom';
|
4
3
|
import { CSSResult } from 'lit';
|
5
4
|
import { Editor } from '@prosekit/core';
|
6
5
|
import type { EditorView } from '@prosekit/pm/view';
|
7
|
-
import { Extension } from '@prosekit/core';
|
8
|
-
import { ExtensionTyping } from '@prosekit/core';
|
9
6
|
import { Keymap } from '@prosekit/core';
|
10
7
|
import { LitElement } from 'lit';
|
11
8
|
import { Options } from 'tsup';
|
12
9
|
import { PropertyValues } from 'lit';
|
13
|
-
import type { ProseMirrorNode } from '@prosekit/pm/model';
|
14
10
|
import { ReactiveController } from 'lit';
|
15
11
|
import { ReactiveControllerHost } from 'lit';
|
16
12
|
import { TemplateResult } from 'lit';
|
@@ -143,28 +139,6 @@ export { AutoUpdateOptions }
|
|
143
139
|
|
144
140
|
export declare const blockComponentStyles: CSSResult;
|
145
141
|
|
146
|
-
export declare class CodeBlockPopover extends Popover implements Partial<CodeBlockPopoverProps> {
|
147
|
-
editor?: Editor;
|
148
|
-
/** @hidden */
|
149
|
-
private controller;
|
150
|
-
protected updated(): void;
|
151
|
-
}
|
152
|
-
|
153
|
-
export declare class CodeBlockPopoverController implements ReactiveController {
|
154
|
-
private host;
|
155
|
-
reference: Element | null;
|
156
|
-
private editor;
|
157
|
-
private cleanup;
|
158
|
-
constructor(host: ReactiveControllerHost);
|
159
|
-
setEditor(editor: Editor): void;
|
160
|
-
private defineExtension;
|
161
|
-
hostDisconnected(): void;
|
162
|
-
}
|
163
|
-
|
164
|
-
export declare interface CodeBlockPopoverProps {
|
165
|
-
editor: Editor;
|
166
|
-
}
|
167
|
-
|
168
142
|
export declare class ComboBox extends Popover {
|
169
143
|
onDismiss?: VoidFunction;
|
170
144
|
private listManager;
|
@@ -265,19 +239,6 @@ export declare const defaultPopoverOptions_alias_2: PopoverOptions;
|
|
265
239
|
|
266
240
|
export declare function defaultQueryBuilder(match: RegExpExecArray): string;
|
267
241
|
|
268
|
-
/**
|
269
|
-
* Returns a ProseKit extension that call `onSelect` when the text selection is
|
270
|
-
* insert into a code block, and `onDismiss` when it is not.
|
271
|
-
*/
|
272
|
-
export declare function defineCodeBlockSelect(options: {
|
273
|
-
onSelect: (info: {
|
274
|
-
pos: number;
|
275
|
-
node: ProseMirrorNode;
|
276
|
-
dom: HTMLElement;
|
277
|
-
}) => void;
|
278
|
-
onDismiss: () => void;
|
279
|
-
}): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
280
|
-
|
281
242
|
export declare function getVirtualSelectionElement(view: EditorView): Range | undefined;
|
282
243
|
|
283
244
|
export declare class InlinePopover extends Popover implements Partial<InlinePopoverProps> {
|
@@ -468,24 +429,22 @@ export { propNames_3 as propNames_alias_3 }
|
|
468
429
|
export { propNames_3 as propNames_alias_4 }
|
469
430
|
|
470
431
|
declare const propNames_4: never[];
|
471
|
-
export { propNames_4 as
|
432
|
+
export { propNames_4 as propNames_alias_8 }
|
472
433
|
export { propNames_4 as propNames_alias_9 }
|
473
434
|
|
474
435
|
declare const propNames_5: never[];
|
436
|
+
export { propNames_5 as propNames_alias_10 }
|
475
437
|
export { propNames_5 as propNames_alias_11 }
|
476
|
-
export { propNames_5 as propNames_alias_12 }
|
477
438
|
|
478
|
-
export declare const
|
439
|
+
export declare const propNames_alias_12: readonly ["editor", "popoverOptions"];
|
479
440
|
|
480
|
-
export declare const
|
441
|
+
export declare const propNames_alias_13: readonly ["active", "reference", "options", "autoUpdate", "autoUpdateOptions"];
|
481
442
|
|
482
443
|
export declare const propNames_alias_5: readonly ["editor", "regex", "popoverOptions"];
|
483
444
|
|
484
|
-
export declare const propNames_alias_6: readonly ["
|
485
|
-
|
486
|
-
export declare const propNames_alias_7: readonly ["onDismiss"];
|
445
|
+
export declare const propNames_alias_6: readonly ["onDismiss"];
|
487
446
|
|
488
|
-
export declare const
|
447
|
+
export declare const propNames_alias_7: readonly ["placeholder"];
|
489
448
|
|
490
449
|
export declare function queryClosestAutocompleteItem(element?: Element | null): AutocompleteItem | null;
|
491
450
|
|
@@ -3,10 +3,10 @@ import {
|
|
3
3
|
} from "./chunk-KJJEZNYD.js";
|
4
4
|
import "./chunk-XOVIMVFL.js";
|
5
5
|
import "./chunk-6P3YKUWI.js";
|
6
|
-
import "./chunk-PCXKL6TA.js";
|
7
6
|
import {
|
8
7
|
Popover
|
9
8
|
} from "./chunk-HNKGDXIJ.js";
|
9
|
+
import "./chunk-PCXKL6TA.js";
|
10
10
|
import {
|
11
11
|
__decorateClass
|
12
12
|
} from "./chunk-ZN7DMIEB.js";
|
@@ -1,3 +1,3 @@
|
|
1
1
|
export { ComboBoxItem_alias_1 as ComboBoxItem } from './_tsup-dts-rollup';
|
2
2
|
export { ComboBoxItemProps_alias_1 as ComboBoxItemProps } from './_tsup-dts-rollup';
|
3
|
-
export {
|
3
|
+
export { propNames_alias_9 as propNames } from './_tsup-dts-rollup';
|
@@ -1,3 +1,3 @@
|
|
1
1
|
export { ComboBoxList_alias_1 as ComboBoxList } from './_tsup-dts-rollup';
|
2
2
|
export { ComboBoxListProps_alias_1 as ComboBoxListProps } from './_tsup-dts-rollup';
|
3
|
-
export {
|
3
|
+
export { propNames_alias_11 as propNames } from './_tsup-dts-rollup';
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import "./chunk-XTIVRSSC.js";
|
2
|
-
import {
|
3
|
-
ListManager
|
4
|
-
} from "./chunk-PCXKL6TA.js";
|
5
1
|
import {
|
6
2
|
Popover
|
7
3
|
} from "./chunk-HNKGDXIJ.js";
|
4
|
+
import {
|
5
|
+
ListManager
|
6
|
+
} from "./chunk-PCXKL6TA.js";
|
7
|
+
import "./chunk-XTIVRSSC.js";
|
8
8
|
import {
|
9
9
|
comboBoxContext
|
10
10
|
} from "./chunk-C4MW43I4.js";
|
@@ -1,4 +1,4 @@
|
|
1
1
|
export { PopoverOptions_alias_1 as PopoverOptions } from './_tsup-dts-rollup';
|
2
|
-
export {
|
2
|
+
export { propNames_alias_12 as propNames } from './_tsup-dts-rollup';
|
3
3
|
export { InlinePopoverProps } from './_tsup-dts-rollup';
|
4
4
|
export { InlinePopover } from './_tsup-dts-rollup';
|
@@ -10,7 +10,7 @@ import "@prosekit/core";
|
|
10
10
|
import { customElement, property } from "lit/decorators.js";
|
11
11
|
|
12
12
|
// src/components/inline-popover/controller.ts
|
13
|
-
import {
|
13
|
+
import { defineUpdateHandler } from "@prosekit/core";
|
14
14
|
import "lit";
|
15
15
|
|
16
16
|
// src/components/inline-popover/helpers.ts
|
@@ -92,7 +92,7 @@ var InlinePopoverController = class {
|
|
92
92
|
if (!editor) {
|
93
93
|
return;
|
94
94
|
}
|
95
|
-
const extension =
|
95
|
+
const extension = defineUpdateHandler(() => this.update());
|
96
96
|
(_a = this.cleanupExtension) == null ? void 0 : _a.call(this);
|
97
97
|
this.cleanupExtension = editor.use(extension);
|
98
98
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
export { AutoUpdateOptions } from './_tsup-dts-rollup';
|
2
2
|
export { PopoverOptions_alias_2 as PopoverOptions } from './_tsup-dts-rollup';
|
3
|
-
export {
|
3
|
+
export { propNames_alias_13 as propNames } from './_tsup-dts-rollup';
|
4
4
|
export { PopoverProps } from './_tsup-dts-rollup';
|
5
5
|
export { Popover } from './_tsup-dts-rollup';
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/lit",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0
|
4
|
+
"version": "0.1.0",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -50,11 +50,6 @@
|
|
50
50
|
"import": "./dist/prosekit-lit-autocomplete-popover.js",
|
51
51
|
"default": "./dist/prosekit-lit-autocomplete-popover.js"
|
52
52
|
},
|
53
|
-
"./code-block-popover": {
|
54
|
-
"types": "./dist/prosekit-lit-code-block-popover.d.ts",
|
55
|
-
"import": "./dist/prosekit-lit-code-block-popover.js",
|
56
|
-
"default": "./dist/prosekit-lit-code-block-popover.js"
|
57
|
-
},
|
58
53
|
"./combo-box": {
|
59
54
|
"types": "./dist/prosekit-lit-combo-box.d.ts",
|
60
55
|
"import": "./dist/prosekit-lit-combo-box.js",
|
@@ -92,9 +87,9 @@
|
|
92
87
|
"dependencies": {
|
93
88
|
"@floating-ui/dom": "^1.5.3",
|
94
89
|
"@lit/context": "^1.0.1",
|
95
|
-
"@prosekit/core": "^0.0
|
96
|
-
"@prosekit/extensions": "^0.0
|
97
|
-
"@prosekit/pm": "^0.0
|
90
|
+
"@prosekit/core": "^0.1.0",
|
91
|
+
"@prosekit/extensions": "^0.1.0",
|
92
|
+
"@prosekit/pm": "^0.1.0",
|
98
93
|
"@superhuman/command-score": "^0.5.0",
|
99
94
|
"lit": "^3.0.2"
|
100
95
|
},
|
@@ -104,7 +99,7 @@
|
|
104
99
|
"tsup": "^7.2.0",
|
105
100
|
"typescript": "^5.2.2",
|
106
101
|
"vitest": "^0.34.6",
|
107
|
-
"vue": "^3.3.
|
102
|
+
"vue": "^3.3.8"
|
108
103
|
},
|
109
104
|
"scripts": {
|
110
105
|
"build:tsup": "tsup",
|
@@ -128,9 +123,6 @@
|
|
128
123
|
"autocomplete-popover": [
|
129
124
|
"./dist/prosekit-lit-autocomplete-popover.d.ts"
|
130
125
|
],
|
131
|
-
"code-block-popover": [
|
132
|
-
"./dist/prosekit-lit-code-block-popover.d.ts"
|
133
|
-
],
|
134
126
|
"combo-box": [
|
135
127
|
"./dist/prosekit-lit-combo-box.d.ts"
|
136
128
|
],
|
@@ -1,140 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
Popover
|
3
|
-
} from "./chunk-HNKGDXIJ.js";
|
4
|
-
import {
|
5
|
-
__decorateClass
|
6
|
-
} from "./chunk-ZN7DMIEB.js";
|
7
|
-
|
8
|
-
// src/components/code-block-popover/index.ts
|
9
|
-
import { offset } from "@floating-ui/dom";
|
10
|
-
import { customElement, property } from "lit/decorators.js";
|
11
|
-
|
12
|
-
// src/components/code-block-popover/controller.ts
|
13
|
-
import "@prosekit/core";
|
14
|
-
import "lit";
|
15
|
-
|
16
|
-
// src/components/code-block-popover/code-block-select.ts
|
17
|
-
import { definePlugin } from "@prosekit/core";
|
18
|
-
import { ProseMirrorPlugin } from "@prosekit/pm/state";
|
19
|
-
function defineCodeBlockSelect(options) {
|
20
|
-
let prevState = null;
|
21
|
-
const plugin = new ProseMirrorPlugin({
|
22
|
-
view: () => {
|
23
|
-
return {
|
24
|
-
update: (view) => {
|
25
|
-
const currState = getState(view);
|
26
|
-
if ((prevState == null ? void 0 : prevState.pos) !== (currState == null ? void 0 : currState.pos) || (prevState == null ? void 0 : prevState.dom) !== (currState == null ? void 0 : currState.dom)) {
|
27
|
-
if (currState) {
|
28
|
-
options.onSelect(currState);
|
29
|
-
} else {
|
30
|
-
options.onDismiss();
|
31
|
-
}
|
32
|
-
}
|
33
|
-
prevState = currState;
|
34
|
-
}
|
35
|
-
};
|
36
|
-
}
|
37
|
-
});
|
38
|
-
return definePlugin(plugin);
|
39
|
-
}
|
40
|
-
function getState(view) {
|
41
|
-
const { $from, $to } = view.state.selection;
|
42
|
-
if ($from.sameParent($to)) {
|
43
|
-
const node = $from.parent;
|
44
|
-
if (isCodeBlock(node)) {
|
45
|
-
const pos = $from.before();
|
46
|
-
const dom = view.nodeDOM(pos);
|
47
|
-
if (dom) {
|
48
|
-
return { pos, node, dom };
|
49
|
-
}
|
50
|
-
}
|
51
|
-
}
|
52
|
-
return null;
|
53
|
-
}
|
54
|
-
function isCodeBlock(node) {
|
55
|
-
return node.type.spec.code && node.isTextblock;
|
56
|
-
}
|
57
|
-
|
58
|
-
// src/components/code-block-popover/controller.ts
|
59
|
-
var CodeBlockPopoverController = class {
|
60
|
-
constructor(host) {
|
61
|
-
this.host = host;
|
62
|
-
this.reference = null;
|
63
|
-
this.editor = null;
|
64
|
-
this.cleanup = null;
|
65
|
-
this.host.addController(this);
|
66
|
-
}
|
67
|
-
setEditor(editor) {
|
68
|
-
if (this.editor !== editor) {
|
69
|
-
this.editor = editor;
|
70
|
-
this.defineExtension();
|
71
|
-
this.host.requestUpdate();
|
72
|
-
}
|
73
|
-
}
|
74
|
-
defineExtension() {
|
75
|
-
var _a;
|
76
|
-
const editor = this.editor;
|
77
|
-
if (!editor)
|
78
|
-
return;
|
79
|
-
const extension = defineCodeBlockSelect({
|
80
|
-
onSelect: ({ dom }) => {
|
81
|
-
if (this.reference !== dom) {
|
82
|
-
this.reference = dom;
|
83
|
-
this.host.requestUpdate();
|
84
|
-
}
|
85
|
-
},
|
86
|
-
onDismiss: () => {
|
87
|
-
if (this.reference !== null) {
|
88
|
-
this.reference = null;
|
89
|
-
this.host.requestUpdate();
|
90
|
-
}
|
91
|
-
}
|
92
|
-
});
|
93
|
-
(_a = this.cleanup) == null ? void 0 : _a.call(this);
|
94
|
-
this.cleanup = editor.use(extension);
|
95
|
-
}
|
96
|
-
hostDisconnected() {
|
97
|
-
var _a;
|
98
|
-
(_a = this.cleanup) == null ? void 0 : _a.call(this);
|
99
|
-
this.cleanup = null;
|
100
|
-
}
|
101
|
-
};
|
102
|
-
|
103
|
-
// src/components/code-block-popover/index.ts
|
104
|
-
var propNames = ["editor"];
|
105
|
-
var CodeBlockPopover = class extends Popover {
|
106
|
-
constructor() {
|
107
|
-
super(...arguments);
|
108
|
-
/** @hidden */
|
109
|
-
this.controller = new CodeBlockPopoverController(this);
|
110
|
-
}
|
111
|
-
updated() {
|
112
|
-
var _a, _b;
|
113
|
-
if (this.editor) {
|
114
|
-
this.controller.setEditor(this.editor);
|
115
|
-
}
|
116
|
-
this.reference = (_b = (_a = this.controller) == null ? void 0 : _a.reference) != null ? _b : void 0;
|
117
|
-
this.active = !!this.reference;
|
118
|
-
this.options = popoverOptions;
|
119
|
-
super.updated();
|
120
|
-
}
|
121
|
-
};
|
122
|
-
__decorateClass([
|
123
|
-
property({ attribute: false, type: Object })
|
124
|
-
], CodeBlockPopover.prototype, "editor", 2);
|
125
|
-
CodeBlockPopover = __decorateClass([
|
126
|
-
customElement("prosekit-code-block-popover")
|
127
|
-
], CodeBlockPopover);
|
128
|
-
var popoverOptions = {
|
129
|
-
placement: "top-start",
|
130
|
-
strategy: "absolute",
|
131
|
-
middleware: [
|
132
|
-
offset((options) => {
|
133
|
-
return -options.rects.floating.height;
|
134
|
-
})
|
135
|
-
]
|
136
|
-
};
|
137
|
-
export {
|
138
|
-
CodeBlockPopover,
|
139
|
-
propNames
|
140
|
-
};
|