volar-service-prettyhtml 0.0.31 → 0.0.33
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/index.d.ts +3 -3
- package/index.js +7 -6
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as prettyhtml from '@starptech/prettyhtml';
|
|
2
|
-
import type { DocumentSelector, Result, ServiceContext, ServicePlugin, TextDocument } from '@volar/language-service';
|
|
3
|
-
export type
|
|
2
|
+
import type { DocumentSelector, FormattingOptions, Result, ServiceContext, ServicePlugin, TextDocument } from '@volar/language-service';
|
|
3
|
+
export type PrettyhtmlFormattingOptions = Parameters<typeof prettyhtml>[1];
|
|
4
4
|
export declare function create({ documentSelector, isFormattingEnabled, getFormattingOptions, }?: {
|
|
5
5
|
documentSelector?: DocumentSelector;
|
|
6
6
|
isFormattingEnabled?(document: TextDocument, context: ServiceContext): Result<boolean>;
|
|
7
|
-
getFormattingOptions?(document: TextDocument, context: ServiceContext): Result<
|
|
7
|
+
getFormattingOptions?(document: TextDocument, options: FormattingOptions, context: ServiceContext): Result<PrettyhtmlFormattingOptions>;
|
|
8
8
|
}): ServicePlugin;
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.create = void 0;
|
|
4
4
|
const prettyhtml = require("@starptech/prettyhtml");
|
|
5
|
-
function create({ documentSelector = ['html'], isFormattingEnabled = () => true, getFormattingOptions = () =>
|
|
5
|
+
function create({ documentSelector = ['html'], isFormattingEnabled = () => true, getFormattingOptions = (_document, options) => {
|
|
6
|
+
return {
|
|
7
|
+
tabWidth: options.tabSize,
|
|
8
|
+
useTabs: !options.insertSpaces,
|
|
9
|
+
};
|
|
10
|
+
}, } = {}) {
|
|
6
11
|
return {
|
|
7
12
|
name: 'prettyhtml',
|
|
8
13
|
create(context) {
|
|
@@ -13,11 +18,7 @@ function create({ documentSelector = ['html'], isFormattingEnabled = () => true,
|
|
|
13
18
|
if (!await isFormattingEnabled(document, context))
|
|
14
19
|
return;
|
|
15
20
|
const oldRangeText = document.getText(range);
|
|
16
|
-
const newRangeText = prettyhtml(oldRangeText,
|
|
17
|
-
tabWidth: options.tabSize,
|
|
18
|
-
useTabs: !options.insertSpaces,
|
|
19
|
-
...await getFormattingOptions(document, context),
|
|
20
|
-
}).contents;
|
|
21
|
+
const newRangeText = prettyhtml(oldRangeText, await getFormattingOptions(document, options, context)).contents;
|
|
21
22
|
if (newRangeText === oldRangeText)
|
|
22
23
|
return [];
|
|
23
24
|
const newText = document.getText({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-prettyhtml",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.33",
|
|
4
4
|
"description": "Integrate prettyhtml into Volar",
|
|
5
5
|
"homepage": "https://github.com/volarjs/services/tree/master/packages/prettyhtml",
|
|
6
6
|
"bugs": "https://github.com/volarjs/services/issues",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"optional": true
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "d04c9ea5f5b58c5e0b6db9a65a8aba1a5a2ed9ef"
|
|
38
38
|
}
|