Skip to content

Commit

Permalink
🐎 Improve: Enhance existing functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
nookery committed Jan 17, 2025
1 parent e6dd954 commit eb75c43
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Sources/JuiceEditorKit/Server/HTTPServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Vapor
public class HTTPServer: ObservableObject, SuperThread {
public var app: Application?
public let directoryPath: String
public let isDevMode = true
public let isDevMode = false
public var port: Int = 49493
public let vueDevServerURL = "http://localhost:5173"
public var delegate: EditorDelegate
Expand Down Expand Up @@ -127,5 +127,5 @@ extension HTTPServer {
#Preview {
EditorView(verbose: true)
.frame(height: 1000)
.frame(width: 700)
.frame(width: 1700)
}
6 changes: 3 additions & 3 deletions Sources/JuiceEditorKit/Views/EditorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extension EditorDelegate {
}

public func onReady() {
warning("Editor Ready")
warning("EditorDelegate: Editor Ready")
}

public func onUpdateNodes(_ nodes: [EditorNode]) {
Expand Down Expand Up @@ -80,6 +80,6 @@ public struct DefaultDelegate: EditorDelegate {}

#Preview {
EditorView(verbose: true)
.frame(height: 1000)
.frame(width: 700)
.frame(height: 1500)
.frame(width: 900)
}
12 changes: 10 additions & 2 deletions Sources/JuiceEditorKit/Views/EditorViewApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,16 @@ public extension EditorView {
try await run("window.editor.disableFloatingMenu()")
}

func disableFlotingMenuAndBubbleMenu() async throws -> Any {
try await run("window.editor.disableFlotingMenuAndBubbleMenu()")
@discardableResult
func disableDebugBar() async throws -> Any {
debug("disableDebugBar")
let result = try await run("window.editor.disableDebugBar()")
debug("disableDebugBar result: \(result)")
return result
}

func disableFloatingMenuAndBubbleMenu() async throws -> Any {
try await run("window.editor.disableFloatingMenuAndBubbleMenu()")
}

func disableEdit() async throws -> Any {
Expand Down
3 changes: 2 additions & 1 deletion Sources/JuiceEditorKit/Views/EditorViewEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ extension EditorView {
do {
try await self.setChatApi(server.chatApi)
try await self.setDrawLink(server.drawIoLink)
try await self.disableFloatingMenu()
try await self.disableDebugBar()

self.delegate.onReady()
} catch {
Expand Down Expand Up @@ -132,7 +134,6 @@ extension EditorView {
} else {
}
}

}

#Preview {
Expand Down
19 changes: 12 additions & 7 deletions src/extensions/DebugBar/DebugBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ const DebugBar = TiptapExtension.create({

disableDebugBar: () => ({ }) => {
this.storage.enabled = false

if (this.storage.verbose) {
this.editor.commands.appendLog(this.storage.title, '🚀 disableDebugBar')
console.log('disableDebugBar')
}

this.editor.commands.closeDebugBar()
return true
},

Expand Down Expand Up @@ -88,6 +95,10 @@ const DebugBar = TiptapExtension.create({
return true
}

if (this.storage.verbose) {
console.log('showDebugBar')
}

const mountPoint = document.createElement('div');
mountPoint.id = this.options.mountPointId;
mountPoint.style.position = 'fixed';
Expand All @@ -99,20 +110,14 @@ const DebugBar = TiptapExtension.create({
mountPoint.style.justifyContent = 'center';
mountPoint.style.zIndex = '9999';
mountPoint.style.transition = 'all 0.4s cubic-bezier(0.4, 0, 0.2, 1)';
mountPoint.style.opacity = '0';
mountPoint.style.opacity = '1';
mountPoint.style.transformOrigin = 'bottom';
mountPoint.style.transform = 'scale(0.95)';
mountPoint.style.backgroundColor = 'rgba(0, 0, 0, 0)';

let editorElement = this.editor.options.element
editorElement.appendChild(mountPoint);

requestAnimationFrame(() => {
mountPoint.style.opacity = '1';
mountPoint.style.transform = 'scale(1)';
mountPoint.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
});

const app = createApp({
render() {
return h(DebugView, {
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/DebugBar/DebugView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ onMounted(() => {
})
function closeMessage() {
props.editor.commands.toggleDebugBar()
props.editor.commands.disableDebugBar()
}
function toggleTree() {
Expand Down
8 changes: 1 addition & 7 deletions src/extensions/SmartAlert/SmartAlert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,13 @@ const SmartAlert = TiptapExtension.create({
mountPoint.style.alignItems = 'center';
mountPoint.style.zIndex = '9999';
mountPoint.style.transition = 'all 0.4s cubic-bezier(0.4, 0, 0.2, 1)';
mountPoint.style.opacity = '0';
mountPoint.style.opacity = '1';
mountPoint.style.transform = 'scale(0.95)';
mountPoint.style.backgroundColor = 'rgba(0, 0, 0, 0)';

let editorElement = this.editor.options.element
editorElement.appendChild(mountPoint);

requestAnimationFrame(() => {
mountPoint.style.opacity = '1';
mountPoint.style.transform = 'scale(1)';
mountPoint.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
});

const app = createApp({
render() {
return h(Component, {
Expand Down
1 change: 1 addition & 0 deletions src/pages/Root.ce.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const editor = new EditorVue({
publicEditor.options.onCreate?.(publicEditor)
editor.commands.boot()
publicEditor.options.onBooted?.(publicEditor)
updateLoadingState()
},
onContentError: (error) => {
publicEditor.options.onContentError?.()
Expand Down

0 comments on commit eb75c43

Please sign in to comment.