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
import { Plugin, PluginKey, Transaction } from "prosemirror-state" | |
import { BlockInfo, getBlockInfoFromPos } from "../helpers/getBlockInfoFromPos" | |
// ProseMirror Plugin which automatically assigns indices to ordered list items per nesting level. | |
const PLUGIN_KEY = new PluginKey(`numbered-list-indexing`) | |
interface Options { | |
getListCharacter?: (positionDetails: { depth: number; index: number }) => string | |
} |
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
defmodule SuperWeb.Plug.AssetNotFound do | |
import Plug.Conn | |
alias Plug.Conn | |
def init(opts) do | |
%{ | |
at: Keyword.fetch!(opts, :at) |> Plug.Router.Utils.split(), | |
only: {Keyword.fetch!(opts, :only), []} | |
} | |
end |
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
import React, { useEffect, useRef, useState } from "react" | |
import { createReactBlockSpec } from "@blocknote/react" | |
import { SuperedBlockNoteEditor } from "../../BlockNoteEditor" | |
import useReload from "../../../useReload" | |
export const TABLE_OF_CONTENTS_TYPE = "table-of-contents" | |
interface Heading { | |
id: string | |
level: 1 | 2 | 3 | 4 |
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
public class ImmutableCounter { | |
private final int counter; | |
public ImmutableCounter(int num) { | |
this.counter = num; | |
} | |
public int getCount() { | |
return this.counter; | |
} |
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
import java.util.HashMap; | |
// This class is broken, follow the TODOs | |
public class ImmutableDemo { | |
// TODO: How to prevent external actors from accessing the map directly? | |
public HashMap<String,String> map; | |
public ImmutableDemo() { | |
this.map = new HashMap<String, String>(); | |
this.map.put("Important", "OKAY"); |
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
defmodule Super.RepoTest do | |
use Super.DataCase, async: true | |
require Logger | |
@skipped_schemas [UserService.User] | |
defp tenant_schemas do | |
{:ok, mods} = :application.get_key(:super, :modules) | |
Enum.map(mods, fn mod -> |
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
var links = document.getElementsByTagName('a'); | |
var params = new URLSearchParams(window.location.search); | |
var utmParams = {}; | |
params.forEach(function (val, name) { | |
if (name.startsWith('utm_')) { | |
utmParams[name] = val; | |
} | |
}); |
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
export const SpaceLayoutEditor = { | |
// Not important for the integration, just something for my specific use case | |
recentItems: [], | |
mounted() { | |
// IMPORTANT LINE: LiveView -> React data flow | |
this.handleEvent("react.update_items", ({ items }: { items: string }) => { | |
const newItems: SpaceItem[] = JSON.parse(items) | |
this.mountEditor(newItems) | |
}) |
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
export const SpaceLayoutEditor = { | |
mounted() { | |
// I use webpack chunks to reduce LiveView entry file size | |
import(/* webpackChunkName: "space-layout-editor-lv" */ '../entry/space-layout-editor-lv').then((mounter) => { | |
this.unmountComponent = mounter.default(this.el.id, { | |
editorOpts: this.editorOpts() | |
}) | |
}).catch(console.error) | |
}, |
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 example is just copy/pasted from my code base. The gist of it is that `this.pushEventTo` on the hook | |
* will send an event over the LiveView channel that is processed by the component/LiveView that's mounted at | |
* that element. | |
* | |
* I recommend using pushEventTo instead of pushEvent because I've run into situations where the event gets sent | |
* to the incorrect component or LiveView. | |
*/ | |
const GeneratePDFButton = { | |
mounted() { |
NewerOlder