more plugins for MilkDown and CSS for all

master
Niko PLP 3 months ago
parent f289170e74
commit fa0102f1f4
  1. 12
      ng-app/package.json
  2. 40
      ng-app/src/apps/MilkDownEditor.svelte
  3. 41
      ng-app/src/apps/PostMdViewer.svelte
  4. 2
      ng-app/src/apps/ProseMirrorEditor.svelte
  5. 2
      ng-app/src/apps/ProseMirrorViewer.svelte
  6. 15
      ng-app/src/lib/Document.svelte
  7. 41
      ng-app/src/styles.css
  8. 1
      ng-app/src/zeras.ts
  9. 3
      ng-app/tailwind.config.cjs
  10. 4
      ng-app/vite.config.ts
  11. 468
      pnpm-lock.yaml

@ -36,30 +36,42 @@
"@milkdown/core": "^7.4.0",
"@milkdown/ctx": "^7.2.0",
"@milkdown/plugin-collab": "^7.4.0",
"@milkdown/plugin-emoji": "^7.4.0",
"@milkdown/plugin-indent": "^7.4.0",
"@milkdown/plugin-math": "^7.4.0",
"@milkdown/plugin-prism": "^7.4.0",
"@milkdown/plugin-slash": "^7.4.0",
"@milkdown/preset-commonmark": "^7.4.0",
"@milkdown/preset-gfm": "^7.4.0",
"@milkdown/prose": "^7.2.0",
"@milkdown/theme-nord": "^7.4.0",
"@milkdown/transformer": "^7.2.0",
"@milkdown/utils": "^7.4.0",
"@popperjs/core": "^2.11.8",
"@replit/codemirror-lang-svelte": "^6.0.0",
"@sindresorhus/is": "4.6.0",
"@tailwindcss/typography": "^0.5.13",
"@tauri-apps/api": "2.0.0-alpha.8",
"@tauri-apps/plugin-barcode-scanner": "2.0.0-alpha.0",
"@tauri-apps/plugin-window": "2.0.0-alpha.1",
"async-proxy": "^0.4.1",
"char-regex": "1.0.2",
"classnames": "^2.3.2",
"codemirror": "^6.0.1",
"emojilib": "2.4.0",
"extend": "3.0.2",
"flowbite": "^1.6.5",
"flowbite-svelte": "^0.43.3",
"html5-qrcode": "^2.3.8",
"katex": "^0.16.11",
"lodash.debounce": "4.0.8",
"ng-sdk-js": "workspace:^0.1.0-preview.1",
"prism-themes": "^1.9.0",
"prosemirror-model": "^1.7.1",
"prosemirror-state": "^1.2.3",
"prosemirror-svelte": "^0.2.4",
"prosemirror-view": "^1.9.10",
"skin-tone": "2.0.0",
"style-mod": "^4.1.2",
"svelte-codemirror-editor": "^1.4.0",
"svelte-i18n": "^4.0.0",

