mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
[@wordpress/autop] add new definitions (#36221)
This commit is contained in:
committed by
Daniel Rosenwasser
parent
0acd9c210d
commit
35871c9954
45
types/wordpress__autop/index.d.ts
vendored
Normal file
45
types/wordpress__autop/index.d.ts
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// Type definitions for @wordpress/autop 2.3
|
||||
// Project: https://github.com/WordPress/gutenberg/tree/master/packages/autop/README.md
|
||||
// Definitions by: Derek Sifford <https://github.com/dsifford>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.4
|
||||
|
||||
/**
|
||||
* Replaces double line-breaks with paragraph elements.
|
||||
*
|
||||
* @remarks
|
||||
* A group of regex replaces used to identify text formatted with newlines and
|
||||
* replace double line-breaks with HTML paragraph tags. The remaining line-
|
||||
* breaks after conversion become `<br />` tags, unless br is set to 'false'.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { autop } from '@wordpress/autop';
|
||||
* autop( 'my text' ); // "<p>my text</p>"
|
||||
* ```
|
||||
*
|
||||
* @param text - The text which has to be formatted.
|
||||
* @param br - Optional. If set, will convert all remaining line- breaks
|
||||
* after paragraphing. Default `true`.
|
||||
*
|
||||
* @returns Text which has been converted into paragraph tags.
|
||||
*/
|
||||
export function autop(text: string, br?: boolean): string;
|
||||
|
||||
/**
|
||||
* Replaces `<p>` tags with two line breaks. "Opposite" of autop().
|
||||
*
|
||||
* @remarks
|
||||
* Replaces `<p>` tags with two line breaks except where the `<p>` has attributes.
|
||||
* Unifies whitespace. Indents `<li>`, `<dt>` and `<dd>` for better readability.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { removep } from '@wordpress/autop';
|
||||
* removep( '<p>my text</p>' ); // "my text"
|
||||
* ```
|
||||
* @param html - The content from the editor.
|
||||
*
|
||||
* @returns The content with stripped paragraph tags.
|
||||
*/
|
||||
export function removep(html: string): string;
|
||||
19
types/wordpress__autop/tsconfig.json
Normal file
19
types/wordpress__autop/tsconfig.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"@wordpress/autop": ["wordpress__autop"]
|
||||
}
|
||||
},
|
||||
"files": ["index.d.ts", "wordpress__autop-tests.ts"]
|
||||
}
|
||||
1
types/wordpress__autop/tslint.json
Normal file
1
types/wordpress__autop/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
5
types/wordpress__autop/wordpress__autop-tests.ts
Normal file
5
types/wordpress__autop/wordpress__autop-tests.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { autop, removep } from '@wordpress/autop';
|
||||
|
||||
autop('my text'); // "<p>my text</p>"
|
||||
|
||||
removep('<p>my text</p>'); // "my text"
|
||||
Reference in New Issue
Block a user