volar-service-prettyhtml 0.0.31 → 0.0.32

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.
Files changed (3) hide show
  1. package/index.d.ts +3 -3
  2. package/index.js +7 -6
  3. 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 FormattingOptions = Parameters<typeof prettyhtml>[1];
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<FormattingOptions>;
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.31",
3
+ "version": "0.0.32",
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": "f7005aef724767786ee9fe943fa976231cc79bf1"
37
+ "gitHead": "717049e7dcd5c30f451f6db8eb71eaba43f74c83"
38
38
  }