mover css de bubblemenu a sus componentes

This commit is contained in:
Cat /dev/Nulo 2023-03-16 10:07:33 -03:00
parent cc361f107b
commit 7668c4a805
4 changed files with 81 additions and 92 deletions

View file

@ -25,6 +25,7 @@
import { refreshCoords as _refreshCoords } from "./bubblemenu/coords";
import SimpleMarkItem from "./bubblemenu/SimpleMarkItem.svelte";
import { nanoid } from "nanoid";
import Button from "./bubblemenu/Button.svelte";
export let view: EditorView;
export let state: EditorState;
@ -148,17 +149,13 @@
<SimpleMarkItem {view} {state} type={view.state.schema.marks.strikethrough}
><StrikethroughIcon style={svgStyle} /></SimpleMarkItem
>
<button
type="button"
class:active={markIsActive(state, view.state.schema.marks.link)}
on:mousedown|preventDefault={startEditingLink}
><LinkIcon style={svgStyle} /></button
<Button
active={markIsActive(state, view.state.schema.marks.link)}
onClick={startEditingLink}><LinkIcon style={svgStyle} /></Button
>
<button
type="button"
class:active={markIsActive(state, view.state.schema.marks.internal_link)}
on:mousedown|preventDefault={createInternalLink}
><InternalLinkIcon style={svgStyle} /></button
<Button
active={markIsActive(state, view.state.schema.marks.internal_link)}
onClick={createInternalLink}><InternalLinkIcon style={svgStyle} /></Button
>
{:else if changingProp.type === "link"}
<input
@ -168,11 +165,39 @@
on:change|preventDefault={onChangeLink}
value={changingProp.url}
/>
<button
type="button"
title="Borrar enlace"
on:mousedown|preventDefault={removeLink}
><CloseIcon style={svgStyle} /></button
<Button title="Borrar enlace" onClick={removeLink}
><CloseIcon style={svgStyle} /></Button
>
{/if}
</div>
<style>
.bubble {
display: flex !important;
position: absolute;
z-index: 420;
transform: translateX(-50%);
background: black;
color: white;
border-radius: 5px;
padding: 0rem;
margin-bottom: 0.5rem;
visibility: visible;
opacity: 1;
transition: opacity 0.2s, visibility 0.2s;
}
.bubble[hidden] {
visibility: hidden;
opacity: 0;
}
.bubble input {
appearance: none;
background: none;
color: inherit;
border: none;
font-size: 1.25em;
}
</style>

View file

@ -0,0 +1,38 @@
<script lang="ts">
export let active: boolean = false;
export let onClick: (event: Event) => void;
export let title: string = "";
</script>
<button
type="button"
{title}
class:active
on:mousedown|preventDefault={onClick}
>
<slot />
</button>
<style>
button {
appearance: none;
background: none;
color: inherit;
border: none;
border-radius: 2px;
padding: 0.3em;
margin: 0.2em;
width: 1.8rem;
height: 1.8rem;
font-size: 1em;
line-height: 1;
transition: background 0.2s;
}
button:hover {
background: #333;
}
button.active {
background: #555;
}
</style>

View file

@ -5,6 +5,7 @@
import { toggleMark } from "prosemirror-commands";
import { commandListener, markIsActive } from "../ps-utils";
import Button from "./Button.svelte";
export let view: EditorView;
export let state: EditorState;
@ -15,10 +16,10 @@
$: listener = commandListener(view, toggleMark(type));
</script>
<button type="button" class:active={isActive} on:mousedown={listener}>
<Button active={isActive} onClick={listener}>
{#if small}
<small><slot /></small>
{:else}
<slot />
{/if}
</button>
</Button>

View file

@ -23,11 +23,6 @@
border-bottom: 1px solid #bbb;
}
.editor .menubar .separator {
border-right: 2px solid #bbb;
margin: 0 0.5rem;
}
.editor .menubar button {
appearance: none;
background: none;
@ -52,76 +47,6 @@
height: 1.5rem;
}
.editor .bubble {
display: flex !important;
position: absolute;
z-index: 420;
transform: translateX(-50%);
background: black;
color: white;
border-radius: 5px;
padding: 0rem;
margin-bottom: 0.5rem;
visibility: visible;
opacity: 1;
transition: opacity 0.2s, visibility 0.2s;
}
.editor .bubble[hidden] {
visibility: hidden;
opacity: 0;
}
.editor .bubble input {
appearance: none;
background: none;
color: inherit;
border: none;
font-size: 1.25em;
}
.editor .bubble .separator {
border-right: 1px solid #777;
margin: 0 0.5rem;
}
.editor .bubble button {
appearance: none;
background: none;
color: inherit;
border: none;
border-radius: 2px;
padding: 0.3em;
margin: 0.2em;
width: 1.8rem;
height: 1.8rem;
font-size: 1em;
line-height: 1;
transition: background 0.2s;
}
.editor .bubble button:hover {
background: #333;
}
.editor .bubble button.active {
background: #555;
}
.editor .bubble .color-button {
padding: 0.4em;
}
.editor .bubble .color {
display: inline-block;
width: 1em;
height: 1em;
border-radius: 100%;
}
.editor .bubble p {
margin: 0;
}
.ProseMirror {
width: 100%;
padding: 0.5em;