@ -45,12 +45,36 @@
import { placeholder, placeholderCtx } from './milkdown-placeholder'
import { splitEditing, toggleSplitEditing } from '@milkdown-lab/plugin-split-editing'
import { SlashProvider, slashFactory } from '@milkdown/plugin-slash'
import { callCommand } from '@milkdown/utils';
import { emoji } from '@milkdown/plugin-emoji';
import { math } from '@milkdown/plugin-math';
import 'katex/dist/katex.min.css';
import { indent } from '@milkdown/plugin-indent';
import { prism } from '@milkdown/plugin-prism';
import 'prism-themes/themes/prism-nord.css'
export let commits = {};
const ydoc = new Y.Doc()
let editor;
let width;
let split = true;
function width_changed() {
if (!editor) return;
if (width < 768 && split) {
console.log("toggle down")
split = false;
editor.action(callCommand(toggleSplitEditing.key, true));
} else if (width >= 768 && !split) {
split = true;
console.log("toggle up")
editor.action(callCommand(toggleSplitEditing.key, false));
}
}
$: width, width_changed();
function slashPluginView(view) {
const content = document.createElement('div');
@ -79,7 +103,17 @@
ctx.set(slash.key, {
view: slashPluginView
})
}).use(slash).config(nord).use(commonmark).use(gfm).use(placeholder).use(splitEditing).use(collab).create();
}).use(slash)
.config(nord)
.use(commonmark)
.use(gfm)
.use(prism)
.use(indent)
.use(math)
.use(emoji)
.use(placeholder)
.use(splitEditing)
.use(collab).create();
ydoc.on('update', async (update, origin) => {
//console.log(update,origin);
@ -124,8 +158,8 @@
editor.action((ctx) => {
const editorView = ctx.get(editorViewCtx)
editorView.focus();
//toggleSplitEditing(ctx);
});
width_changed();
}
onMount(async ()=>{
@ -141,7 +175,7 @@
</script>
<div class="grow p-5 post-rich-text" style="min-height:300px;">
<div class="grow p-5 post-rich-text" style="min-height:300px;" bind:clientWidth={width}>
<div id="mdeditor" class="prosemirror-editor"></div>
</div>

@ -26,9 +26,11 @@
import {
cur_tab_register_on_save,
cur_tab_deregister_on_save,
cur_tab_branch_class
cur_tab_branch_class,
set_view_or_edit
} from "../tab";
import { t } from "svelte-i18n";
import{ PencilSquare } from "svelte-heros-v2";
import * as Y from 'yjs'
@ -38,12 +40,20 @@
import { nord } from '@milkdown/theme-nord';
import '@milkdown/theme-nord/style.css';
import { collab, collabServiceCtx } from '@milkdown/plugin-collab';
import "svelte-highlight/styles/github.css";
import { emoji } from '@milkdown/plugin-emoji';
import { math } from '@milkdown/plugin-math';
import 'katex/dist/katex.min.css';
import { indent } from '@milkdown/plugin-indent';
import { prism } from '@milkdown/plugin-prism';
import 'prism-themes/themes/prism-nord.css'
export let commits = {};
const ydoc = new Y.Doc()
let editor;
let has_content = false;
async function setup() {
editor = await Editor.make().config((ctx) => {
@ -52,7 +62,15 @@
...prev,
editable:() => false,
}))
}).config(nord).use(commonmark).use(gfm).use(collab).create();
}).config(nord)
.use(commonmark)
.use(gfm)
.use(prism)
.use(indent)
.use(math)
.use(emoji)
.use(collab)
.create();
ydoc.on('destroy', async () => {
commits.discrete?.deregisterOnUpdate();
@ -70,9 +88,11 @@
let history = commits.discrete?.registerOnUpdate((update) => {
Y.applyUpdate(ydoc, update.YXml, {local:true})
has_content = true;
});
for (const h of history) {
Y.applyUpdate(ydoc, h.YXml, {local:true})
has_content = true;
}
}
@ -86,9 +106,24 @@
await editor.destroy();
});
const edit = () => {
set_view_or_edit(false);
}
</script>
<div class="grow p-5 post-rich-text">
{#if !has_content}
<button
on:click={edit}
on:keypress={edit}
class="select-none mb-10 text-white bg-primary-700 hover:bg-primary-700/90 focus:ring-4 focus:ring-primary-500/50 rounded-lg text-base p-2 text-center inline-flex items-center dark:focus:ring-primary-700/55"
>
<PencilSquare tabindex="-1" class="mr-2 focus:outline-none" />
{$t("doc.start_editing")}
</button>
{/if}
<div class="grow p-5 post-rich-text prose">
<div id="mdeditor" class="prosemirror-editor"></div>
</div>

@ -93,7 +93,7 @@
});
</script>
<div class="grow p-5 post-rich-text" style="min-height:300px;">
<div class="grow p-5 post-rich-text prose" style="min-height:300px;">
<ProsemirrorEditor
className="prosemirror-editor"
{editorState}

