npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@momsfriendlydevco/embed-gdocs

v2.1.0

Published

Simple, agnostic component to embed a Google Doc into a webpage

Downloads

48

Readme

@MomsFriendlyDevCo/Embed-GDocs

Simple, agnostic component to embed a Google Doc into a webpage.

Features:

  • Simple API to include a Google-Doc embed within any webpage
  • Platform and framework agnostic - works as plain JS with no dependencies
  • Included fixes for common issues with embeds (various style fixes, unminify links, retarget links to open in other tags)
<html>
<head>
	<title>@MomsFriendlyDevCo/Embed-GDocs Example</title>
	<script src="/dist/embed-gdocs.js"></script>
	<script type="module">
	import embedGDoc from '/dist/embed-gdocs.js';

	window.addEventListener('load', ()=> {
		embedGDoc({
			selector: '#gdoc',
			url: 'https://docs.google.com/document/d/e/2PACX-1vTasmjm8_rI_tzzzMs0xl5AhjafHXCPs33uyq6VShbMepnlkumS9rDBkxbEs0AAoAtdMRm-dmoGXxbR/pub?embedded=true',
		});
	});
	</script>
</head>
<body>
	<div id="gdoc"></div>
</body>
</html>

API

embedGDoc(url, options)

import embedGDoc from '@momsfriendlydevco/embed-gdoc';

Insert a Google document within a given element.

Options are:

| Option | Type | Default | Description | |-----------------------|--------------------------|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | selector | String / HTMLElement | | Either the DOM node to replace or a selector to use | | url | String | | The Google Docs published URL to embed - this generally ends in /pub?embedded=true | | urlOptions | Object | | Additional Fetch options when retrieving the document from the url | | keepStyle | Boolean | true | Keep the source document style, if false this removes the style completely | | fixContentTrim | Boolean | true | Remove the outer wrapping of the element and just use the embedded content | | fixWidth | Boolean | true | Remove page width restrictions | | fixParaMargins | Boolean | true | Add slight margin to paragraphs | | fixTableWidth | Boolean | true | Remove table width restrictions | | fixPadding | Boolean | true | Remove page padding | | fixLinkTargets | Boolean | true | Make all links open in a new tab instead of replacing the current one | | fixLinkShorten | Boolean | true | Remove Google tracking URL prefix from links | | fixImageTitleAsLink | Boolean | true | If an image "alternative text" (actually the title attribute) looks like a link make the image linkable - this is to fix how Google Docs weirdly handles image linking | | onLoad | Function | html => html | Called as (html:String) when the HTML has been loaded, expected to return the mutated input | | onMount | Function | el => null | Called as (el:DomElement) when the Dom element has been created but has not yet been added into the DOM, can mutate the input element |

clean(html, options)

import {clean} from '@momsfriendlydevco/embed-gdoc';
// OR
import clean from '@momsfriendlydevco/embed-gdoc/clean';

Take input HTML and return a "clean" version of the same fixing various issues. This is the actual worker of the other supplied functions.

Options are inherited from embedGDoc() but also include:

| Option | Type | Default | Description | |-----------------|------------|--------------------------|-----------------------------| | createElement | Function | document.createElement | How to create DOM fragments |

html(html, options)

import {html} from '@momsfriendlydevco/embed-gdoc';
// OR
import html from '@momsfriendlydevco/embed-gdoc/html';

Similar to embedGDoc() but return only the resulting HTML. This function is used mainly for backend scripts which wish to clean up the resulting HTML before serving it directly.

Options are inherited from embedGDoc() + clean().