-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move printint to apputils and add support docs
- Loading branch information
1 parent
60cf15a
commit 7264b0d
Showing
7 changed files
with
66 additions
and
13 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Printd } from 'printd'; | ||
import { Widget } from '@phosphor/widgets'; | ||
|
||
/** | ||
* Symbol to use for a method that prints out out the object. | ||
*/ | ||
export const printSymbol = Symbol(); | ||
|
||
/** | ||
* Widgets who provide a custom way of printing themselves | ||
* should implement this interface. | ||
*/ | ||
export interface IPrintable { | ||
[printSymbol]: () => void; | ||
} | ||
|
||
/** | ||
* Returns whether an object implements a print method. | ||
*/ | ||
export function isPrintable(a: object): a is IPrintable { | ||
return printSymbol in a; | ||
} | ||
|
||
/** | ||
* Calls the print symbol on an object to print it. | ||
*/ | ||
export function print(a: IPrintable) { | ||
a[printSymbol](); | ||
} | ||
|
||
/** | ||
* Global print instance | ||
*/ | ||
const _PRINTD = new Printd(); | ||
|
||
/** | ||
* Use this as a print property for a widget that will | ||
* use the `printd` library to print the node, by | ||
* creating an iframe and copying the DOM into it. | ||
*/ | ||
export function printd(this: Widget) { | ||
_PRINTD.print(this.node); | ||
} |
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