@ -71,7 +71,7 @@
{#if source}
<div class="post-rich-text">
<div class="post-rich-text prose">
{@html source}
</div>

@ -31,6 +31,9 @@
let width;
let center;
$: center = width > 1024 && !$cur_app?.full_width
let commits;
// TODO deals with cases when nuri has :r :w :l (remove them from nuri that should only have :o:v format , and add them in cur_tab)
$: commits = $active_session && nuri && branch_subscribe(nuri, true);
@ -52,16 +55,16 @@
</Alert>
</div>
{:else}
<div class="flex justify-left" class:justify-center={width>1024} use:inview={inview_options} on:inview_change={(event) => {
<div class="flex justify-left" class:justify-center={center} use:inview={inview_options} on:inview_change={(event) => {
const { inView, entry, scrollDirection, observer, node} = event.detail;
if ($cur_branch) { set_header_in_view(inView); }
if (inView) nav_bar_reset_newest();
}}>
<div class="flex flex-col grow">
<div class="flex flex-col" class:grow={width<=1024 || $cur_app?.full_width}>
{#if $can_have_header}
<div class="flex p-4 max-w-screen-lg justify-start flex-wrap" class:w-[1024px]={width>1024} >
<div class:max-w-screen-lg={center} class="flex p-4 justify-start flex-wrap" class:w-[1024px]={center} >
{#if $header_icon}
<NavIcon img={$header_icon} config={{
tabindex:"-1",
@ -80,21 +83,21 @@
{/if}
</div>
{#if $header_description}
<div class="flex p-4 max-w-screen-lg text-left text-gray-600 dark:text-white" class:w-[1024px]={width>1024}>
<div class:max-w-screen-lg={center} class="flex p-4 text-left text-gray-600 dark:text-white" class:w-[1024px]={center}>
{$header_description}
</div>
{/if}
{/if}
{#if commits}
{#await commits.load()}
<div class="row p-4 max-w-screen-lg text-gray-600" class:w-[1024px]={width>1024}>
<div class:max-w-screen-lg={center} class="row p-4 text-gray-600" class:w-[1024px]={center}>
<p>{$t("connectivity.loading")}...</p>
</div>
{:then}
{#if $cur_app}
{#await load_official_app($cur_app) then app}
<div class="flex max-w-screen-lg" style="overflow-wrap: anywhere;" class:w-[1024px]={width>1024} >
<div class:max-w-screen-lg={center} class="flex" style="overflow-wrap: anywhere;" class:w-[1024px]={center} >
<svelte:component this={app} commits={$commits}/>
</div>
{/await}

@ -59,35 +59,52 @@ td.hljs {
outline-offset: 2px;
}
.post-rich-text em {
.post-rich-text em,
.prose em {
font-style: italic;
font-family: Verdana, Arial, sans-serif;
}
/*
.post-rich-text h1 {
font-size: 2.5rem /* 24px */;
line-height: 4rem /* 32px */;
font-size: 2.5rem;
line-height: 4rem;
}
.post-rich-text h2 {
font-size: 2rem /* 20px */;
line-height: 3rem /* 28px */;
font-size: 2rem;
line-height: 3rem;
}
.post-rich-text h3 {
font-size: 1.5rem /* 18px */;
line-height: 2.5rem /* 28px */;
font-size: 1.5rem;
line-height: 2.5rem;
}
.post-rich-text h4 {
font-size: 1.25rem /* 18px */;
line-height: 2rem /* 28px */;
font-size: 1.25rem;
line-height: 2rem;
font-weight: 700;
}
.post-rich-text h5 {
font-size: 1.125rem /* 18px */;
line-height: 2rem /* 28px */;
font-size: 1.125rem;
line-height: 2rem;
} */
.prose {
max-width: 100%;
}
.prose .emoji {
width: 25px;
}
.prose li p,
.prose dd p {
margin: 0;
}
.prose table {
width: calc(100% - 32px) !important;
}
.menu-bg-modal + div {

@ -224,6 +224,7 @@ export const official_apps = {
"ng:b": "MilkDownEditor",
"ng:o": [],
"ng:w": ["post:md"],
"full_width": true,
},
"n:g:z:code_editor": {
"ng:n": "Text Editor",

@ -28,7 +28,8 @@ const config = {
},
plugins: [
require('flowbite/plugin')
require('flowbite/plugin'),
require('@tailwindcss/typography')
],
darkMode: 'class',
};

@ -17,8 +17,8 @@ export default defineConfig(async () => {
"prosemirror-svelte", "prosemirror-svelte/state", "prosemirror-svelte/helpers", "y-prosemirror", "prosemirror-state", "prosemirror-model", "prosemirror-view", "y-protocols",
"@milkdown/core", "@milkdown/ctx", "@milkdown/prose", "@milkdown/transformer", "@milkdown/preset-commonmark", "@milkdown/theme-nord", "@milkdown/plugin-collab",
"svelte-highlight", "svelte-highlight/languages/typescript", "svelte-highlight/languages/javascript", "svelte-highlight/languages/rust", "@milkdown/preset-gfm",
"@milkdown-lab/plugin-split-editing", "@milkdown/plugin-slash"],
include: ["debug","extend","highlight.js","highlight.js/lib/core","lodash.debounce"]
"@milkdown-lab/plugin-split-editing", "@milkdown/plugin-slash", "@milkdown/utils", "@milkdown/plugin-prism", "@milkdown/plugin-emoji", "@milkdown/plugin-math", "@milkdown/plugin-indent"],
include: ["debug","extend","highlight.js","highlight.js/lib/core","lodash.debounce","@sindresorhus/is","char-regex","emojilib","skin-tone"]
},
worker: {
format: 'es',

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save