-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e506532
commit 21e29b2
Showing
7 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.bb-scroll { | ||
max-width: 100%; | ||
padding: 5px; | ||
overflow:auto; | ||
border: 1px solid; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { preprocessAttr, toNode } from "../utils/common"; | ||
|
||
/** | ||
* Parse the user provided height and return a valid height value | ||
* @param {Number} heightValue obtains the input of the user entered height (default is 700) | ||
* @returns A validated number less than 0. | ||
*/ | ||
function parseHeight(heightValue) { | ||
const maxHeight = 700; | ||
const parsedHeight = heightValue && heightValue.trim() !== "" | ||
? heightValue.replace ( /[^\d.]/g, '' ) | ||
: 0; | ||
|
||
if(parsedHeight && parsedHeight >= 0 && parsedHeight <= maxHeight) { | ||
return parsedHeight; | ||
} else { | ||
// if the value = 0 then nothing will be returned | ||
return parsedHeight === 0 | ||
? 0 | ||
: maxHeight; | ||
} | ||
} | ||
|
||
/** | ||
* @file Adds [scroll] to bbcode | ||
* @example [scroll]content[/scroll] | ||
*/ | ||
export const scroll = (node) => { | ||
const attrs = preprocessAttr(node.attrs)._default; | ||
const heightInput = parseHeight(attrs); | ||
return toNode("div", { class: "bb-scroll",style: `height: ${heightInput}px` }, node.content); | ||
} |