[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gambas-bugtracker] Bug #3181: Add new features into WebTextArea object


http://gambaswiki.org/bugtracker/edit?object=BUG.3181&from=L21haW4-

Olivier CRUILLES reported a new bug.

Summary
-------

Add new features into WebTextArea object

Type             : Request
Priority         : Medium
Gambas version   : Master
Product          : Web components


Description
-----------

Hi Benoit,

I would like to request new features for the WebTextArea object that will help me a lot with a new project using gb.web.gui component, like we have for the TextEditor on desktop side.
I'm working to build a new Gambas France Forum to improve functionalities based on gb.web.gui. Fabien is aware about this very recent project.
In the end it will be a really good test of a real web site in Gambas (gb.web.gui) exposed on Internet.

Could it be possible to add this list of feature:

- WebTextArea.Column

- WebTextArea.Line

- WebTextArea.Selection() -> to get the current selected text

- WebTextArea.Selectioned

- WebTextArea.Insert(Text As String)

- WebTexArea.Select([Start As Integer, Length As Integer])

- WebTextArea.SelectAll()


It will great to have all those features.

The goal for me in my project is to mimic the functionalities of a simple markdown editor.
For example, offer base buttons to set Bolt/Italic/Underline/strikethrough/etc to a text selected by the user in the WebTextArea.
For that reason the requested features will help me a lot.

For now, I need to directly inject Javascript commands to manipulate/search/replace the selected text in the TextArea.
It works but it's not really clean regarding how the gb.web.gui is built.

Example of Javascript injection:

Public Sub WebButtonTextBold_Click()
  Remplace_Texte_Selection(WebTextAreaEditDoc.Name, "**", "**")

  ModLogs.EcrireLogs("WebButtonTest_Click()")
End

Public Sub Remplace_Texte_Selection(IdTextArea As String, MotifDebut As String, MotifFin As String)

  Dim CodeJS As String

  CodeJs = "(() => {"
  "  try {"
  "    const textarea = document.getElementById('" & IdTextArea & "');"
  "    const start = textarea.selectionStart;"
  "    const end = textarea.selectionEnd;"
  "    const motifDebut = '" & MotifDebut & "';"
  "    const motifFin = '" & MotifFin & "';"
  "    let selectedText = textarea.value.substring(start, end);"
  "    const hasStart = selectedText.startsWith(motifDebut);"
  "    const hasEnd = selectedText.endsWith(motifFin);"
  "    if (hasStart && hasEnd) {"
  "        selectedText = selectedText.substring(motifDebut.length,selectedText.length - motifFin.length);"
  "    } else {"
  "      selectedText = motifDebut + selectedText + motifFin;"
  "    }"
  "    textarea.focus();"
  "    textarea.setRangeText(selectedText, start, end, 'end');"
  "    gw.updates['" & IdTextArea & "'] = gw.textarea.updateText;"
  "    const newStart = start;"
  "    const newEnd = start + selectedText.length;"
  "    setTimeout(() => {"
  "      textarea.focus();"
  "      textarea.setSelectionRange(newStart, newEnd);"
  "    }, 0);"
  "  } catch (error) {"
  "    return 'ERR';"
  "  }"
  "})();"


  Try TexteSelect = Me.Exec(CodeJs)

  ModLogs.EcrireLogs("Remplace_Texte_Selection()")

End

Merci
Olivier


System information
------------------

