Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove defineClassAs function #119

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions javascript/src/html_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,9 @@ class Paragraph {
*/
export interface HTMLProcessorOptions {
/**
* This class name is added to the containing block
* when the BudouX is applied.
*
* The caller is responsible for defining the class.
* {@link defineClassAs} can append a `<style>` element
* that defines the default styles as a class.
* This class name is added to the containing block when the BudouX is applied.
* The containing block should have following CSS properties to make it work.
* `{ word-break: keep-all; overflow-wrap: break-word; }`
*
* When falsy, an inline style is set instead.
*/
Expand Down Expand Up @@ -461,15 +458,4 @@ export class HTMLProcessor {
style.wordBreak = 'keep-all';
style.overflowWrap = 'break-word';
}

/**
* Append a `<style>` element that defines the default styles as a class.
* @param document The document to append to.
* @param className The CSS class name.
*/
static defineClassAs(document: Document, className: string): void {
const style = document.createElement('style');
style.textContent = `.${className} { word-break: keep-all; overflow-wrap: break-word; }`;
document.head.appendChild(style);
}
}