chore: copy all 3rd css files

This commit is contained in:
thecodrr
2022-06-30 17:41:00 +05:00
parent dd66544ee8
commit 58e4702cdc
43 changed files with 17 additions and 328 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,4 @@
/// <reference types="react" />
import { MenuItem } from "./types";
export declare function useFocus(items: MenuItem[], onAction: (event: KeyboardEvent) => void, onClose: (event: KeyboardEvent) => void): {
focusIndex: number;

View File

@@ -1,4 +0,0 @@
/// <reference types="react" />
import { ToggleProps } from "react-toggle";
import "react-toggle/style.css";
export declare function Toggle(props: ToggleProps): JSX.Element;

View File

@@ -1,18 +0,0 @@
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import ReactToggle from "react-toggle";
import "react-toggle/style.css";
var css = ".react-toggle {\n display: flex;\n align-items: center;\n }\n \n .react-toggle-thumb {\n box-shadow: none;\n }\n \n .react-toggle-track {\n width: 30px;\n height: 18px;\n }\n \n .react-toggle-thumb {\n width: 16px;\n height: 16px;\n top: 0px;\n left: 1px;\n margin-top: 1px;\n }\n \n .react-toggle--checked .react-toggle-thumb {\n left: 13px;\n border-color: var(--primary);\n }\n \n .react-toggle:active:not(.react-toggle--disabled) .react-toggle-thumb {\n box-shadow: none;\n }\n \n .react-toggle--focus .react-toggle-thumb {\n box-shadow: none;\n }\n ";
export function Toggle(props) {
return (_jsxs(_Fragment, { children: [_jsx("style", { children: css }), _jsx(ReactToggle, __assign({ size: 20, onChange: function () { }, icons: false }, props))] }));
}

View File

@@ -1,5 +1,4 @@
/// <reference types="react" />
import "prism-themes/themes/prism-dracula.min.css";
import { CodeBlockAttributes } from "./code-block";
import { ReactNodeViewProps } from "../react/types";
export declare function CodeblockComponent(props: ReactNodeViewProps<CodeBlockAttributes>): JSX.Element;

View File

@@ -65,7 +65,6 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
import { useEffect, useRef, useState } from "react";
import { isLanguageLoaded, loadLanguage } from "./loader";
import { refractor } from "refractor/lib/core";
import "prism-themes/themes/prism-dracula.min.css";
import { Flex, Text } from "rebass";
import Languages from "./languages.json";
import { Input } from "@rebass/forms";

View File

@@ -1,6 +1,5 @@
import { Extension } from "@tiptap/core";
import codemark from "prosemirror-codemark";
// import "prosemirror-codemark/dist/codemark.css";
export var Codemark = Extension.create({
name: "codemarkPlugin",
addProseMirrorPlugins: function () {

View File

@@ -1,3 +0,0 @@
import { Link } from "./link";
export * from "./link";
export default Link;

View File

@@ -1,3 +0,0 @@
import { Link } from "./link";
export * from "./link";
export default Link;

View File

@@ -1 +0,0 @@
export declare const Link: import("@tiptap/core").Mark<import("@tiptap/extension-link").LinkOptions, any>;

View File

@@ -1,91 +0,0 @@
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
import { jsx as _jsx } from "react/jsx-runtime";
import TiptapLink from "@tiptap/extension-link";
import { Plugin, PluginKey } from "prosemirror-state";
import { showPopup } from "../../components/popup-presenter";
import { ToolbarGroup } from "../../toolbar/components/toolbar-group";
var linkHoverPluginKey = new PluginKey("linkHover");
export var Link = TiptapLink.extend({
addProseMirrorPlugins: function () {
var _this = this;
var _a;
var linkRef = null;
return __spreadArray(__spreadArray([], __read((((_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)) || [])), false), [
new Plugin({
key: linkHoverPluginKey,
props: {
handleDOMEvents: {
mouseover: function (view, event) {
var _a;
if (event.target instanceof HTMLElement &&
((_a = event.target) === null || _a === void 0 ? void 0 : _a.classList.contains("ProseMirror"))) {
return;
}
if (event.target instanceof HTMLElement &&
event.target.nodeName === "A") {
if (linkRef)
return;
var pos_1 = view.posAtDOM(event.target, 0);
var node_1 = view.state.doc.nodeAt(pos_1);
console.log(node_1, pos_1);
if (!(node_1 === null || node_1 === void 0 ? void 0 : node_1.isText) ||
node_1.marks.length <= 0 ||
!node_1.marks.some(function (mark) { return mark.type === _this.type; }))
return;
linkRef = showPopup({
popup: function () { return (_jsx(ToolbarGroup, { force: true, tools: ["editLink", "removeLink", "openLink"], editor: _this.editor, selectedNode: {
node: node_1,
from: pos_1,
to: pos_1 + node_1.nodeSize,
}, sx: {
bg: "background",
boxShadow: "menu",
borderRadius: "default",
p: 1,
} })); },
theme: _this.editor.storage.theme,
blocking: false,
focusOnRender: false,
position: {
target: event.target,
align: "center",
location: "top",
isTargetAbsolute: true,
},
});
}
else if (linkRef) {
linkRef();
linkRef = null;
}
},
},
},
}),
], false);
},
});

View File

@@ -1,3 +1,2 @@
import { Node } from "@tiptap/core";
import "katex/dist/katex.min.css";
export declare const MathInline: Node<any, any>;

View File

@@ -1,7 +1,6 @@
import { Node, mergeAttributes } from "@tiptap/core";
import { inputRules } from "prosemirror-inputrules";
import { makeInlineMathInputRule, REGEX_INLINE_MATH_DOLLARS, mathPlugin, } from "./plugin";
import "katex/dist/katex.min.css";
export var MathInline = Node.create({
name: "math_inline",
group: "inline math",

View File

@@ -25,11 +25,11 @@ interface SchemaSpecJson<N extends string = any, M extends string = any> extends
}
declare type MathSpecNodeT = SchemaSpecNodeT<typeof mathSchemaSpec>;
declare type MathSpecMarkT = SchemaSpecMarkT<typeof mathSchemaSpec>;
export declare const mathSchemaSpec: SchemaSpecJson<"math_inline" | "paragraph" | "text" | "doc" | "math_display", "math_select">;
export declare const mathSchemaSpec: SchemaSpecJson<"paragraph" | "text" | "doc" | "math_inline" | "math_display", "math_select">;
/**
* Use the prosemirror-math default SchemaSpec to create a new Schema.
*/
export declare function createMathSchema(): Schema<"math_inline" | "paragraph" | "text" | "doc" | "math_display", "math_select">;
export declare function createMathSchema(): Schema<"paragraph" | "text" | "doc" | "math_inline" | "math_display", "math_select">;
/**
* Create a new SchemaSpec by adding math nodes to an existing spec.

View File

@@ -1,2 +0,0 @@
import { Fragment, Node as ProsemirrorNode, NodeType } from "prosemirror-model";
export declare function createCell(cellType: NodeType, cellContent?: Fragment | ProsemirrorNode | Array<ProsemirrorNode>): ProsemirrorNode | null | undefined;

View File

@@ -1,6 +0,0 @@
export function createCell(cellType, cellContent) {
if (cellContent) {
return cellType.createChecked(null, cellContent);
}
return cellType.createAndFill();
}

View File

@@ -1,2 +0,0 @@
import { Fragment, Node as ProsemirrorNode, Schema } from "prosemirror-model";
export declare function createTable(schema: Schema, rowsCount: number, colsCount: number, withHeaderRow: boolean, cellContent?: Fragment | ProsemirrorNode | Array<ProsemirrorNode>): ProsemirrorNode;

View File

@@ -1,24 +0,0 @@
import { createCell } from "./createCell";
import { getTableNodeTypes } from "./getTableNodeTypes";
export function createTable(schema, rowsCount, colsCount, withHeaderRow, cellContent) {
var types = getTableNodeTypes(schema);
var headerCells = [];
var cells = [];
for (var index = 0; index < colsCount; index += 1) {
var cell = createCell(types.cell, cellContent);
if (cell) {
cells.push(cell);
}
if (withHeaderRow) {
var headerCell = createCell(types.header_cell, cellContent);
if (headerCell) {
headerCells.push(headerCell);
}
}
}
var rows = [];
for (var index = 0; index < rowsCount; index += 1) {
rows.push(types.row.createChecked(null, withHeaderRow && index === 0 ? headerCells : cells));
}
return types.table.createChecked(null, rows);
}

View File

@@ -1,2 +0,0 @@
import { KeyboardShortcutCommand } from '@tiptap/core';
export declare const deleteTableWhenAllCellsSelected: KeyboardShortcutCommand;

View File

@@ -1,27 +0,0 @@
import { findParentNodeClosestToPos } from '@tiptap/core';
import { isCellSelection } from './isCellSelection';
export var deleteTableWhenAllCellsSelected = function (_a) {
var editor = _a.editor;
var selection = editor.state.selection;
if (!isCellSelection(selection)) {
return false;
}
var cellCount = 0;
var table = findParentNodeClosestToPos(selection.ranges[0].$from, function (node) {
return node.type.name === 'table';
});
table === null || table === void 0 ? void 0 : table.node.descendants(function (node) {
if (node.type.name === 'table') {
return false;
}
if (['tableCell', 'tableHeader'].includes(node.type.name)) {
cellCount += 1;
}
});
var allCellsSelected = cellCount === selection.ranges.length;
if (!allCellsSelected) {
return false;
}
editor.commands.deleteTable();
return true;
};

View File

@@ -1,4 +0,0 @@
import { NodeType, Schema } from 'prosemirror-model';
export declare function getTableNodeTypes(schema: Schema): {
[key: string]: NodeType;
};

View File

@@ -1,14 +0,0 @@
export function getTableNodeTypes(schema) {
if (schema.cached.tableNodeTypes) {
return schema.cached.tableNodeTypes;
}
var roles = {};
Object.keys(schema.nodes).forEach(function (type) {
var nodeType = schema.nodes[type];
if (nodeType.spec.tableRole) {
roles[nodeType.spec.tableRole] = nodeType;
}
});
schema.cached.tableNodeTypes = roles;
return roles;
}

View File

@@ -1,2 +0,0 @@
import { CellSelection } from 'prosemirror-tables';
export declare function isCellSelection(value: unknown): value is CellSelection;

View File

@@ -1,4 +0,0 @@
import { CellSelection } from 'prosemirror-tables';
export function isCellSelection(value) {
return value instanceof CellSelection;
}

View File

@@ -1,3 +1,4 @@
/// <reference types="react" />
import "./extensions";
import { EditorOptions } from "@tiptap/react";
import Toolbar from "./toolbar";

View File

@@ -1,5 +0,0 @@
import { Editor } from "../../../types";
export interface ElementHoverHandler<T extends string> {
nodeName: T;
handler: (editor: Editor) => void;
}

View File

@@ -1,25 +0,0 @@
import { useEffect } from "react";
import { LinkHandler } from "./link";
var elementHandlers = [LinkHandler];
function HoverHandler(props) {
var editor = props.editor;
useEffect(function () {
function onMouseOver(e) {
var _a;
if (!(e.target instanceof HTMLElement))
return;
if ((_a = e.target) === null || _a === void 0 ? void 0 : _a.classList.contains("ProseMirror"))
return;
var nodeName = e.target.nodeName.toLowerCase();
var handler = elementHandlers.find(function (h) { return h.nodeName === nodeName; });
if (!handler)
return;
handler.handler(editor);
}
window.addEventListener("mouseover", onMouseOver);
return function () {
window.removeEventListener("mouseover", onMouseOver);
};
}, []);
return null;
}

View File

@@ -1,2 +0,0 @@
import { ElementHoverHandler } from "./handler";
export declare const LinkHandler: ElementHoverHandler<"a">;

View File

@@ -1,4 +0,0 @@
export var LinkHandler = {
nodeName: "a",
handler: function (editor) { },
};

View File

@@ -1,3 +0,0 @@
/// <reference types="react" />
import { FloatingMenuProps } from "./types";
export declare function ImageToolbar(props: FloatingMenuProps): JSX.Element;

View File

@@ -1,15 +0,0 @@
import { jsx as _jsx } from "react/jsx-runtime";
import { ToolbarGroup } from "../components/toolbar-group";
export function ImageToolbar(props) {
var editor = props.editor;
return (_jsx(ToolbarGroup, { editor: editor, tools: [
"imageAlignLeft",
"imageAlignCenter",
"imageAlignRight",
"imageProperties",
], sx: {
boxShadow: "menu",
borderRadius: "default",
bg: "background",
} }));
}

View File

@@ -13,7 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Flex, Text } from "rebass";
import { useCallback } from "react";
import { Popup } from "../components/popup";
import { Toggle } from "../../components/toggle";
import { Checkbox } from "@rebass/forms";
import { InlineInput } from "../../components/inline-input";
export function ImageProperties(props) {
var height = props.height, width = props.width, float = props.float, editor = props.editor, onClose = props.onClose;
@@ -34,7 +34,7 @@ export function ImageProperties(props) {
};
editor.chain().setImageSize(size).run();
}, [width, height]);
return (_jsx(Popup, __assign({ title: "Image properties", onClose: onClose }, { children: _jsxs(Flex, __assign({ sx: { width: ["auto", 300], flexDirection: "column", p: 1 } }, { children: [_jsxs(Flex, __assign({ sx: { justifyContent: "space-between", alignItems: "center" } }, { children: [_jsx(Text, __assign({ variant: "body" }, { children: "Floating?" })), _jsx(Toggle, { checked: float, onClick: function () {
return (_jsx(Popup, __assign({ title: "Image properties", onClose: onClose }, { children: _jsxs(Flex, __assign({ sx: { width: ["auto", 300], flexDirection: "column", p: 1 } }, { children: [_jsxs(Flex, __assign({ sx: { justifyContent: "space-between", alignItems: "center" } }, { children: [_jsx(Text, __assign({ variant: "body" }, { children: "Floating?" })), _jsx(Checkbox, { checked: float, onClick: function () {
return editor
.chain()
.setImageAlignment({ float: !float, align: "left" })

View File

@@ -1,3 +1,4 @@
/// <reference types="react" />
import { Editor } from "@tiptap/core";
import { MenuButton } from "../../components/menu/types";
import { ToolProps } from "../types";

View File

@@ -1,3 +1,5 @@
ln -s $(realpath ./src/styles.css) $(realpath ./dist/)
cp ./node_modules/katex/dist/katex.min.css $(realpath ./styles/)
cp ./node_modules/prism-themes/themes/prism-dracula.min.css $(realpath ./styles/)/prism-theme.css
ln -s $(realpath ./src/styles.css) $(realpath ./styles/)
yarn tsc --watch

View File

@@ -1,46 +0,0 @@
import ReactToggle, { ToggleProps } from "react-toggle";
import "react-toggle/style.css";
const css = `.react-toggle {
display: flex;
align-items: center;
}
.react-toggle-thumb {
box-shadow: none;
}
.react-toggle-track {
width: 30px;
height: 18px;
}
.react-toggle-thumb {
width: 16px;
height: 16px;
top: 0px;
left: 1px;
margin-top: 1px;
}
.react-toggle--checked .react-toggle-thumb {
left: 13px;
border-color: var(--primary);
}
.react-toggle:active:not(.react-toggle--disabled) .react-toggle-thumb {
box-shadow: none;
}
.react-toggle--focus .react-toggle-thumb {
box-shadow: none;
}
`;
export function Toggle(props: ToggleProps) {
return (
<>
<style>{css}</style>
<ReactToggle size={20} onChange={() => {}} icons={false} {...props} />
</>
);
}

View File

@@ -1,7 +1,6 @@
import { useEffect, useRef, useState } from "react";
import { isLanguageLoaded, loadLanguage } from "./loader";
import { refractor } from "refractor/lib/core";
import "prism-themes/themes/prism-dracula.min.css";
import { Flex, Text } from "rebass";
import Languages from "./languages.json";
import { Input } from "@rebass/forms";

View File

@@ -1,6 +1,5 @@
import { Extension } from "@tiptap/core";
import codemark from "prosemirror-codemark";
// import "prosemirror-codemark/dist/codemark.css";
export const Codemark = Extension.create({
name: "codemarkPlugin",

View File

@@ -6,8 +6,6 @@ import {
mathPlugin,
} from "./plugin";
import "katex/dist/katex.min.css";
export const MathInline = Node.create({
name: "math_inline",
group: "inline math",

View File

@@ -1,7 +1,6 @@
import { Button, Flex, Text } from "rebass";
import { useCallback, useEffect, useState } from "react";
import { Popup } from "../components/popup";
import { Toggle } from "../../components/toggle";
import { Input, Textarea } from "@rebass/forms";
import {
Embed,

View File

@@ -1,8 +1,7 @@
import { Button, Flex, Text } from "rebass";
import { useCallback, useEffect, useState } from "react";
import { Flex, Text } from "rebass";
import { useCallback } from "react";
import { Popup } from "../components/popup";
import { Toggle } from "../../components/toggle";
import { Input, Textarea } from "@rebass/forms";
import { Checkbox } from "@rebass/forms";
import {
ImageAlignmentOptions,
ImageSizeOptions,
@@ -42,7 +41,7 @@ export function ImageProperties(props: ImagePropertiesProps) {
<Flex sx={{ width: ["auto", 300], flexDirection: "column", p: 1 }}>
<Flex sx={{ justifyContent: "space-between", alignItems: "center" }}>
<Text variant={"body"}>Floating?</Text>
<Toggle
<Checkbox
checked={float}
onClick={() =>
editor

1
packages/editor/styles/katex.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
code[class*=language-],pre[class*=language-]{color:#f8f8f2;background:0 0;text-shadow:0 1px rgba(0,0,0,.3);font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto;border-radius:.3em}:not(pre)>code[class*=language-],pre[class*=language-]{background:#282a36}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#6272a4}.token.punctuation{color:#f8f8f2}.namespace{opacity:.7}.token.constant,.token.deleted,.token.property,.token.symbol,.token.tag{color:#ff79c6}.token.boolean,.token.number{color:#bd93f9}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#50fa7b}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url,.token.variable{color:#f8f8f2}.token.atrule,.token.attr-value,.token.class-name,.token.function{color:#f1fa8c}.token.keyword{color:#8be9fd}.token.important,.token.regex{color:#ffb86c}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}