@fastkit/vui 0.8.10 → 0.8.13
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/vui.cjs.js +6 -16
- package/dist/vui.cjs.prod.js +6 -16
- package/dist/vui.css +25 -50
- package/dist/vui.d.ts +78 -7157
- package/dist/vui.min.css +1 -1
- package/dist/vui.min.css.map +1 -1
- package/dist/vui.mjs +7 -17
- package/package.json +13 -13
- package/src/components/VWysiwygEditor/extensions/linter/Linter.tsx +39 -43
- package/src/plugin.tsx +3 -11
|
@@ -20,7 +20,7 @@ function resolveWysiwygLinterFixMessage(message: WysiwygLinterFixMessage) {
|
|
|
20
20
|
return typeof message === 'function' ? message() : message;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
function renderIcon(view: EditorView
|
|
23
|
+
function renderIcon(view: EditorView, issue: Issue) {
|
|
24
24
|
const { level = 'warning' } = issue;
|
|
25
25
|
const icon = document.createElement('div');
|
|
26
26
|
const message = resolveWysiwygLinterFixMessage(issue.message);
|
|
@@ -81,7 +81,7 @@ export interface WysiwygLinterStorage {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export const WysiwygLinter = createWysiwygExtension((ctx) => {
|
|
84
|
-
function showMenu(view: EditorView
|
|
84
|
+
function showMenu(view: EditorView, issue: Issue, event: Event) {
|
|
85
85
|
const message = resolveWysiwygLinterFixMessage(issue.message);
|
|
86
86
|
const variant = ctx.vui.setting('containedVariant');
|
|
87
87
|
const scope = ctx.vui.setting(`${issue.level}Scope`);
|
|
@@ -166,49 +166,45 @@ export const WysiwygLinter = createWysiwygExtension((ctx) => {
|
|
|
166
166
|
};
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
new
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return runAll(doc);
|
|
175
|
-
},
|
|
176
|
-
apply(transaction, oldState) {
|
|
177
|
-
return transaction.docChanged
|
|
178
|
-
? runAll(transaction.doc)
|
|
179
|
-
: oldState;
|
|
180
|
-
},
|
|
169
|
+
const linterPlugin: Plugin<any> = new Plugin({
|
|
170
|
+
key: new PluginKey('linter'),
|
|
171
|
+
state: {
|
|
172
|
+
init(_, { doc }) {
|
|
173
|
+
return runAll(doc);
|
|
181
174
|
},
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return this.getState(state);
|
|
185
|
-
},
|
|
186
|
-
handleClick(view, _, event) {
|
|
187
|
-
const info = getIssueElementByEvent(event.target);
|
|
188
|
-
if (!info) {
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const { issue } = info;
|
|
193
|
-
const { from, to } = issue;
|
|
194
|
-
|
|
195
|
-
const focus = () =>
|
|
196
|
-
view.dispatch(
|
|
197
|
-
view.state.tr
|
|
198
|
-
.setSelection(
|
|
199
|
-
TextSelection.create(view.state.doc, from, to),
|
|
200
|
-
)
|
|
201
|
-
.scrollIntoView(),
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
focus();
|
|
205
|
-
|
|
206
|
-
showMenu(view, issue, event);
|
|
207
|
-
return true;
|
|
208
|
-
},
|
|
175
|
+
apply(transaction, oldState) {
|
|
176
|
+
return transaction.docChanged ? runAll(transaction.doc) : oldState;
|
|
209
177
|
},
|
|
210
|
-
}
|
|
211
|
-
|
|
178
|
+
},
|
|
179
|
+
props: {
|
|
180
|
+
decorations(state) {
|
|
181
|
+
return linterPlugin.getState(state);
|
|
182
|
+
},
|
|
183
|
+
handleClick(view, _, event) {
|
|
184
|
+
const info = getIssueElementByEvent(event.target);
|
|
185
|
+
if (!info) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const { issue } = info;
|
|
190
|
+
const { from, to } = issue;
|
|
191
|
+
|
|
192
|
+
const focus = () =>
|
|
193
|
+
view.dispatch(
|
|
194
|
+
view.state.tr
|
|
195
|
+
.setSelection(TextSelection.create(view.state.doc, from, to))
|
|
196
|
+
.scrollIntoView(),
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
focus();
|
|
200
|
+
|
|
201
|
+
showMenu(view, issue, event);
|
|
202
|
+
return true;
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
return [linterPlugin];
|
|
212
208
|
},
|
|
213
209
|
});
|
|
214
210
|
});
|
package/src/plugin.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
installVueStackPlugin,
|
|
11
11
|
VueStackServiceOptions,
|
|
12
12
|
VueColorSchemePlugin,
|
|
13
|
+
onAppUnmount,
|
|
13
14
|
} from '@fastkit/vue-kit';
|
|
14
15
|
import { VButton } from './components/VButton';
|
|
15
16
|
|
|
@@ -46,14 +47,7 @@ declare module '@vue/runtime-core' {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
export class VuiPlugin {
|
|
49
|
-
static readonly installedApps = new Set<App>();
|
|
50
|
-
|
|
51
50
|
static install(app: App, opts: VuiPluginOptions) {
|
|
52
|
-
const { installedApps } = this;
|
|
53
|
-
if (installedApps.has(app)) return;
|
|
54
|
-
const unmountApp = app.unmount;
|
|
55
|
-
installedApps.add(app);
|
|
56
|
-
|
|
57
51
|
const { colorScheme, stack, uiSettings } = opts;
|
|
58
52
|
|
|
59
53
|
// ColorScheme
|
|
@@ -88,11 +82,9 @@ export class VuiPlugin {
|
|
|
88
82
|
app.provide(VuiInjectionKey, $vui);
|
|
89
83
|
app.config.globalProperties.$vui = $vui;
|
|
90
84
|
|
|
91
|
-
app
|
|
92
|
-
installedApps.delete(app);
|
|
85
|
+
onAppUnmount(app, () => {
|
|
93
86
|
delete app.config.globalProperties.$vui;
|
|
94
|
-
|
|
95
|
-
};
|
|
87
|
+
});
|
|
96
88
|
}
|
|
97
89
|
}
|
|
98
90
|
|