1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Text editor eats up space character

Discussion in 'Resolved Bug Reports' started by Dragokas, Apr 26, 2016.

  1. Dragokas

    Dragokas Member


    When we are copying text from MS Word document (I attached example) to text editor, some 'space' characters are disappear:

    There should be two separate words in hightlighted part.

    Compare: If we'll copy the same text from MS Word to Notepad / AkelPad / N++, all characters are displayed correctly.

    Also, I'd like to pay attention on this thread: https://xenforo.com/community/threads/ms-word-paste-fix.115266/


    Attached Files:

  2. cclaerhout

    cclaerhout Well-Known Member

  3. Dragokas

    Dragokas Member

    This is non-standart editor. When we are testing it last time, it had obvious bugs and we generally disliked it for other reasons too.
    So, we decided to refuse using of it. That's why it is not an option.

    My bug report apply to standart edoitor only. We don't plan to replace it.
  4. cclaerhout

    cclaerhout Well-Known Member

    TinyMCE is quite a standard in RTE. It is not the stock Editor since XenForo 1.2.

    Such as?

    Then you will have to code in JavaScript a paste plugin to deal with the Word html specific standard. Good luck with that. This might help you.
  5. rainmotorsports

    rainmotorsports Well-Known Member

    Have you tried pasting as plain text? Just a right click away. Pasting into something like notepad basically is the same thing. While more advanced editors such as the ones in forum software attempt to preserve formatting, MS Word has a ton of garbage to deal with. Pasting only the pure text value from the clipboard usually works better if you need no special formatting.
  6. Dragokas

    Dragokas Member

    Hi, rainmotorsports !
    There is no probem with pasting through an transitional editor like Notepad. But your suggestion destroys all sens of preparing articles on MS Word.
    When there are 10 pages of MS Word, I am able to recover formatting manually. But if there a lot -> it's almost impossible and no sens.

    cclaerhout, thank you. Maybe if I was Java Developer, it could be a way.
    Intead of that I found another solution that correctly works for any forum -> I wrote MS Word macros which replace several kinds of formatting into BB-codes.
    So, maybe it will be useful to other people who face with this problem too. I decided to public it here.

    Sequence: Run macros on your MS Word article*, copy resulting text to Notepad, copy text from Notepad to forum. Profit.
    Currently macros configured on such kinds of formatting:
    - replace font size (10, 12, 14, 16). By default - 12.
    - replace hyperlinks
    - bold
    - italic
    - red color
    - blue color
    - center alignment
    - and any combinations of these

    * to apply macro, you should insert it once on normal.dot. Then It will be work on any document without necessity to paste it again.
    On any doc, Left ALT + F8, Create, Change, insert following code.
    To apply macro on your doc -> open your doc, Left Alt + F8, choose name of macro, Run.
    Option Explicit
    Private Enum TEXT_PROPERTY
        TEXT_BOLD = 1
        TEXT_SIZE_10 = 10
        TEXT_SIZE_12 = 12
        TEXT_SIZE_14 = 14
        TEXT_SIZE_16 = 16
    End Enum
        BEG As String
        END As String
    End Type
    Private Type BB_TAG_CODE
        BOLD            As POSITION_CONTEXT
    End Type
    Private Const DEFAULT_SIZE = TEXT_SIZE_12   'размер текста по-умолчанию
    Public TAG As BB_TAG_CODE
    ' заполнение соответствий форматирования MS Word и BB-кодам
    Private Sub Mapping_Init()
        With TAG
            .BOLD.BEG = "[b]"
            .BOLD.END = "[/b]"
            .ITALIC.BEG = "[i]"
            .ITALIC.END = "[/i]"
            .TEXT_SIZE_10.BEG = "[size=3]"
            .TEXT_SIZE_10.END = "[/size]"
            .TEXT_SIZE_12.BEG = "[size=4]"
            .TEXT_SIZE_12.END = "[/size]"
            .TEXT_SIZE_14.BEG = "[size=5]"
            .TEXT_SIZE_14.END = "[/size]"
            .TEXT_SIZE_16.BEG = "[size=6]"
            .TEXT_SIZE_16.END = "[/size]"
            .COLOR_RED.BEG = "[color=red]"
            .COLOR_RED.END = "[/color]"
            .COLOR_BLUE.BEG = "[color=blue]"
            .COLOR_BLUE.END = "[/color]"
            .POS_CENTER.BEG = "[center]"
            .POS_CENTER.END = "[/center]"
        End With
    End Sub
    Public Sub A_Replace_Into_BBcode()
        Dim Style1
        Dim Style2
        Dim Style3
        Dim Style4
        Dim Style5
        Dim hh As Hyperlink
        For Each hh In ActiveDocument.Hyperlinks
            hh.TextToDisplay = "[url=" & hh.Address & "]" & IIf(hh.TextToDisplay = "", "X", hh.TextToDisplay) & "[/url]"
        Call Mapping_Init
        For Each Style1 In Array(TEXT_BOLD, 0)
            For Each Style2 In Array(TEXT_ITALIC, 0)
                For Each Style3 In Array(TEXT_SIZE_10, TEXT_SIZE_12, TEXT_SIZE_14, TEXT_SIZE_16)
                    For Each Style4 In Array(TEXT_RED, TEXT_BLUE, 0)
                        For Each Style5 In Array(TEXT_CENTER, 0)
                            StyleToBB Style1, Style2, Style3, Style4, Style5
    End Sub
    Private Sub StyleToBB(ParamArray Styles())
        Dim Style, BB_Beg$, BB_End$, BB_Beg_Concat$, BB_End_Concat$
        With Selection.Find
            For Each Style In Styles
                BB_Beg = ""
                BB_End = ""
                Select Case CLng(Style)
                    Case TEXT_BOLD
                        .Font.BOLD = True
                        .Replacement.Font.BOLD = False
                        BB_Beg = TAG.BOLD.BEG
                        BB_End = TAG.BOLD.END
                    Case TEXT_ITALIC
                        .Font.ITALIC = True
                        .Replacement.Font.ITALIC = False
                        BB_Beg = TAG.ITALIC.BEG
                        BB_End = TAG.ITALIC.END
                    Case TEXT_SIZE_10
                        .Font.Size = 10
                        .Replacement.Font.Size = DEFAULT_SIZE
                        BB_Beg = TAG.TEXT_SIZE_10.BEG
                        BB_End = TAG.TEXT_SIZE_10.END
                    Case TEXT_SIZE_12
                        .Font.Size = 12
                        .Replacement.Font.Size = DEFAULT_SIZE
                        BB_Beg = TAG.TEXT_SIZE_12.BEG
                        BB_End = TAG.TEXT_SIZE_12.END
                    Case TEXT_SIZE_14
                        .Font.Size = 14
                        .Replacement.Font.Size = DEFAULT_SIZE
                        BB_Beg = TAG.TEXT_SIZE_14.BEG
                        BB_End = TAG.TEXT_SIZE_14.END
                    Case TEXT_SIZE_16
                        .Font.Size = 16
                        .Replacement.Font.Size = DEFAULT_SIZE
                        BB_Beg = TAG.TEXT_SIZE_16.BEG
                        BB_End = TAG.TEXT_SIZE_16.END
                    Case TEXT_RED
                        .Font.Color = wdColorRed
                        .Replacement.Font.Color = wdColorAutomatic
                        BB_Beg = TAG.COLOR_RED.BEG
                        BB_End = TAG.COLOR_RED.END
                    Case TEXT_BLUE
                        .Font.Color = wdColorBlue
                        .Replacement.Font.Color = wdColorAutomatic
                        BB_Beg = TAG.COLOR_BLUE.BEG
                        BB_End = TAG.COLOR_BLUE.END
                    Case TEXT_CENTER
                        .ParagraphFormat.Alignment = wdAlignParagraphCenter
                        .Replacement.ParagraphFormat.Alignment = wdAlignParagraphLeft
                        BB_Beg = TAG.POS_CENTER.BEG
                        BB_End = TAG.POS_CENTER.END
                End Select
                If Style <> DEFAULT_SIZE Then
                    BB_Beg_Concat = BB_Beg & BB_Beg_Concat$
                    BB_End_Concat = BB_End_Concat & BB_End
                End If
            .Replacement.Text = BB_Beg_Concat & "^&" & BB_End_Concat
            .Execute FindText:="", Replace:=wdReplaceAll, Wrap:=wdFindContinue
        End With
    End Sub
  7. Mike

    Mike XenForo Developer Staff Member

    I've identified the cause of this now and I believe I have worked around it. (The fix should be running here now if you'd like to test.)
    Dragokas likes this.
  8. Dragokas

    Dragokas Member

    Thank you, Mike! It seems looks fine now.

    It would be great if you try to fix a bug with extra line breaks also.

Share This Page