[System]
Gambas=3.21.99 464d6c38d (master)
OperatingSystem=Linux
Distribution=Fedora Linux 42 (MATE-Compiz)
Kernel=6.19.14-101.fc42.x86_64
Architecture=x86_64
Cores=8
Memory=32026M
Language=fr_FR.UTF-8
Platform=x11
Desktop=MATE
DesktopResolution=93
DesktopScale=7
WidgetTheme=proxy
Font=Liberation Sans,10
DarkTheme=False
[Programs]
appimage-builder=
clang=clang version 20.1.8 (Fedora 20.1.8-4.fc42)
dpkg=Programme « dpkg » de gestion de paquets Debian version 1.23.7 (amd64).
gcc=gcc (GCC) 15.2.1 20260123 (Red Hat 15.2.1-7)
git=git version 2.54.0
msgmerge=msgmerge (GNU gettext-tools) 0.23.1
pngquant=4.0.0 (January 2023)
rpmbuild=RPM version 4.20.1
trans=Translate Shell 0.9.7.1-git:dc67af4
[Libraries]
Cairo=libcairo.so.2.11802.2
Curl=libcurl.so.4.8.0
DBus=libdbus-1.so.3.38.3
GDK2=libgdk-x11-2.0.so.0.2400.33
GDK3=libgdk-3.so.0.2420.32
GStreamer=libgstreamer-1.0.so.0.2611.0
GTK+2=libgtk-x11-2.0.so.0.2400.33
GTK+3=libgtk-3.so.0.2420.32
OpenGL=libGL.so.1.7.0
Poppler=libpoppler.so.146.0.0
QT4=libQtCore.so.4.8.7
QT5=libQt5Core.so.5.15.18
QT6=libQt6Core.so.6.10.2
RSvg=librsvg-2.so.2.60.0
SDL=libSDL2-2.0.so.0.3200.64
SQLite3=libsqlite3.so.0.8.6
[Environment]
CAPP_BUILD=<home>/Packages/Starter/Build
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DEBUGINFOD_IMA_CERT_PATH=/etc/keys/ima:
DEBUGINFOD_URLS=https://debuginfod.fedoraproject.org/ 
DESKTOP_SESSION=mate
DIALOGBLOCKSDIR=/usr/share/dialogblocks
DISPLAY=:0
EDITOR=/usr/bin/nano
FREETYPE_PROPERTIES=truetype:interpreter-version=35
GB_GUI=gb.qt6
GDMSESSION=mate
GDM_LANG=fr_FR.UTF-8
GIO_LAUNCHED_DESKTOP_FILE_PID=18615
GPG_TTY=pas un tty
GTK3_MODULES=xapp-gtk3-module
GTKM_INSERT_EMOJI=1
GTK_BACKDROP=1
GTK_ENLARGE_SCROLLBAR=1
GTK_FOCUS_VISIBLE=1
GTK_OVERLAY_SCROLLING=0
GTK_PROGRESS_TEXT_INSIDE=1
GTK_TREEVIEW_LINES=0
GTK_USE_IEC_UNITS=1
HISTCONTROL=ignoredups
HISTSIZE=1000
HISTTIMEFORMAT=%F %T 
HOME=<home>
HOSTNAME=<hostname>
IMSETTINGS_INTEGRATE_DESKTOP=yes
IMSETTINGS_MODULE=none
KDEDIRS=/usr
LANG=fr_FR.UTF-8
LANGUAGE=fr_FR.UTF-8
LESSOPEN=||/usr/bin/lesspipe.sh %s
LOGNAME=<user>
MAIL=/var/spool/mail/<user>
MANPAGER=less
MATE_DESKTOP_SESSION_ID=this-is-deprecated
MOZ_GMP_PATH=/usr/lib64/mozilla/plugins/gmp-gmpopenh264/system-installed
PAGER=most
PATH=<home>/.local/bin:<home>/.cargo/bin:<home>/narwhal/bin:<home>/.opencode/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:<home>/.cargo/bin:/usr/local/bin:/usr/bin:/usr/sbin:/var/lib/snapd/snap/bin:<home>/bin:/usr/local/xaralx/bin
PWD=<home>
QTDIR=/usr/lib64/qt-3.3
QTINC=/usr/lib64/qt-3.3/include
QTLIB=/usr/lib64/qt-3.3/lib
QT_FONT_DPI=93
QT_IM_MODULE=xim
QT_LOGGING_RULES=*.debug=false
QT_SCALE_FACTOR=1
SESSION_MANAGER=local/unix:@/tmp/.ICE-unix/2070541,unix/unix:/tmp/.ICE-unix/2070541
SHELL=/bin/bash
SHLVL=1
SSH_AGENT_PID=2070777
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
TERM=dumb
TZ=:/etc/localtime
USER=<user>
XAUTHORITY=/run/lightdm/<user>/xauthority
XDG_CURRENT_DESKTOP=MATE
XDG_DATA_DIRS=<home>/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/<user>
XDG_RUNTIME_DIR=/run/user/1000
XDG_SEAT=seat0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_CLASS=user
XDG_SESSION_DESKTOP=mate
XDG_SESSION_ID=9409
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session1
XDG_SESSION_TYPE=x11
XDG_VTNR=1
XMODIFIERS=@im=none
_=/usr/bin/gambas3
force_s3tc_enable=true
key2FA1=GHPTQQ4GDRNTZBKG4P5ZFH24RA



----[ Gambas bugtracker-list is hosted by https://www.hostsharing.net ]----