-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Action bar button to toggle read-only mode and move isEditable …
…context into Composer
- Loading branch information
Showing
4 changed files
with
31 additions
and
16 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
packages/svelte-lexical/src/lib/components/actionbar/ActionBar.svelte
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
<script lang="ts"> | ||
import ImportButton from './ImportButton.svelte'; | ||
import ExportButton from './ExportButton.svelte'; | ||
import ReadonlyButton from './ReadonlyButton.svelte'; | ||
</script> | ||
|
||
<div class="actions"> | ||
<ImportButton /> | ||
<ExportButton /> | ||
<ReadonlyButton /> | ||
</div> |
17 changes: 17 additions & 0 deletions
17
packages/svelte-lexical/src/lib/components/actionbar/ReadonlyButton.svelte
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<script lang="ts"> | ||
import type {LexicalEditor} from 'lexical'; | ||
import {getEditor, getIsEditable} from '$lib/core/composerContext.js'; | ||
const editor: LexicalEditor = getEditor(); | ||
const isEditable = getIsEditable(); | ||
</script> | ||
|
||
<button | ||
class={`action-button ${!$isEditable ? 'unlock' : 'lock'}`} | ||
on:click={() => { | ||
editor.setEditable(!editor.isEditable()); | ||
}} | ||
title="Read-Only Mode" | ||
aria-label={`${!$isEditable ? 'Unlock' : 'Lock'} read-only mode`}> | ||
<i class={!$isEditable ? 'unlock' : 'lock'} /> | ||
</button> |
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 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