@fastkit/vui 0.12.8 → 0.12.10
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/LICENSE +1 -1
- package/dist/vui.css +2522 -2723
- package/dist/vui.css.map +1 -0
- package/dist/vui.d.ts +8760 -10172
- package/dist/vui.mjs +1704 -2490
- package/dist/vui.mjs.map +1 -0
- package/package.json +69 -61
- package/src/components/VApp/VApp.tsx +3 -1
- package/src/components/VAvatar/VAvatar.scss +62 -60
- package/src/components/VAvatar/VAvatar.tsx +6 -1
- package/src/components/VBreadcrumbs/VBreadcrumbs.scss +53 -51
- package/src/components/VBusyImage/VBusyImage.scss +50 -51
- package/src/components/VButton/VButton.scss +120 -118
- package/src/components/VButton/VButton.tsx +6 -1
- package/src/components/VButton/VButtonGroup.scss +21 -19
- package/src/components/VCard/VCard.scss +41 -42
- package/src/components/VCard/VCard.tsx +5 -0
- package/src/components/VCard/VCardActions.scss +9 -7
- package/src/components/VCard/VCardContent.scss +4 -2
- package/src/components/VCheckable/VCheckable.scss +79 -80
- package/src/components/VCheckable/VCheckable.tsx +1 -1
- package/src/components/VCheckbox/VCheckbox.scss +50 -48
- package/src/components/VCheckbox/VCheckbox.tsx +2 -2
- package/src/components/VChip/VChip.scss +61 -59
- package/src/components/VChip/VChip.tsx +6 -1
- package/src/components/VContentSwitcher/VContentSwitcher.scss +52 -50
- package/src/components/VControlField/VControlField.scss +148 -146
- package/src/components/VControlField/VControlField.tsx +3 -3
- package/src/components/VDataTable/VDataTable.scss +167 -168
- package/src/components/VDrawerLayout/VDrawerLayout.scss +27 -25
- package/src/components/VForm/VForm.tsx +3 -4
- package/src/components/VFormControl/VFormControl.scss +84 -82
- package/src/components/VFormControl/VFormControl.tsx +2 -3
- package/src/components/VGrid/VGridContainer.scss +5 -3
- package/src/components/VGrid/VGridItem.scss +4 -2
- package/src/components/VHero/VHero.scss +23 -21
- package/src/components/VIcon/VIcon.scss +19 -17
- package/src/components/VListTile/VListTile.scss +60 -58
- package/src/components/VListTile/VListTile.tsx +5 -0
- package/src/components/VNavigation/VNavigation.scss +12 -10
- package/src/components/VNavigation/VNavigationItem.scss +21 -19
- package/src/components/VNavigation/VNavigationItem.tsx +5 -0
- package/src/components/VOption/VOption.scss +55 -56
- package/src/components/VOption/VOption.tsx +2 -2
- package/src/components/VOptionGroup/VOptionGroup.scss +14 -12
- package/src/components/VOptionGroup/VOptionGroup.tsx +3 -1
- package/src/components/VPagination/VPagination.scss +81 -79
- package/src/components/VPagination/VPagination.tsx +1 -1
- package/src/components/VPaper/VPaper.scss +43 -41
- package/src/components/VRadio/VRadio.scss +52 -53
- package/src/components/VRadio/VRadio.tsx +2 -2
- package/src/components/VSelect/VSelect.scss +77 -75
- package/src/components/VSelect/VSelect.tsx +5 -2
- package/src/components/VSkeltonLoader/VSkeltonLoaderBone.scss +24 -22
- package/src/components/VSwitch/VSwitch.scss +96 -94
- package/src/components/VSwitch/VSwitch.tsx +2 -2
- package/src/components/VTabs/VTab.scss +59 -57
- package/src/components/VTabs/VTabs.scss +41 -39
- package/src/components/VTabs/VTabs.tsx +5 -2
- package/src/components/VTextCounter/VTextCounter.scss +4 -2
- package/src/components/VTextField/VTextField.scss +37 -35
- package/src/components/VTextField/VTextField.tsx +2 -2
- package/src/components/VTextarea/VTextarea.scss +33 -31
- package/src/components/VTextarea/VTextarea.tsx +2 -2
- package/src/components/VToolbar/VToolbar.scss +19 -17
- package/src/components/VToolbar/VToolbarEdge.scss +21 -19
- package/src/components/VToolbar/VToolbarMenu.scss +6 -4
- package/src/components/VToolbar/VToolbarMenu.tsx +5 -0
- package/src/components/VToolbar/VToolbarTitle.scss +19 -17
- package/src/components/index.ts +3 -1
- package/src/components/kits.ts +1 -1
- package/src/composables/control.ts +1 -1
- package/src/composables/form-selector.scss +20 -18
- package/src/composables/form-selector.tsx +5 -3
- package/src/index.ts +13 -2
- package/src/injections.ts +1 -1
- package/src/plugin.tsx +4 -4
- package/src/schemes/control.ts +2 -2
- package/src/service.tsx +5 -5
- package/src/styles/core/functions.scss +2 -2
- package/src/styles/index.scss +23 -9
- package/dist/tool/index.d.ts +0 -2
- package/dist/tool/index.d.ts.map +0 -1
- package/dist/tool/index.mjs +0 -193
- package/dist/tool/vite-plugin.d.ts +0 -25
- package/dist/tool/vite-plugin.d.ts.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/assets/builtins/color-scheme.ts +0 -9
- package/src/assets/builtins/media-match.ts +0 -3
- package/src/components/.DS_Store +0 -0
- package/src/components/VAvatar/.DS_Store +0 -0
- package/src/components/VChip/.DS_Store +0 -0
- package/src/components/VSkeltonLoader/.DS_Store +0 -0
- package/src/components/VTextField/.DS_Store +0 -0
- package/src/components/VWysiwygEditor/.DS_Store +0 -0
- package/src/components/VWysiwygEditor/VWysiwygEditor.scss +0 -66
- package/src/components/VWysiwygEditor/VWysiwygEditor.tsx +0 -354
- package/src/components/VWysiwygEditor/extensions/.DS_Store +0 -0
- package/src/components/VWysiwygEditor/extensions/color.ts +0 -72
- package/src/components/VWysiwygEditor/extensions/index.ts +0 -2
- package/src/components/VWysiwygEditor/extensions/linter/.DS_Store +0 -0
- package/src/components/VWysiwygEditor/extensions/linter/Linter.scss +0 -140
- package/src/components/VWysiwygEditor/extensions/linter/Linter.tsx +0 -210
- package/src/components/VWysiwygEditor/extensions/linter/LinterPlugin.ts +0 -65
- package/src/components/VWysiwygEditor/extensions/linter/index.ts +0 -5
- package/src/components/VWysiwygEditor/extensions/linter/plugins/BadWords.tsx +0 -50
- package/src/components/VWysiwygEditor/extensions/linter/plugins/HeadingLevel.ts +0 -39
- package/src/components/VWysiwygEditor/extensions/linter/plugins/Punctuation.ts +0 -49
- package/src/components/VWysiwygEditor/extensions/linter/plugins/index.ts +0 -3
- package/src/components/VWysiwygEditor/extensions/linter/utils.ts +0 -28
- package/src/components/VWysiwygEditor/index.ts +0 -4
- package/src/components/VWysiwygEditor/schemes.ts +0 -251
- package/src/components/VWysiwygEditor/tools/bullet-list.ts +0 -18
- package/src/components/VWysiwygEditor/tools/color.scss +0 -140
- package/src/components/VWysiwygEditor/tools/color.tsx +0 -90
- package/src/components/VWysiwygEditor/tools/format-bold.ts +0 -19
- package/src/components/VWysiwygEditor/tools/format-italic.ts +0 -18
- package/src/components/VWysiwygEditor/tools/format-underline.ts +0 -18
- package/src/components/VWysiwygEditor/tools/history.ts +0 -26
- package/src/components/VWysiwygEditor/tools/index.ts +0 -8
- package/src/components/VWysiwygEditor/tools/link.ts +0 -57
- package/src/components/VWysiwygEditor/tools/ordered-list.ts +0 -21
- package/src/tool/index.ts +0 -2
- package/src/tool/vite-plugin.ts +0 -266
- /package/{src/styles → dist}/after-effects/display-flow.scss +0 -0
- /package/{src/styles → dist}/after-effects/spacing.scss +0 -0
- /package/{src/styles → dist}/after-effects/text.scss +0 -0
- /package/{src/styles → dist}/after-effects.scss +0 -0
- /package/dist/{assets/builtins → builtins}/color-scheme.ts +0 -0
- /package/dist/{assets/builtins → builtins}/media-match.ts +0 -0
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import './Linter.scss';
|
|
2
|
-
|
|
3
|
-
import { Extension } from '@tiptap/core';
|
|
4
|
-
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
5
|
-
import { Plugin, PluginKey, TextSelection } from 'prosemirror-state';
|
|
6
|
-
import { Node as ProsemirrorNode } from 'prosemirror-model';
|
|
7
|
-
import {
|
|
8
|
-
WysiwygLinterPlugin,
|
|
9
|
-
WysiwygLinterResult as Issue,
|
|
10
|
-
WysiwygLinterFixMessage,
|
|
11
|
-
} from './LinterPlugin';
|
|
12
|
-
import { EditorView } from 'prosemirror-view';
|
|
13
|
-
import { createWysiwygExtension } from '../../schemes';
|
|
14
|
-
|
|
15
|
-
const PROBLEM_CLASS_NAME = 'v-linter__problem';
|
|
16
|
-
const ISSUE_ICON_CLASS_NAME = 'v-linter__issue-icon';
|
|
17
|
-
const ISSUE_DATASET_NAME = 'data-issue-id';
|
|
18
|
-
|
|
19
|
-
function resolveWysiwygLinterFixMessage(message: WysiwygLinterFixMessage) {
|
|
20
|
-
return typeof message === 'function' ? message() : message;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function renderIcon(view: EditorView, issue: Issue) {
|
|
24
|
-
const { level = 'warning' } = issue;
|
|
25
|
-
const icon = document.createElement('div');
|
|
26
|
-
const message = resolveWysiwygLinterFixMessage(issue.message);
|
|
27
|
-
|
|
28
|
-
icon.className = `${ISSUE_ICON_CLASS_NAME} ${level}-scope`;
|
|
29
|
-
icon.setAttribute(ISSUE_DATASET_NAME, issue.id);
|
|
30
|
-
|
|
31
|
-
if (typeof message === 'string') {
|
|
32
|
-
icon.title = message;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return icon;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function runAllLinterPlugins(
|
|
39
|
-
doc: ProsemirrorNode,
|
|
40
|
-
plugins: Array<typeof WysiwygLinterPlugin>,
|
|
41
|
-
) {
|
|
42
|
-
const decorations: [any?] = [];
|
|
43
|
-
|
|
44
|
-
const issues = plugins
|
|
45
|
-
.map((RegisteredLinterPlugin) => {
|
|
46
|
-
return new RegisteredLinterPlugin(doc).scan().getResults();
|
|
47
|
-
})
|
|
48
|
-
.flat();
|
|
49
|
-
|
|
50
|
-
issues.forEach((issue) => {
|
|
51
|
-
const { level = 'warning', icon } = issue;
|
|
52
|
-
const message = resolveWysiwygLinterFixMessage(issue.message);
|
|
53
|
-
decorations.push(
|
|
54
|
-
Decoration.inline(issue.from, issue.to, {
|
|
55
|
-
class: `${PROBLEM_CLASS_NAME} ${level}-scope`,
|
|
56
|
-
'data-issue-id': issue.id,
|
|
57
|
-
title: typeof message === 'string' ? message : undefined,
|
|
58
|
-
}),
|
|
59
|
-
);
|
|
60
|
-
if (icon) {
|
|
61
|
-
decorations.push(
|
|
62
|
-
Decoration.widget(issue.from, (view) => renderIcon(view, issue)),
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const decorationSet = DecorationSet.create(doc, decorations);
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
issues,
|
|
71
|
-
decorationSet,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface WysiwygLinterOptions {
|
|
76
|
-
plugins: Array<typeof WysiwygLinterPlugin>;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface WysiwygLinterStorage {
|
|
80
|
-
issues: Issue[];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export const WysiwygLinter = createWysiwygExtension((ctx) => {
|
|
84
|
-
function showMenu(view: EditorView, issue: Issue, event: Event) {
|
|
85
|
-
const message = resolveWysiwygLinterFixMessage(issue.message);
|
|
86
|
-
const variant = ctx.vui.setting('containedVariant');
|
|
87
|
-
const scope = ctx.vui.setting(`${issue.level}Scope`);
|
|
88
|
-
|
|
89
|
-
return ctx.vui.menu({
|
|
90
|
-
activator: event,
|
|
91
|
-
content: (stack) => (
|
|
92
|
-
<div class="v-linter__issue-menu__body">
|
|
93
|
-
<div
|
|
94
|
-
class={[
|
|
95
|
-
'v-linter__issue-menu__message',
|
|
96
|
-
`${scope}-scope ${variant}`,
|
|
97
|
-
]}>
|
|
98
|
-
{message}
|
|
99
|
-
</div>
|
|
100
|
-
{issue.fix.length && (
|
|
101
|
-
<div class="v-linter__issue-menu__fixers">
|
|
102
|
-
{issue.fix.map((fixer, index) => (
|
|
103
|
-
<div key={index} class="v-linter__issue-menu__fixer">
|
|
104
|
-
<button
|
|
105
|
-
type="button"
|
|
106
|
-
class="v-linter__issue-menu__fixer__button"
|
|
107
|
-
onClick={() => {
|
|
108
|
-
stack.close();
|
|
109
|
-
fixer.handler(view, issue);
|
|
110
|
-
}}>
|
|
111
|
-
<span class="v-linter__issue-menu__fixer__button__message">
|
|
112
|
-
{resolveWysiwygLinterFixMessage(fixer.message)}
|
|
113
|
-
</span>
|
|
114
|
-
</button>
|
|
115
|
-
</div>
|
|
116
|
-
))}
|
|
117
|
-
</div>
|
|
118
|
-
)}
|
|
119
|
-
</div>
|
|
120
|
-
),
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return Extension.create<WysiwygLinterOptions, WysiwygLinterStorage>({
|
|
125
|
-
name: 'linter',
|
|
126
|
-
|
|
127
|
-
addOptions() {
|
|
128
|
-
return {
|
|
129
|
-
plugins: [],
|
|
130
|
-
};
|
|
131
|
-
},
|
|
132
|
-
addStorage() {
|
|
133
|
-
return {
|
|
134
|
-
issues: [],
|
|
135
|
-
};
|
|
136
|
-
},
|
|
137
|
-
addProseMirrorPlugins() {
|
|
138
|
-
const { plugins } = this.options;
|
|
139
|
-
const { storage } = this;
|
|
140
|
-
|
|
141
|
-
const runAll = (doc: ProsemirrorNode) => {
|
|
142
|
-
const { issues, decorationSet } = runAllLinterPlugins(doc, plugins);
|
|
143
|
-
storage.issues = issues;
|
|
144
|
-
return decorationSet;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const getIssue = (id: string) =>
|
|
148
|
-
storage.issues.find((issue) => issue.id === id);
|
|
149
|
-
|
|
150
|
-
const getIssueElementByEvent = (
|
|
151
|
-
source: EventTarget | null,
|
|
152
|
-
):
|
|
153
|
-
| {
|
|
154
|
-
issue: Issue;
|
|
155
|
-
}
|
|
156
|
-
| undefined => {
|
|
157
|
-
if (!source || !(source instanceof HTMLElement)) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
const issueId = source.getAttribute(ISSUE_DATASET_NAME);
|
|
161
|
-
const issue = issueId && getIssue(issueId);
|
|
162
|
-
if (!issue) return;
|
|
163
|
-
|
|
164
|
-
return {
|
|
165
|
-
issue,
|
|
166
|
-
};
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
const linterPlugin: Plugin<any> = new Plugin({
|
|
170
|
-
key: new PluginKey('linter'),
|
|
171
|
-
state: {
|
|
172
|
-
init(_, { doc }) {
|
|
173
|
-
return runAll(doc);
|
|
174
|
-
},
|
|
175
|
-
apply(transaction, oldState) {
|
|
176
|
-
return transaction.docChanged ? runAll(transaction.doc) : oldState;
|
|
177
|
-
},
|
|
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];
|
|
208
|
-
},
|
|
209
|
-
});
|
|
210
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { VNodeChild } from 'vue';
|
|
2
|
-
import { Node as ProsemirrorNode } from 'prosemirror-model';
|
|
3
|
-
import { EditorView } from 'prosemirror-view';
|
|
4
|
-
import { cheepUUID } from './utils';
|
|
5
|
-
|
|
6
|
-
export type WysiwygLinterFixFn = (
|
|
7
|
-
view: EditorView,
|
|
8
|
-
issue: WysiwygLinterResult,
|
|
9
|
-
) => any;
|
|
10
|
-
|
|
11
|
-
export type WysiwygLinterFixMessage = string | (() => VNodeChild);
|
|
12
|
-
|
|
13
|
-
export interface WysiwygLinterFixer {
|
|
14
|
-
message: WysiwygLinterFixMessage;
|
|
15
|
-
handler: WysiwygLinterFixFn;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type WysiwygLinterResultLevel = 'warning' | 'error';
|
|
19
|
-
|
|
20
|
-
// fixers
|
|
21
|
-
export interface WysiwygLinterResult {
|
|
22
|
-
id: string;
|
|
23
|
-
icon: boolean;
|
|
24
|
-
level: WysiwygLinterResultLevel;
|
|
25
|
-
message: WysiwygLinterFixMessage;
|
|
26
|
-
from: number;
|
|
27
|
-
to: number;
|
|
28
|
-
fix: WysiwygLinterFixer[];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface RawLinterResult
|
|
32
|
-
extends Omit<WysiwygLinterResult, 'level' | 'fix' | 'id' | 'icon'> {
|
|
33
|
-
level?: WysiwygLinterResultLevel;
|
|
34
|
-
icon?: boolean;
|
|
35
|
-
fix?: WysiwygLinterFixer | WysiwygLinterFixer[];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export class WysiwygLinterPlugin {
|
|
39
|
-
protected doc: ProsemirrorNode;
|
|
40
|
-
|
|
41
|
-
private results: Array<WysiwygLinterResult> = [];
|
|
42
|
-
|
|
43
|
-
constructor(doc: ProsemirrorNode) {
|
|
44
|
-
this.doc = doc;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
record(result: RawLinterResult) {
|
|
48
|
-
const { fix = [], icon = false } = result;
|
|
49
|
-
this.results.push({
|
|
50
|
-
level: 'error',
|
|
51
|
-
id: cheepUUID(),
|
|
52
|
-
...result,
|
|
53
|
-
fix: Array.isArray(fix) ? fix : [fix],
|
|
54
|
-
icon,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
scan() {
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
getResults() {
|
|
63
|
-
return this.results;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { WysiwygLinterPlugin } from '../LinterPlugin';
|
|
2
|
-
|
|
3
|
-
export function WysiwygLinterBadWords(
|
|
4
|
-
words: string[],
|
|
5
|
-
): typeof WysiwygLinterPlugin {
|
|
6
|
-
const regex = new RegExp(`\\b(${words.join('|')})\\b`);
|
|
7
|
-
|
|
8
|
-
return class WysiwygLinterBadWords extends WysiwygLinterPlugin {
|
|
9
|
-
scan() {
|
|
10
|
-
this.doc.descendants((node: any, position: number) => {
|
|
11
|
-
if (!node.isText) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const matches = regex.exec(node.text);
|
|
16
|
-
|
|
17
|
-
if (matches) {
|
|
18
|
-
const fixValue = matches[0] + '!!!!!';
|
|
19
|
-
|
|
20
|
-
this.record({
|
|
21
|
-
level: 'warning',
|
|
22
|
-
message: `Try not to say '${matches[0]}'`,
|
|
23
|
-
from: position + matches.index,
|
|
24
|
-
to: position + matches.index + matches[0].length,
|
|
25
|
-
fix: [
|
|
26
|
-
{
|
|
27
|
-
message: () => (
|
|
28
|
-
<span>
|
|
29
|
-
<code>{fixValue}</code>に修正する。
|
|
30
|
-
</span>
|
|
31
|
-
),
|
|
32
|
-
handler: () => {
|
|
33
|
-
console.log('hoge');
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
message: 'どうにかする',
|
|
38
|
-
handler: () => {
|
|
39
|
-
console.log('hoge');
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { EditorView } from 'prosemirror-view';
|
|
2
|
-
import {
|
|
3
|
-
WysiwygLinterPlugin,
|
|
4
|
-
WysiwygLinterResult as Issue,
|
|
5
|
-
} from '../LinterPlugin';
|
|
6
|
-
|
|
7
|
-
export class WysiwygLinterHeadingLevel extends WysiwygLinterPlugin {
|
|
8
|
-
fixHeader(level: number) {
|
|
9
|
-
return function ({ state, dispatch }: EditorView, issue: Issue) {
|
|
10
|
-
dispatch(state.tr.setNodeMarkup(issue.from - 1, undefined, { level }));
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
scan() {
|
|
15
|
-
let lastHeadLevel: number | null = null;
|
|
16
|
-
|
|
17
|
-
this.doc.descendants((node, position) => {
|
|
18
|
-
if (node.type.name === 'heading') {
|
|
19
|
-
// Check whether heading levels fit under the current level
|
|
20
|
-
const { level } = node.attrs;
|
|
21
|
-
|
|
22
|
-
if (lastHeadLevel != null && level > lastHeadLevel + 1) {
|
|
23
|
-
this.record({
|
|
24
|
-
message: `Heading too small (${level} under ${lastHeadLevel})`,
|
|
25
|
-
from: position + 1,
|
|
26
|
-
to: position + 1 + node.content.size,
|
|
27
|
-
fix: {
|
|
28
|
-
message: '修正する',
|
|
29
|
-
handler: this.fixHeader(lastHeadLevel + 1),
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
lastHeadLevel = level;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { EditorView } from 'prosemirror-view';
|
|
2
|
-
import {
|
|
3
|
-
WysiwygLinterPlugin,
|
|
4
|
-
WysiwygLinterResult as Issue,
|
|
5
|
-
} from '../LinterPlugin';
|
|
6
|
-
|
|
7
|
-
export class WysiwygLinterPunctuation extends WysiwygLinterPlugin {
|
|
8
|
-
public regex = / ([,.!?:]) ?/g;
|
|
9
|
-
|
|
10
|
-
fix(replacement: any) {
|
|
11
|
-
return function ({ state, dispatch }: EditorView, issue: Issue) {
|
|
12
|
-
dispatch(
|
|
13
|
-
state.tr.replaceWith(
|
|
14
|
-
issue.from,
|
|
15
|
-
issue.to,
|
|
16
|
-
state.schema.text(replacement),
|
|
17
|
-
),
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
scan() {
|
|
23
|
-
this.doc.descendants((node, position) => {
|
|
24
|
-
if (!node.isText) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (!node.text) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const matches = this.regex.exec(node.text);
|
|
33
|
-
|
|
34
|
-
if (matches) {
|
|
35
|
-
this.record({
|
|
36
|
-
message: 'Suspicious spacing around punctuation',
|
|
37
|
-
from: position + matches.index,
|
|
38
|
-
to: position + matches.index + matches[0].length,
|
|
39
|
-
fix: {
|
|
40
|
-
message: 'Fix it!!!',
|
|
41
|
-
handler: this.fix(`${matches[1]} `),
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
let IDX = 256,
|
|
2
|
-
BUFFER: any;
|
|
3
|
-
const HEX: any = [];
|
|
4
|
-
while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
|
|
5
|
-
|
|
6
|
-
export function cheepUUID() {
|
|
7
|
-
let i = 0,
|
|
8
|
-
num,
|
|
9
|
-
out = '';
|
|
10
|
-
|
|
11
|
-
if (!BUFFER || IDX + 16 > 256) {
|
|
12
|
-
BUFFER = Array((i = 256));
|
|
13
|
-
while (i--) BUFFER[i] = (256 * Math.random()) | 0;
|
|
14
|
-
i = IDX = 0;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
for (; i < 16; i++) {
|
|
18
|
-
num = BUFFER[IDX + i];
|
|
19
|
-
if (i == 6) out += HEX[(num & 15) | 64];
|
|
20
|
-
else if (i == 8) out += HEX[(num & 63) | 128];
|
|
21
|
-
else out += HEX[num];
|
|
22
|
-
|
|
23
|
-
if (i & 1 && i > 1 && i < 11) out += '-';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
IDX++;
|
|
27
|
-
return out;
|
|
28
|
-
}
|