0.1.32 • Published 1 year ago

embed-fbcmt-client v0.1.32

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

embed-fbcmt (Embed Facebook Comment Plugin)

npm.io npm version

GitHub license

Test CodeQL ESLint Prettier TypeScript Checker Declaration Try build

This is a plugin allow embed Facebook Comment Plugin to website SPA

Demo: https://anime-vsub.github.io/embed-fbcmt?href=https://google.com&no_socket=true&num_posts=20

Usage

Append this code to location show comment:

<iframe src="https://anime-vsub.github.io/embed-fbcmt?<options>"></iframe>

All mentioned options of FB comment plugin are available. In addition, you can also use some of the following custom options:

OptionTypeDefaultDescription
langcode langen_USlanguage the plugin will display (example: vi_VN, ja_JP...)
loader_bgcolorrgba(0,0,0,0.8)adjust background color when plugin is loading
loader_textcolorwhiteadjust text color when plugin is loading
originhost name*domain name will be sent the message. you can specify the hostname of the embedded website to increase security
no_socketbooleanfalsewhether to disable WebSocket to save resources
activebooleantrueif this plugin is enabled if false then the plugin displays a blank page
no_popupbooleanfalseremove loading popup and use error warnings when you customize them

Package NPM

This package allows you to send change requests to the plugin without losing the SDK reload time. A useful thing for SPA website

Install

pnpm add embed-fbcmt-client

You can use this plugin anywhere I will give an example with Vue

<template>
   <button @click="setPropValue(cmtRef, 'lang', 'ja_JP')">Change lang to Japanese</button>

   <iframe ref="cmtRef" src="https://anime-vsub.github.io/embed-fbcmt?https://google.com&lang=en_US" />

</template>

<script lang="ts" setup>
import { ref } from "vue"
import { setPropValue } from "embed-fbcmt-client/vue"

const cmtRef = ref<HTMLIFrameElement>()
</script>

Functions

function setPropValue(el: HTMLIFrameElement | Ref<HTMLIFrameElement>, propName: string, value: string): Promise<void>
  • Options:
    • el: iframe embed plugin
    • propName: option name set
    • value: value set to prop
  • Return: Promise<void> a promise that resolves when the set option succeeds or fails
function listenEvent(
  el: HTMLIFrameElement,
  cb: (event: { type: "success" | "loading" | "error"; code: CODES }) => void
): () => void
  • Options:
    • el: iframe embed plugin
    • cb: this function is cakked every time something changes in the embed
  • Return: () => void cancel
function listenResize(
  el: HTMLIFrameElement,
  type: "width" | "height",
  cb: (size: number) => void
): () => void
  • Options:
    • el: iframe embed plugin
    • cb: this function is cakked every time something changes in the embed
  • Return: () => void cancel

For vue

function useEmbed(el: HTMLIFrameElement | Ref<HTMLIFrameElement>): {
   code: CODES // code status embed
   loading: boolean // true is loading
   error: boolean // true is error emited
}

component:

<template>
   <EmbedFbCmt href="https://google.com" />
</template>

<script lang="ts" setup>
import { EmbedFbCmt } from "embed-fbcmt-client/vue"
</script>
function useEmbedSize(
  el: HTMLIFrameElement | Ref<HTMLIFrameElement | undefined> | undefined
): {
  width: Ref<number>
  height: Ref<number>
}
function useEmbedHeight(
  el: HTMLIFrameElement | Ref<HTMLIFrameElement | undefined> | undefined
): Ref<number>
0.1.30

1 year ago

0.1.31

1 year ago

0.1.32

1 year ago

0.1.10

1 year ago

0.1.11

1 year ago

0.1.12

1 year ago

0.1.13

1 year ago

0.1.14

1 year ago

0.1.15

1 year ago

0.1.27

1 year ago

0.1.28

1 year ago

0.1.29

1 year ago

0.1.21

1 year ago

0.1.22

1 year ago

0.1.23

1 year ago

0.1.26

1 year ago

0.1.16

1 year ago

0.1.8

1 year ago

0.1.17

1 year ago

0.1.7

1 year ago

0.1.18

1 year ago

0.1.19

1 year ago

0.1.9

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.0.7

1 year ago